import { constructors } from '../core/library.js';
import { doCreate, Ωempty } from '../helper/utilities.js';
import baseMix from '../mixin/base.js';
import shapeMix from '../mixin/shape-basic.js';import { constructors } from '../core/library.js';
import { doCreate, Ωempty } from '../helper/utilities.js';
import baseMix from '../mixin/base.js';
import shapeMix from '../mixin/shape-basic.js';Shared constants
import { ENTITY } from '../helper/shared-vars.js';Local constants
const T_SHAPE = 'Shape';const Shape = function (items = Ωempty) {
this.shapeInit(items);
return this;
};const P = Shape.prototype = doCreate();
P.type = T_SHAPE;
P.lib = ENTITY;
P.isArtefact = true;
P.isAsset = false;baseMix(P);
shapeMix(P);cleanSpecies - internal helper function - called by prepareStamp
P.cleanSpecies = function () {
this.dirtySpecies = false;
};
P.cleanStampHandlePositionsAdditionalActions = function () {
const box = this.localBox;
if (!box || box.length < 2) return;
const stampHandle = this.currentStampHandlePosition;
stampHandle[0] += box[0];
stampHandle[1] += box[1];
};Accepts argument with attributes:
pathDefinition (required) - an SVG d attribute Stringscrawl.makeShape({
name: 'myArrow',
pathDefinition: 'M266.2,703.1 h-178 L375.1,990 l287-286.9 H481.9 C507.4,365,683.4,91.9,911.8,25.5 877,15.4,840.9,10,803.9,10 525.1,10,295.5,313.4,266.2,703.1 z',
startX: 300,
startY: 200,
handleX: '50%',
handleY: '50%',
scale: 0.2,
scaleOutline: false,
fillStyle: 'lightgreen',
method: 'fill',
});
export const makeShape = function (items) {
if (!items) return false;
return new Shape(items);
};
constructors.Shape = Shape;