onsight
Version:
Interactive, easy to use JavaScript game framework.
32 lines (24 loc) • 959 B
JavaScript
import { Object2D } from '../../Object2D.js';
import { Thing } from '../../Thing.js';
/**
* A mask can be used to set the drawing region.
* Masks are treated as objects their shape is used to filter other objects shape.
* Multiple mask objects can be active simultaneously, they have to be attached to the object mask list to filter the render region.
* A mask objects is draw using the context.clip() method.
*/
class Mask extends Object2D {
constructor() {
super();
this.isMask = true;
this.type = 'Mask';
}
/**
* Clip the canvas context. Define a clipping path and set the clip using the context.clip() method.
* Ensures that next objects being drawn are clipped to the path stored here.
* More information about canvas clipping https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/clip.
*/
clip(renderer) {
}
}
Thing.register('Mask', Mask);
export { Mask };