♻️ switching to typescript
This commit is contained in:
40
src/nodes/Canvas2d/Fill.ts
Normal file
40
src/nodes/Canvas2d/Fill.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import Canvas2d from './Canvas2d';
|
||||
import {
|
||||
NumberVar,
|
||||
ColorVar
|
||||
} from '../io/AbstractIOSet';
|
||||
|
||||
const inputs = {
|
||||
image: null,
|
||||
width: {
|
||||
type: 'Number',
|
||||
default: 100,
|
||||
min: 1,
|
||||
} as NumberVar,
|
||||
height: {
|
||||
type: 'Number',
|
||||
default: 100,
|
||||
min: 1,
|
||||
} as NumberVar,
|
||||
color: {
|
||||
type: 'Color',
|
||||
default: '#FFFFFF'
|
||||
} as ColorVar
|
||||
};
|
||||
const outputs = {};
|
||||
|
||||
export default class Fill extends Canvas2d<typeof inputs, typeof outputs> {
|
||||
|
||||
constructor() {
|
||||
super('Fill', inputs, outputs);
|
||||
this._update();
|
||||
}
|
||||
|
||||
async render({color, width, height}, canvas, ctx) {
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
return canvas;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user