lazy-widgets
Version:
Typescript retained mode GUI for the HTML canvas API
34 lines • 1.12 kB
JavaScript
import { safeRoundRect } from '../helpers/safeRoundRect.js';
import { PassthroughWidget } from './PassthroughWidget.js';
import { SingleParentXMLInputConfig } from '../xml/SingleParentXMLInputConfig.js';
/**
* A container widget that rounds the corners of a child widget.
*
* @category Widget
*/
export class RoundedCorners extends PassthroughWidget {
constructor(child, properties) {
super(child, properties);
}
onThemeUpdated(property = null) {
super.onThemeUpdated(property);
if (property === null || property === 'roundedCornersRadii') {
this.markWholeAsDirty();
}
}
handlePainting(dirtyRects) {
// Paint brackground
const ctx = this.viewport.context;
ctx.save();
ctx.beginPath();
safeRoundRect(ctx, this.x, this.y, this.width, this.height, this.roundedCornersRadii);
ctx.clip();
super.handlePainting(dirtyRects);
ctx.restore();
}
}
RoundedCorners.autoXML = {
name: 'rounded-corners',
inputConfig: SingleParentXMLInputConfig
};
//# sourceMappingURL=RoundedCorners.js.map