fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
1 lines • 1.35 kB
Source Map (JSON)
{"version":3,"file":"basic.mjs","sources":["../../../extensions/aligning_guidelines/util/basic.ts"],"sourcesContent":["import type { FabricObject, Point } from 'fabric';\n\nexport function getDistance(a: number, b: number) {\n return Math.abs(a - b);\n}\n\nexport function setPositionDir(\n target: FabricObject,\n pos: Point,\n dir: 'x' | 'y',\n) {\n const center = target.translateToCenterPoint(pos, 'center', 'center');\n const position = target.translateToOriginPoint(\n center,\n target.originX,\n target.originY,\n );\n if (dir == 'x') target.setX(position.x);\n else target.setY(position.y);\n}\n"],"names":["getDistance","a","b","Math","abs","setPositionDir","target","pos","dir","center","translateToCenterPoint","position","translateToOriginPoint","originX","originY","setX","x","setY","y"],"mappings":"AAEO,SAASA,WAAWA,CAACC,CAAS,EAAEC,CAAS,EAAE;AAChD,EAAA,OAAOC,IAAI,CAACC,GAAG,CAACH,CAAC,GAAGC,CAAC,CAAC,CAAA;AACxB,CAAA;AAEO,SAASG,cAAcA,CAC5BC,MAAoB,EACpBC,GAAU,EACVC,GAAc,EACd;EACA,MAAMC,MAAM,GAAGH,MAAM,CAACI,sBAAsB,CAACH,GAAG,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACrE,EAAA,MAAMI,QAAQ,GAAGL,MAAM,CAACM,sBAAsB,CAC5CH,MAAM,EACNH,MAAM,CAACO,OAAO,EACdP,MAAM,CAACQ,OACT,CAAC,CAAA;EACD,IAAIN,GAAG,IAAI,GAAG,EAAEF,MAAM,CAACS,IAAI,CAACJ,QAAQ,CAACK,CAAC,CAAC,CAAC,KACnCV,MAAM,CAACW,IAAI,CAACN,QAAQ,CAACO,CAAC,CAAC,CAAA;AAC9B;;;;"}