added drawRotated

This commit is contained in:
Emma
2023-02-07 11:53:18 -07:00
parent c24bd45718
commit 2dbaeb57b9
3 changed files with 31 additions and 0 deletions

View File

@@ -163,6 +163,15 @@ export class Doodler {
this.ctx.stroke();
}
drawRotated(origin: Vector, angle: number, cb: () => void){
this.ctx.save();
this.ctx.translate(origin.x, origin.y);
this.ctx.rotate(angle);
this.ctx.translate(-origin.x, -origin.y);
cb();
this.ctx.restore();
}
setStyle(style?: IStyle) {
const ctx = this.ctx;
ctx.fillStyle = style?.color || style?.fillColor || 'black';