lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
32 lines • 970 B
JavaScript
import { SingleParentXMLInputConfig } from '../xml/SingleParentXMLInputConfig.js';
import { BaseContainer } from './BaseContainer.js';
/**
* A container widget that adds a background color.
*
* @category Widget
*/
export class Background extends BaseContainer {
constructor(child, properties) {
super(child, properties);
}
onThemeUpdated(property = null) {
super.onThemeUpdated(property);
if (property === null || property === 'canvasFill') {
this.markWholeAsDirty();
}
}
handlePainting(dirtyRects) {
// Paint brackground
const ctx = this.viewport.context;
ctx.save();
ctx.fillStyle = this.canvasFill;
ctx.fillRect(this.x, this.y, this.width, this.height);
ctx.restore();
super.handlePainting(dirtyRects);
}
}
Background.autoXML = {
name: 'background',
inputConfig: SingleParentXMLInputConfig
};
//# sourceMappingURL=Background.js.map