-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path20181130.ts
More file actions
38 lines (32 loc) · 810 Bytes
/
20181130.ts
File metadata and controls
38 lines (32 loc) · 810 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 { Colors } from "./Colors";
const screenSize = 128;
const frameCount = 10;
const grassMax = 20;
export class DailyDoodle implements Doodle {
private frame = 0;
private grassBend = 0;
private grassDir = 1;
public init() {
// nop
}
public update() {
this.frame++;
if(this.frame >= frameCount) {
this.grassBend += this.grassDir;
if (Math.abs(this.grassBend) >= grassMax) {
this.grassDir *= -1;
}
}
}
public draw(ctx: CanvasRenderingContext2D) {
ctx.clearRect(0, 0, screenSize, screenSize);
ctx.strokeStyle = Colors.green;
for (let i = 0; i < screenSize; i += 5) {
ctx.beginPath();
ctx.moveTo(i,32);
ctx.quadraticCurveTo(i+this.grassBend,96,64,128);
ctx.stroke();
}
}
}