-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch31.js
50 lines (43 loc) · 1.12 KB
/
sketch31.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
44
45
46
47
48
49
50
'use strict';
class Sketch31 extends Sketch {
constructor() {
super();
this.scale = 1;
this.width = Math.floor(this.canvas.width / this.scale);
this.height = this.width;
}
load() {
super.load();
this.chars = [
'\ud83c\udf83',
'\ud83e\udd87',
'\ud83c\udf6c',
'\ud83d\udc7b',
'\ud83d\ude08'
];
}
update() {
}
draw(ctx, width, height, t, mousePoint) {
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, width, height);
//text
ctx.font = '100px Arial';
ctx.fillStyle = 'white';
ctx.translate(width / 2, 0);
ctx.textAlign = 'center';
ctx.fillText('Happy', 0, 100);
ctx.fillText('Halloween', 0, 200);
//characters moving around
for (let i = 0; i < 5; i++) {
const a = t + Math.PI * 2 * i / 5;
const x = 200 * Math.cos(a);
const y = 350 + 100 * Math.sin(a);
const size = 100 + 50 * Math.sin(a);
ctx.font = `${size}px Arial`;
ctx.fillText(this.chars[i], x, y);
}
}
}
app.sketches[31] = new Sketch31();
app.sketches[31].desc = `Trick or treat?!`;