-
Notifications
You must be signed in to change notification settings - Fork 2
/
thumbnail-gen.html
64 lines (61 loc) · 1.55 KB
/
thumbnail-gen.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<style>
canvas {
display: block;
padding: 1em;
max-width: calc(100vw - 10px - 2em);
}
</style>
<script src="thumbnail-gen.js"></script>
<script>
'use strict';
async function loadImage(src) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = reject;
img.src = src;
});
}
async function main() {
const logo = await loadImage('http://localhost:8080/threejs/lessons/resources/threejsfundamentals-background.jpg');
for (const text of [
'Planar and Perspective Projection Mapping',
'WordThatIsTooLongToDisplay Projection Mapping',
'WebGLにおける画像処理。続き',
'WebGL 纹理映射的透视纠正',
]) {
const canvas = document.createElement('canvas');
document.body.appendChild(canvas);
canvas.width = logo.width;
canvas.height = logo.height;
genThumbnail({
backgroundImage: logo,
canvas,
text: [
{
text,
font: 'bold 100px sans-serif',
textAlign: 'left',
verticalSpacing: 100,
offset: [100, 150],
shadowOffset: [15, 15],
strokeWidth: 15,
textWrapWidth: 1000,
},
{
text: 'threejsfundamentals.org',
offset: [-100, -90],
font: 'bold 60px sans-serif',
textAlign: 'right',
verticalSpacing: 100,
shadowOffset: [8, 8],
strokeWidth: 15,
textWrapWidth: 1000,
color: 'hsl(340, 100%, 70%)',
},
],
});
}
}
main();
</script>