Added ctx to draw methods
This commit is contained in:
28
src/API.ts
28
src/API.ts
@ -2200,6 +2200,34 @@ export class UserAPI {
|
|||||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public width = (): number => {
|
||||||
|
/**
|
||||||
|
* Returns the width of the canvas.
|
||||||
|
* @returns The width of the canvas
|
||||||
|
*/
|
||||||
|
const canvas: HTMLCanvasElement = this.app.interface.drawings as HTMLCanvasElement;
|
||||||
|
return canvas.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public height = (): number => {
|
||||||
|
/**
|
||||||
|
* Returns the height of the canvas.
|
||||||
|
* @returns The height of the canvas
|
||||||
|
*/
|
||||||
|
const canvas: HTMLCanvasElement = this.app.interface.drawings as HTMLCanvasElement;
|
||||||
|
return canvas.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public draw = (func: Function): void => {
|
||||||
|
/**
|
||||||
|
* Draws on the canvas.
|
||||||
|
* @param func - The function to execute
|
||||||
|
*/
|
||||||
|
const canvas: HTMLCanvasElement = this.app.interface.drawings as HTMLCanvasElement;
|
||||||
|
const ctx = canvas.getContext("2d")!;
|
||||||
|
func(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
public circle = (
|
public circle = (
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
|
|||||||
@ -464,7 +464,7 @@ export abstract class AudibleEvent extends AbstractEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public draw = (lambda: Function) => {
|
public draw = (lambda: Function) => {
|
||||||
lambda(this.values);
|
lambda(this.values, (this.app.interface.drawings as HTMLCanvasElement).getContext("2d"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user