-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
39 lines (31 loc) · 815 Bytes
/
sketch.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
class Sketch {
constructor(camera) {
this.camera = camera;
}
setup(width, height) {
this.gfx = createGraphics(width, height);
// Draw the background
this.camera.clear_screen(this.gfx);
// We don't have a renderer until the first call of build();
this.renderer = null;
}
/**
* Attach all the components and clear the screen.
*/
build(renderer) {
this.renderer = renderer;
this.camera.clear_screen(this.gfx);
}
/**
* Draw on the buffer
*/
draw() {
this.camera.start_complex_plane(this.gfx);
if (this.renderer !== null)
this.renderer.draw(this.gfx);
this.camera.finish_complex_plane(this.gfx);
}
display() {
image(this.gfx, 0, 0);
}
}