-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20181207.ts
More file actions
45 lines (39 loc) · 1.18 KB
/
20181207.ts
File metadata and controls
45 lines (39 loc) · 1.18 KB
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
import Doodle from "./Doodle";
import { Point } from "./Point";
import { PointOscillator } from "./PointOscillator";
import { Colors } from "./Colors";
const screenSize = 128;
const pointCount = 1000;
const bigRadius = 80;
const littleRadius = 30;
export class DailyDoodle implements Doodle {
private pos: PointOscillator[] = [];
public init() {
for (let i = 0; i < pointCount; i++) {
const angle = 2 * Math.PI * (i / pointCount);
const bigCircleX = 64 + Math.tan(angle) * bigRadius;
const bigCircleY = 64 + Math.sin(angle) * bigRadius;
const littleCircleX = 64 + Math.tan(angle) * littleRadius;
const littleCircleY = 64 + Math.sin(angle) * littleRadius;
this.pos.push(
new PointOscillator(
new Point(littleCircleX, littleCircleY),
new Point(bigCircleX, bigCircleY)
)
);
}
}
public update() {
for (const po of this.pos) {
po.update();
}
}
public draw(ctx: CanvasRenderingContext2D) {
ctx.fillStyle = Colors.darkPurple;
ctx.fillRect(0, 0, screenSize, screenSize);
ctx.fillStyle = Colors.white;
for (const po of this.pos) {
ctx.fillRect(po.p.x, po.p.y, 1, 1);
}
}
}