import { constructors } from '../core/library.js';
import { mergeOver } from '../core/utilities.js';
import baseMix from '../mixin/base.js';
import entityMix from '../mixin/entity.js';Block entitys are rectangles rendered onto a DOM <canvas> element using the Canvas API’s Path2D interface - specifically the rect method.
import { constructors } from '../core/library.js';
import { mergeOver } from '../core/utilities.js';
import baseMix from '../mixin/base.js';
import entityMix from '../mixin/entity.js';const Block = function (items = {}) {
this.entityInit(items);
if (!items.dimensions) {
if (!items.width) this.currentDimensions[0] = this.dimensions[0] = 10;
if (!items.height) this.currentDimensions[1] = this.dimensions[1] = 10;
}
return this;
};let P = Block.prototype = Object.create(Object.prototype);
P.type = 'Block';
P.lib = 'entity';
P.isArtefact = true;
P.isAsset = false;P = baseMix(P);
P = entityMix(P);No additional attributes required beyond those supplied by the mixins
cleanPathObject - Calculate the Block entity’s Path2D object
P.cleanPathObject = function () {
this.dirtyPathObject = false;
if (!this.noPathUpdates || !this.pathObject) {
let p = this.pathObject = new Path2D();
let handle = this.currentStampHandlePosition,
scale = this.currentScale,
dims = this.currentDimensions;
let x = -handle[0] * scale,
y = -handle[1] * scale,
w = dims[0] * scale,
h = dims[1] * scale;
p.rect(x, y, w, h);
}
};scrawl.makeBlock({
name: 'myblock-fill',
width: 100,
height: 100,
startX: 25,
startY: 25,
fillStyle: 'green',
strokeStyle: 'gold',
lineWidth: 6,
lineJoin: 'round',
shadowOffsetX: 4,
shadowOffsetY: 4,
shadowBlur: 2,
shadowColor: 'black',
}).clone({
name: 'myblock-draw',
startX: 175,
method: 'draw',
sharedState: true,
});
const makeBlock = function (items) {
return new Block(items);
};
constructors.Block = Block;export {
makeBlock,
};