fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
2 lines • 2.51 kB
JavaScript
import{_defineProperty as e}from"../../_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.min.mjs";import{FILL as t,SCALE as n,STROKE as r}from"../constants.min.mjs";import{Point as i}from"../Point.min.mjs";import{degreesToRadians as a}from"../util/misc/radiansDegreesConversion.min.mjs";import{createRotateMatrix as o,createScaleMatrix as s,createTranslateMatrix as c,multiplyTransformMatrixArray as l}from"../util/misc/matrix.min.mjs";import{Intersection as u}from"../Intersection.min.mjs";import{renderCircleControl as d,renderSquareControl as f}from"./controlRendering.min.mjs";var p=class{constructor(t){e(this,`visible`,!0),e(this,`actionName`,n),e(this,`angle`,0),e(this,`x`,0),e(this,`y`,0),e(this,`offsetX`,0),e(this,`offsetY`,0),e(this,`sizeX`,0),e(this,`sizeY`,0),e(this,`touchSizeX`,0),e(this,`touchSizeY`,0),e(this,`cursorStyle`,`crosshair`),e(this,`withConnection`,!1),Object.assign(this,t)}getTransformAnchorPoint(){var e;return(e=this.transformAnchorPoint)==null?new i(.5-this.x,.5-this.y):e}shouldActivate(e,t,n,{tl:r,tr:i,br:a,bl:o}){var s;return((s=t.canvas)==null?void 0:s.getActiveObject())===t&&t.isControlVisible(e)&&u.isPointInPolygon(n,[r,i,a,o])}getActionHandler(e,t,n){return this.actionHandler}getMouseDownHandler(e,t,n){return this.mouseDownHandler}getMouseUpHandler(e,t,n){return this.mouseUpHandler}cursorStyleHandler(e,t,n,r){return t.cursorStyle}getActionName(e,t,n){return t.actionName}getVisibility(e,t){var n,r;return(n=(r=e._controlsVisibility)==null?void 0:r[t])==null?this.visible:n}setVisibility(e,t,n){this.visible=e}positionHandler(e,t,n,r){return new i(this.x*e.x+this.offsetX,this.y*e.y+this.offsetY).transform(t)}calcCornerCoords(e,t,n,r,a,u){let d=l([c(n,r),o({angle:e}),s((a?this.touchSizeX:this.sizeX)||t,(a?this.touchSizeY:this.sizeY)||t)]);return{tl:new i(-.5,-.5).transform(d),tr:new i(.5,-.5).transform(d),br:new i(.5,.5).transform(d),bl:new i(-.5,.5).transform(d)}}commonRenderProps(e,n,i,o,s={}){let{cornerSize:c,cornerColor:l,transparentCorners:u,cornerStrokeColor:d}=s,f=c||o.cornerSize,p=this.sizeX||f,m=this.sizeY||f,h=u===void 0?o.transparentCorners:u,g=h?r:t,_=d||o.cornerStrokeColor,v=!h&&!!_;return e.fillStyle=l||o.cornerColor||``,e.strokeStyle=_||``,e.translate(n,i),e.rotate(a(o.getTotalAngle())),{stroke:v,xSize:p,ySize:m,transparentCorners:h,opName:g}}render(e,t,n,r,i){((r=r||{}).cornerStyle||i.cornerStyle)===`circle`?d.call(this,e,t,n,r,i):f.call(this,e,t,n,r,i)}};export{p as Control};
//# sourceMappingURL=Control.min.mjs.map