-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.js
43 lines (40 loc) · 1.1 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict';
const fs = require('fs');
const path = require('path');
const ThumbnailGenerator = require('./thumbnail');
async function main() {
const gen = new ThumbnailGenerator();
const settings = {
backgroundFilename: path.join(__dirname, 'test', 'lessons', 'resources', 'lesson-builder.png'),
fonts: [
{ name: 'lesson-font', filename: path.join(__dirname, 'fonts', 'KlokanTechNotoSansCJK-Bold.otf'), },
],
text: [
{
font: 'bold 100px lesson-font',
text: 'place-holder',
verticalSpacing: 100,
offset: [100, 120],
textAlign: 'left',
shadowOffset: [15, 15],
strokeWidth: 15,
textWrapWidth: 1000,
},
{
font: 'bold 60px lesson-font',
text: 'lesson-builder',
verticalSpacing: 100,
offset: [-100, -90],
textAlign: 'right',
shadowOffset: [8, 8],
strokeWidth: 15,
textWrapWidth: 1000,
color: 'hsl(340, 100%, 70%)',
},
],
};
const data = await gen.generate(settings);
fs.writeFileSync('test.jpg', data);
await gen.close();
}
main();