Change Scene draw API
Closed this issue · 1 comments
imbrn commented
Instead of using this.canvas
inside a Scene implementation of draw
method, it's more appropriate and favors encapsulation to use canvas
as an argument of that.
We can see an example in the moving-ball
example:
ace/examples/moving-ball/index.ts
Lines 35 to 41 in 235947c
After this API change it should look like:
draw(canvas: Canvas): void {
canvas.fillStyle = "black";
canvas.fill(rect({ x: 0, y: 0, width: this.resolution.width, height: this.resolution.height }));
canvas.fillStyle = "green";
canvas.fill(circle({ x: this.x, y: this.y, radius: 50 }));
}
In this way, we can avoid exposing canvas abstraction to the whole scene but just for the drawing step.
maxwelfcoelho commented
Can I try it? thank you!