-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20181128.ts
More file actions
38 lines (32 loc) · 826 Bytes
/
20181128.ts
File metadata and controls
38 lines (32 loc) · 826 Bytes
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
import Doodle from "./Doodle";
import { RandomColor } from "./Colors";
import { drawHex } from "./Hex";
const screenSize = 128;
export class DailyDoodle implements Doodle {
private colors: string[] = [];
private angle = 0;
public init() {
for (let i = 0; i < 10; i++) {
this.colors.push(RandomColor());
}
}
public update() {
this.angle++;
}
public draw(ctx: CanvasRenderingContext2D) {
ctx.clearRect(0, 0, screenSize, screenSize);
for (let i = 0; i < 10; i++) {
ctx.save();
ctx.fillStyle = this.colors[i];
ctx.translate(64, 64);
let angle = this.angle;
if (i % 2 === 0) {
angle *= -1;
}
ctx.rotate((Math.PI / 180) * angle);
ctx.translate(-64, -64);
drawHex(ctx, 64, 64, 5 * (10 - i));
ctx.restore();
}
}
}