@leafer/core
Version:
1 lines • 488 kB
Source Map (JSON)
{"version":3,"file":"core.min.cjs","sources":["../../../../../../src/leafer/packages/display-module/data/src/data.ts","../../../../../../src/leafer/packages/display-module/data/src/DataHelper.ts","../../../../../../src/leafer/packages/display-module/data/src/LeafData.ts","../../../../../../src/leafer/packages/platform/platform/src/Platform.ts","../../../../../../src/leafer/packages/math/src/IncrementId.ts","../../../../../../src/leafer/packages/math/src/FourNumberHelper.ts","../../../../../../src/leafer/packages/math/src/MathHelper.ts","../../../../../../src/leafer/packages/math/src/MatrixHelper.ts","../../../../../../src/leafer/packages/math/src/PointHelper.ts","../../../../../../src/leafer/packages/math/src/Point.ts","../../../../../../src/leafer/packages/math/src/Matrix.ts","../../../../../../src/leafer/packages/math/src/TwoPointBoundsHelper.ts","../../../../../../src/leafer/packages/math/src/Direction.ts","../../../../../../src/leafer/packages/math/src/AroundHelper.ts","../../../../../../src/leafer/packages/math/src/AlignHelper.ts","../../../../../../src/leafer/packages/math/src/BoundsHelper.ts","../../../../../../src/leafer/packages/math/src/Bounds.ts","../../../../../../src/leafer/packages/math/src/StringNumber.ts","../../../../../../src/leafer/packages/debug/src/Debug.ts","../../../../../../src/leafer/packages/debug/src/Run.ts","../../../../../../src/leafer/packages/debug/src/Plugin.ts","../../../../../../src/leafer/packages/platform/platform/src/creator/Creator.ts","../../../../../../src/leafer/packages/platform/platform/src/creator/UICreator.ts","../../../../../../src/leafer/packages/platform/platform/src/creator/EventCreator.ts","../../../../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.6_rollup@4.44.2_tslib@2.8.1_typescript@5.8.3/node_modules/tslib/tslib.es6.js","../../../../../../src/leafer/packages/canvas/canvas/src/Canvas.ts","../../../../../../src/leafer/packages/canvas/canvas/src/LeaferCanvasBase.ts","../../../../../../src/leafer/packages/path/src/PathHelper.ts","../../../../../../src/leafer/packages/path/src/PathCommandMap.ts","../../../../../../src/leafer/packages/path/src/RectHelper.ts","../../../../../../src/leafer/packages/path/src/BezierHelper.ts","../../../../../../src/leafer/packages/path/src/EllipseHelper.ts","../../../../../../src/leafer/packages/path/src/PathCommandNodeHelper.ts","../../../../../../src/leafer/packages/path/src/PathConvert.ts","../../../../../../src/leafer/packages/path/src/PathCommandDataHelper.ts","../../../../../../src/leafer/packages/path/src/PathCreator.ts","../../../../../../src/leafer/packages/path/src/PathDrawer.ts","../../../../../../src/leafer/packages/path/src/PathBounds.ts","../../../../../../src/leafer/packages/path/src/PathCorner.ts","../../../../../../src/leafer/packages/path/src/index.ts","../../../../../../src/leafer/packages/canvas/canvas/src/patch/roundRect.ts","../../../../../../src/leafer/packages/file/src/FileHelper.ts","../../../../../../src/leafer/packages/task/src/TaskItem.ts","../../../../../../src/leafer/packages/task/src/TaskProcessor.ts","../../../../../../src/leafer/packages/file/src/Resource.ts","../../../../../../src/leafer/packages/image/image/src/ImageManager.ts","../../../../../../src/leafer/packages/image/image/src/LeaferImage.ts","../../../../../../src/leafer/packages/decorator/src/object.ts","../../../../../../src/leafer/packages/decorator/src/data.ts","../../../../../../src/leafer/packages/decorator/src/rewrite.ts","../../../../../../src/leafer/packages/display-module/helper/src/LeafHelper.ts","../../../../../../src/leafer/packages/display-module/helper/src/LeafBoundsHelper.ts","../../../../../../src/leafer/packages/display-module/helper/src/BranchHelper.ts","../../../../../../src/leafer/packages/display-module/helper/src/WaitHelper.ts","../../../../../../src/leafer/packages/display-module/layout/src/LeafLayout.ts","../../../../../../src/leafer/packages/event/src/Event.ts","../../../../../../src/leafer/packages/event/src/ChildEvent.ts","../../../../../../src/leafer/packages/event/src/PropertyEvent.ts","../../../../../../src/leafer/packages/event/src/ImageEvent.ts","../../../../../../src/leafer/packages/event/src/BoundsEvent.ts","../../../../../../src/leafer/packages/event/src/ResizeEvent.ts","../../../../../../src/leafer/packages/event/src/WatchEvent.ts","../../../../../../src/leafer/packages/event/src/LayoutEvent.ts","../../../../../../src/leafer/packages/event/src/RenderEvent.ts","../../../../../../src/leafer/packages/event/src/LeaferEvent.ts","../../../../../../src/leafer/packages/event/src/Eventer.ts","../../../../../../src/leafer/packages/display-module/display-module/src/LeafEventer.ts","../../../../../../src/leafer/packages/display-module/display-module/src/LeafDataProxy.ts","../../../../../../src/leafer/packages/display-module/display-module/src/LeafMatrix.ts","../../../../../../src/leafer/packages/display-module/display-module/src/LeafBounds.ts","../../../../../../src/leafer/packages/display-module/display-module/src/LeafRender.ts","../../../../../../src/leafer/packages/display-module/display-module/src/BranchRender.ts","../../../../../../src/leafer/packages/display/src/Leaf.ts","../../../../../../src/leafer/packages/display/src/Branch.ts","../../../../../../src/leafer/packages/list/src/LeafList.ts","../../../../../../src/leafer/packages/math/src/AutoBounds.ts","../../../../../../src/leafer/packages/canvas/canvas/src/CanvasManager.ts","../../../../../../src/leafer/packages/list/src/LeafLevelList.ts","../../../../../../src/leafer/packages/canvas/canvas/src/patch/index.ts","../../../../../../src/leafer/packages/decorator/src/class.ts","../../../../../../src/leafer/packages/core/src/index.ts"],"sourcesContent":["import { IObject } from '@leafer/interface'\n\nexport enum Answer {\n No = 0,\n Yes = 1,\n NoAndSkip = 2,\n YesAndSkip = 3\n}\n\nexport const emptyData: IObject = {}\n\nexport function isUndefined(value: any): boolean {\n return value === undefined\n}\n\nexport function isNull(value: any): boolean {\n return value == null // = value === undefined || value === null\n}\n\nexport function isString<T extends string>(value: any): value is T {\n return typeof value === 'string'\n}\n\nexport const { isFinite } = Number\n\nexport function isNumber<T extends number>(value: any): value is T {\n return typeof value === 'number'\n}\n\nconst numberReg = /^-?\\d+(?:\\.\\d+)?$/\n\nexport function tryToNumber(value: any): number {\n return (typeof value === 'string' && numberReg.test(value)) ? +value : value\n}\n\nexport const { isArray } = Array\n\nexport function isObject<T extends object>(value: any): value is T {\n return value && typeof value === 'object' // fix: null is object\n}\n\nexport function isData<T extends object>(value: any): value is T { // 检测 {} 对象\n return isObject(value) && !isArray(value) // 排除数组\n}\n\nexport function isEmptyData(value: any): boolean {\n return JSON.stringify(value) === '{}'\n}","import { IBooleanMap, IObject } from '@leafer/interface'\nimport { isUndefined } from './data'\n\nexport const DataHelper = {\n\n default<T>(t: T, defaultData: IObject): T {\n assign(defaultData, t)\n assign(t, defaultData)\n return t\n },\n\n assign(t: IObject, merge: IObject, exclude?: IObject): void {\n let value: unknown\n Object.keys(merge).forEach(key => {\n value = merge[key]\n if (value?.constructor === Object && t[key]?.constructor === Object) return assign(t[key], merge[key], exclude && exclude[key])\n if (exclude && (key in exclude)) {\n if (exclude[key]?.constructor === Object) assign(t[key] = {}, merge[key], exclude[key])\n return\n }\n t[key] = merge[key]\n })\n },\n\n copyAttrs(t: IObject, from: IObject, include: string[]): IObject {\n include.forEach(key => {\n if (!isUndefined(from[key])) t[key] = from[key]\n })\n return t\n },\n\n clone(data: unknown): IObject {\n return JSON.parse(JSON.stringify(data))\n },\n\n toMap(list: string[]): IBooleanMap {\n const map = {} as IBooleanMap\n for (let i = 0, len = list.length; i < len; i++) map[list[i]] = true\n return map\n },\n\n stintSet<T extends object, K extends keyof T>(data: T, attrName: K, value: T[K]): void {\n value || (value = undefined)\n data[attrName] !== value && (data[attrName] = value) // 只有值不一样时才设置,节省内存开销\n }\n\n}\n\nconst { assign } = DataHelper","import { ILeafData, ILeaf, IObject, IValue, IPathCommandData, IJSONOptions } from '@leafer/interface'\nimport { isArray, isUndefined } from './data'\n\n\nexport class LeafData implements ILeafData {\n\n public __leaf: ILeaf\n public __input: IObject\n public __middle: IObject\n\n public __single: boolean\n\n public __naturalWidth?: number\n public __naturalHeight?: number\n\n public __pathForRender?: IPathCommandData\n\n public __useStroke?: boolean\n public get __useNaturalRatio() { return true }\n\n public get __isLinePath(): boolean {\n const { path } = this as ILeafData\n return path && path.length === 6 && path[0] === 1 // M = 1\n }\n\n public get __usePathBox(): boolean {\n return (this as ILeafData).__pathInputed as any as boolean\n }\n\n public get __blendMode(): string {\n if ((this as ILeafData).eraser && (this as ILeafData).eraser !== 'path') return 'destination-out'\n const { blendMode } = (this as ILeafData)\n return blendMode === 'pass-through' ? null : blendMode\n }\n\n constructor(leaf: ILeaf) {\n this.__leaf = leaf\n }\n\n public __get(name: string): any {\n if (this.__input) {\n const value = this.__input[name]\n if (!isUndefined(value)) return value\n }\n return (this as IObject)[name]\n }\n\n public __getData(): IObject {\n const data: IObject = { tag: this.__leaf.tag }, { __input } = this\n let inputValue: IValue\n for (let key in this) {\n if (key[0] !== '_') {\n inputValue = __input ? __input[key] : undefined\n data[key] = isUndefined(inputValue) ? this[key] : inputValue\n }\n }\n return data\n }\n\n public __setInput(name: string, value: any): void {\n this.__input || (this.__input = {})\n this.__input[name] = value\n }\n\n public __getInput(name: string): any {\n if (this.__input) {\n const value = this.__input[name]\n if (!isUndefined(value)) return value\n }\n\n if (name === 'path' && !(this as ILeafData).__pathInputed) return // no path mode\n\n return (this as IObject)['_' + name]\n }\n\n public __removeInput(name: string): void {\n if (this.__input && !isUndefined(this.__input[name])) this.__input[name] = undefined\n }\n\n public __getInputData(names?: string[] | IObject, options?: IJSONOptions): IObject {\n const data: IObject = {}\n\n if (names) {\n\n if (isArray(names)) {\n for (let name of names) data[name] = this.__getInput(name)\n } else {\n for (let name in names) data[name] = this.__getInput(name)\n }\n\n } else {\n\n let value: IValue, inputValue: IValue, { __input } = this\n data.tag = this.__leaf.tag\n for (let key in this) {\n if (key[0] !== '_') {\n value = (this as IObject)['_' + key]\n if (!isUndefined(value)) {\n\n if (key === 'path' && !(this as ILeafData).__pathInputed) continue // no path mode\n\n inputValue = __input ? __input[key] : undefined\n data[key] = isUndefined(inputValue) ? value : inputValue\n }\n }\n }\n\n }\n\n if (options) {\n if (options.matrix) {\n const { a, b, c, d, e, f } = this.__leaf.__localMatrix\n data.matrix = { a, b, c, d, e, f }\n }\n }\n\n return data\n }\n\n public __setMiddle(name: string, value: any): void {\n this.__middle || (this.__middle = {})\n this.__middle[name] = value\n }\n\n public __getMiddle(name: string): any {\n return this.__middle && this.__middle[name]\n }\n\n public __checkSingle(): void {\n const t = this as ILeafData\n if (t.blendMode === 'pass-through') {\n const leaf = this.__leaf\n if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser || t.filter) {\n t.__single = true\n } else if (t.__single) {\n t.__single = false\n }\n } else {\n t.__single = true\n }\n }\n\n public __removeNaturalSize(): void {\n this.__naturalWidth = this.__naturalHeight = undefined\n }\n\n public destroy(): void {\n this.__input = this.__middle = null\n }\n}","import { IPlatform, IObject, IBoundsData, ICanvasPattern, IMatrixData, ILeaferImagePatternPaint, ISizeData, ICanvasContext2D } from '@leafer/interface'\nimport { DataHelper } from '@leafer/data'\n\n\nconst { floor, max } = Math\n\nexport const Platform: IPlatform = {\n toURL(text: string, fileType?: 'text' | 'svg'): string {\n let url = encodeURIComponent(text)\n if (fileType === 'text') url = 'data:text/plain;charset=utf-8,' + url\n else if (fileType === 'svg') url = 'data:image/svg+xml,' + url\n return url\n },\n image: {\n hitCanvasSize: 100,\n maxCacheSize: 2560 * 1600, // 2k\n maxPatternSize: 4096 * 2160, // 4k\n crossOrigin: 'anonymous',\n isLarge(size: ISizeData, scaleX?: number, scaleY?: number, largeSize?: number): boolean {\n return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize)\n },\n isSuperLarge(size: ISizeData, scaleX?: number, scaleY?: number): boolean {\n return image.isLarge(size, scaleX, scaleY, image.maxPatternSize)\n },\n getRealURL(url: string): string {\n const { prefix, suffix } = Platform.image\n if (suffix && !url.startsWith('data:') && !url.startsWith('blob:')) url += (url.includes(\"?\") ? \"&\" : \"?\") + suffix\n if (prefix && url[0] === '/') url = prefix + url\n return url\n },\n resize(image: any, width: number, height: number, xGap?: number, yGap?: number, clip?: IBoundsData, smooth?: boolean, opacity?: number, _filters?: IObject): any {\n const canvas = Platform.origin.createCanvas(max(floor(width + (xGap || 0)), 1), max(floor(height + (yGap || 0)), 1),)\n const ctx: ICanvasContext2D = canvas.getContext('2d')\n if (opacity) ctx.globalAlpha = opacity\n ctx.imageSmoothingEnabled = smooth === false ? false : true // 平滑绘制\n if (clip) {\n const scaleX = width / clip.width, scaleY = height / clip.height\n ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY)\n ctx.drawImage(image, 0, 0, image.width, image.height)\n } else ctx.drawImage(image, 0, 0, width, height)\n return canvas\n },\n setPatternTransform(pattern: ICanvasPattern, transform?: IMatrixData, paint?: ILeaferImagePatternPaint): void {\n try {\n if (transform && pattern.setTransform) {\n pattern.setTransform(transform) // maybe error \n transform = undefined\n }\n } catch { }\n if (paint) DataHelper.stintSet(paint, 'transform', transform)\n }\n }\n}\n\nconst { image } = Platform","import { INumberMap } from '@leafer/interface'\n\n\nexport const IncrementId = {\n\n RUNTIME: 'runtime',\n LEAF: 'leaf',\n TASK: 'task',\n CNAVAS: 'canvas',\n IMAGE: 'image',\n\n types: {} as INumberMap,\n\n create(typeName: string): number {\n const { types } = I\n if (types[typeName]) {\n return types[typeName]++\n } else {\n types[typeName] = 1\n return 0\n }\n }\n}\n\nconst I = IncrementId","import { IFourNumber } from '@leafer/interface'\nimport { isNumber, isUndefined } from '@leafer/data'\n\n\nlet tempA: number[], tempB: number[], tempTo: number[]\nconst { max } = Math, tempFour = [0, 0, 0, 0]\n\nexport const FourNumberHelper = {\n\n zero: [...tempFour],\n\n tempFour,\n\n set(to: number[], top: number, right?: number, bottom?: number, left?: number): number[] {\n if (right === undefined) right = bottom = left = top\n to[0] = top\n to[1] = right\n to[2] = bottom\n to[3] = left\n return to\n },\n\n setTemp(top: number, right?: number, bottom?: number, left?: number) {\n return set(tempFour, top, right, bottom, left)\n },\n\n toTempAB(a: IFourNumber, b: IFourNumber, change?: boolean): void {\n tempTo = change ? (isNumber(a) ? b : a) as number[] : []\n if (isNumber(a)) tempA = setTemp(a), tempB = b as number[]\n else if (isNumber(b)) tempA = a, tempB = setTemp(b)\n else tempA = a, tempB = b\n\n if (tempA.length !== 4) tempA = get(tempA)\n if (tempB.length !== 4) tempB = get(tempB)\n },\n\n get(num: IFourNumber, maxValue?: number): number[] { // top right bottom left || topLeft, topRight, bottomRight, bottomLeft\n let data: number[]\n if (!isNumber(num)) {\n switch (num.length) {\n case 4:\n data = isUndefined(maxValue) ? num : [...num]\n break\n case 2:\n data = [num[0], num[1], num[0], num[1]]\n break\n case 3:\n data = [num[0], num[1], num[2], num[1]]\n break\n case 1:\n num = num[0]\n break\n default:\n num = 0\n }\n }\n if (!data) data = [num as number, num as number, num as number, num as number]\n if (!isUndefined(maxValue)) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue\n return data\n },\n\n max(t: IFourNumber, other: IFourNumber, change?: boolean): IFourNumber {\n if (isNumber(t) && isNumber(other)) return max(t, other)\n\n toTempAB(t, other, change)\n\n return set(\n tempTo,\n max(tempA[0], tempB[0]),\n max(tempA[1], tempB[1]),\n max(tempA[2], tempB[2]),\n max(tempA[3], tempB[3])\n )\n },\n\n add(t: IFourNumber, other: IFourNumber, change?: boolean): IFourNumber {\n if (isNumber(t) && isNumber(other)) return t + other\n\n toTempAB(t, other, change)\n\n return set(\n tempTo,\n tempA[0] + tempB[0],\n tempA[1] + tempB[1],\n tempA[2] + tempB[2],\n tempA[3] + tempB[3]\n )\n },\n\n swapAndScale(t: IFourNumber, scaleX: number, scaleY: number, change?: boolean): IFourNumber { // 反向交换并缩放\n if (isNumber(t)) return scaleX === scaleY ? t * scaleX : [t * scaleY, t * scaleX]\n\n const to = change ? t : []\n const [top, right, bottom, left] = t.length === 4 ? t : get(t)\n\n return set(\n to,\n bottom * scaleY,\n left * scaleX,\n top * scaleY,\n right * scaleX\n )\n }\n\n}\n\nconst { set, get, setTemp, toTempAB } = FourNumberHelper","import { IPointData, IBoundsData, IMatrixData, IRangeSize, IScaleData, ISizeData, IOptionSizeData } from '@leafer/interface'\nimport { isObject, isNumber, isUndefined } from '@leafer/data'\nimport { FourNumberHelper } from './FourNumberHelper'\n\n\nconst { round, pow, max, floor, PI } = Math\n\nexport const MathHelper = {\n\n within(value: number, min: number | IRangeSize, max?: number): number {\n if (isObject(min)) max = min.max, min = min.min\n if (!isUndefined(min) && value < min) value = min\n if (!isUndefined(max) && value > max) value = max\n return value\n },\n\n fourNumber: FourNumberHelper.get,\n\n formatRotation(rotation: number, unsign?: boolean): number {\n rotation %= 360\n if (unsign) {\n if (rotation < 0) rotation += 360\n } else {\n if (rotation > 180) rotation -= 360\n if (rotation < -180) rotation += 360\n }\n return MathHelper.float(rotation)\n },\n\n getGapRotation(addRotation: number, gap: number, oldRotation: number = 0): number {\n let rotation = addRotation + oldRotation\n if (gap > 1) {\n const r = Math.abs(rotation % gap)\n if (r < 1 || r > gap - 1) rotation = Math.round(rotation / gap) * gap\n }\n return rotation - oldRotation\n },\n\n float(num: number, maxLength?: number): number {\n const a = !isUndefined(maxLength) ? pow(10, maxLength) : 1000000000000 // default\n num = round(num * a) / a\n return num === -0 ? 0 : num\n },\n\n sign(num: number): number {\n return num < 0 ? -1 : 1\n },\n\n getScaleData(scale: number | IPointData, size: number | IOptionSizeData, originSize: ISizeData, scaleData?: IScaleData): IScaleData {\n if (!scaleData) scaleData = {} as IScaleData\n if (size) {\n const scaleX = (isNumber(size) ? size : size.width || 0) / originSize.width, scaleY = (isNumber(size) ? size : size.height || 0) / originSize.height\n scaleData.scaleX = scaleX || scaleY || 1\n scaleData.scaleY = scaleY || scaleX || 1\n } else if (scale) MathHelper.assignScale(scaleData, scale)\n return scaleData\n },\n\n assignScale(scaleData: IScaleData, scale: number | IPointData): void {\n if (isNumber(scale)) {\n scaleData.scaleX = scaleData.scaleY = scale\n } else {\n scaleData.scaleX = scale.x\n scaleData.scaleY = scale.y\n }\n },\n\n getFloorScale(num: number, min = 1): number {\n return max(floor(num), min) / num\n },\n\n randInt,\n\n randColor(opacity?: number): string {\n return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`\n }\n}\n\nfunction randInt(num: number): number {\n return Math.round(Math.random() * num)\n}\n\nexport const OneRadian = PI / 180\nexport const PI2 = PI * 2\nexport const PI_2 = PI / 2\n\nexport function getPointData(): IPointData { return { x: 0, y: 0 } }\nexport function getBoundsData(): IBoundsData { return { x: 0, y: 0, width: 0, height: 0 } }\nexport function getMatrixData(): IMatrixData { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 } }","import { IMatrixData, IPointData, ILayoutData, IMatrixWithLayoutData, IMatrixWithOptionScaleData, IScaleData, IMatrixWithScaleData } from '@leafer/interface'\nimport { isUndefined } from '@leafer/data'\n\nimport { MathHelper, OneRadian, PI_2, getBoundsData, getMatrixData } from './MathHelper'\n\n\nconst { sin, cos, acos, sqrt } = Math\nconst { float } = MathHelper\nconst tempPoint = {} as IPointData\n\nfunction getWorld(): IMatrixWithLayoutData {\n return { ...getMatrixData(), ...getBoundsData(), scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 }\n}\n\nexport const MatrixHelper = {\n\n defaultMatrix: getMatrixData(),\n\n defaultWorld: getWorld(),\n\n tempMatrix: {} as IMatrixData,\n\n set(t: IMatrixData, a = 1, b = 0, c = 0, d = 1, e = 0, f = 0): void {\n t.a = a\n t.b = b\n t.c = c\n t.d = d\n t.e = e\n t.f = f\n },\n\n get: getMatrixData,\n\n getWorld,\n\n copy(t: IMatrixData, matrix: IMatrixData): void {\n t.a = matrix.a\n t.b = matrix.b\n t.c = matrix.c\n t.d = matrix.d\n t.e = matrix.e\n t.f = matrix.f\n },\n\n translate(t: IMatrixData, x: number, y: number): void {\n t.e += x\n t.f += y\n },\n\n translateInner(t: IMatrixData, x: number, y: number, hasOrigin?: boolean): void {\n t.e += t.a * x + t.c * y\n t.f += t.b * x + t.d * y\n if (hasOrigin) t.e -= x, t.f -= y\n },\n\n scale(t: IMatrixData, scaleX: number, scaleY: number = scaleX): void {\n t.a *= scaleX\n t.b *= scaleX\n t.c *= scaleY\n t.d *= scaleY\n },\n\n pixelScale(t: IMatrixData, pixelRatio: number, to?: IMatrixData): void {\n to || (to = t)\n to.a = t.a * pixelRatio\n to.b = t.b * pixelRatio\n to.c = t.c * pixelRatio\n to.d = t.d * pixelRatio\n to.e = t.e * pixelRatio\n to.f = t.f * pixelRatio\n },\n\n scaleOfOuter(t: IMatrixData, origin: IPointData, scaleX: number, scaleY?: number): void {\n M.toInnerPoint(t, origin, tempPoint)\n M.scaleOfInner(t, tempPoint, scaleX, scaleY)\n },\n\n scaleOfInner(t: IMatrixData, origin: IPointData, scaleX: number, scaleY: number = scaleX): void {\n M.translateInner(t, origin.x, origin.y)\n M.scale(t, scaleX, scaleY)\n M.translateInner(t, -origin.x, -origin.y)\n },\n\n\n rotate(t: IMatrixData, rotation: number): void {\n const { a, b, c, d } = t\n\n rotation *= OneRadian\n const cosR = cos(rotation)\n const sinR = sin(rotation)\n\n t.a = a * cosR - b * sinR\n t.b = a * sinR + b * cosR\n t.c = c * cosR - d * sinR\n t.d = c * sinR + d * cosR\n },\n\n rotateOfOuter(t: IMatrixData, origin: IPointData, rotation: number): void {\n M.toInnerPoint(t, origin, tempPoint)\n M.rotateOfInner(t, tempPoint, rotation)\n },\n\n rotateOfInner(t: IMatrixData, origin: IPointData, rotation: number): void {\n M.translateInner(t, origin.x, origin.y)\n M.rotate(t, rotation)\n M.translateInner(t, -origin.x, -origin.y)\n },\n\n\n skew(t: IMatrixData, skewX: number, skewY?: number): void {\n const { a, b, c, d } = t\n\n if (skewY) {\n skewY *= OneRadian\n t.a = a + c * skewY\n t.b = b + d * skewY\n }\n\n if (skewX) {\n skewX *= OneRadian\n t.c = c + a * skewX\n t.d = d + b * skewX\n }\n },\n\n skewOfOuter(t: IMatrixData, origin: IPointData, skewX: number, skewY?: number): void {\n M.toInnerPoint(t, origin, tempPoint)\n M.skewOfInner(t, tempPoint, skewX, skewY)\n },\n\n skewOfInner(t: IMatrixData, origin: IPointData, skewX: number, skewY: number = 0): void {\n M.translateInner(t, origin.x, origin.y)\n M.skew(t, skewX, skewY)\n M.translateInner(t, -origin.x, -origin.y)\n },\n\n\n multiply(t: IMatrixData, child: IMatrixData): void {\n const { a, b, c, d, e, f } = t\n\n t.a = child.a * a + child.b * c\n t.b = child.a * b + child.b * d\n t.c = child.c * a + child.d * c\n t.d = child.c * b + child.d * d\n t.e = child.e * a + child.f * c + e\n t.f = child.e * b + child.f * d + f\n },\n\n multiplyParent(t: IMatrixWithOptionScaleData, parent: IMatrixWithOptionScaleData, to?: IMatrixWithOptionScaleData, abcdChanged?: boolean | number, childScaleData?: IScaleData): void { // = transform\n const { e, f } = t\n\n to || (to = t)\n\n if (isUndefined(abcdChanged)) abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1\n\n if (abcdChanged) {\n const { a, b, c, d } = t\n\n to.a = a * parent.a + b * parent.c\n to.b = a * parent.b + b * parent.d\n to.c = c * parent.a + d * parent.c\n to.d = c * parent.b + d * parent.d\n\n if (childScaleData) {\n to.scaleX = parent.scaleX * childScaleData.scaleX\n to.scaleY = parent.scaleY * childScaleData.scaleY\n }\n\n } else {\n to.a = parent.a\n to.b = parent.b\n to.c = parent.c\n to.d = parent.d\n\n if (childScaleData) {\n to.scaleX = parent.scaleX\n to.scaleY = parent.scaleY\n }\n }\n\n to.e = e * parent.a + f * parent.c + parent.e\n to.f = e * parent.b + f * parent.d + parent.f\n },\n\n\n divide(t: IMatrixData, child: IMatrixData): void {\n M.multiply(t, M.tempInvert(child))\n },\n\n divideParent(t: IMatrixData, parent: IMatrixData): void {\n M.multiplyParent(t, M.tempInvert(parent))\n },\n\n tempInvert(t: IMatrixData): IMatrixData {\n const { tempMatrix } = M\n M.copy(tempMatrix, t)\n M.invert(tempMatrix)\n return tempMatrix\n },\n\n invert(t: IMatrixData): void {\n const { a, b, c, d, e, f } = t\n if (!b && !c) {\n if (a === 1 && d === 1) {\n t.e = -e\n t.f = -f\n } else {\n const s = 1 / (a * d)\n t.a = d * s\n t.d = a * s\n t.e = -e * d * s\n t.f = -f * a * s\n }\n } else {\n const s = 1 / (a * d - b * c)\n t.a = d * s\n t.b = -b * s\n t.c = -c * s\n t.d = a * s\n t.e = -(e * d - f * c) * s\n t.f = -(f * a - e * b) * s\n }\n\n },\n\n\n toOuterPoint(t: IMatrixData, inner: IPointData, to?: IPointData, distance?: boolean): void {\n const { x, y } = inner\n\n // outer\n to || (to = inner)\n to.x = x * t.a + y * t.c\n to.y = x * t.b + y * t.d\n\n if (!distance) {\n to.x += t.e\n to.y += t.f\n }\n },\n\n toInnerPoint(t: IMatrixData, outer: IPointData, to?: IPointData, distance?: boolean): void {\n const { a, b, c, d } = t\n const s = 1 / (a * d - b * c)\n\n const { x, y } = outer\n\n // inner\n to || (to = outer)\n to.x = (x * d - y * c) * s\n to.y = (y * a - x * b) * s\n\n if (!distance) {\n const { e, f } = t\n to.x -= (e * d - f * c) * s\n to.y -= (f * a - e * b) * s\n }\n },\n\n setLayout(t: IMatrixData, layout: ILayoutData, origin?: IPointData, around?: IPointData, bcChanged?: boolean | number): void {\n const { x, y, scaleX, scaleY } = layout\n\n if (isUndefined(bcChanged)) bcChanged = layout.rotation || layout.skewX || layout.skewY\n\n if (bcChanged) {\n\n const { rotation, skewX, skewY } = layout\n const r = rotation * OneRadian\n const cosR = cos(r)\n const sinR = sin(r)\n\n if (skewX || skewY) {\n\n // rotate -> skew -> scale\n const sx = skewX * OneRadian\n const sy = skewY * OneRadian\n\n t.a = (cosR + sy * -sinR) * scaleX\n t.b = (sinR + sy * cosR) * scaleX\n t.c = (-sinR + sx * cosR) * scaleY\n t.d = (cosR + sx * sinR) * scaleY\n\n } else {\n\n // rotate -> scale\n t.a = cosR * scaleX\n t.b = sinR * scaleX\n t.c = -sinR * scaleY\n t.d = cosR * scaleY\n\n }\n\n } else {\n t.a = scaleX\n t.b = 0\n t.c = 0\n t.d = scaleY\n }\n\n // translate\n\n t.e = x\n t.f = y\n\n if (origin = origin || around) M.translateInner(t, -origin.x, -origin.y, !around)\n\n },\n\n getLayout(t: IMatrixData, origin?: IPointData, around?: IPointData, firstSkewY?: boolean): ILayoutData {\n const { a, b, c, d, e, f } = t\n\n let x = e, y = f, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number\n\n if (b || c) {\n\n const s = a * d - b * c\n\n if (c && !firstSkewY) {\n scaleX = sqrt(a * a + b * b)\n scaleY = s / scaleX\n\n const cosR = a / scaleX\n rotation = b > 0 ? acos(cosR) : -acos(cosR)\n\n } else {\n scaleY = sqrt(c * c + d * d)\n scaleX = s / scaleY\n\n const cosR = c / scaleY\n rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR))\n }\n\n const cosR = float(cos(rotation)) // when -90 / 90 is 0\n const sinR = sin(rotation)\n\n scaleX = float(scaleX), scaleY = float(scaleY)\n skewX = cosR ? float((c / scaleY + sinR) / cosR / OneRadian, 9) : 0\n skewY = cosR ? float((b / scaleX - sinR) / cosR / OneRadian, 9) : 0\n rotation = float(rotation / OneRadian)\n\n } else {\n scaleX = a\n scaleY = d\n rotation = skewX = skewY = 0\n }\n\n if (origin = around || origin) {\n x += origin.x * a + origin.y * c\n y += origin.x * b + origin.y * d\n if (!around) x -= origin.x, y -= origin.y\n }\n\n return { x, y, scaleX, scaleY, rotation, skewX, skewY }\n },\n\n withScale(t: IMatrixData, scaleX?: number, scaleY = scaleX): IMatrixWithScaleData {\n const world = t as unknown as IMatrixWithScaleData\n if (!scaleX || !scaleY) {\n const { a, b, c, d } = t\n if (b || c) {\n scaleX = sqrt(a * a + b * b)\n scaleY = (a * d - b * c) / scaleX\n } else {\n scaleX = a\n scaleY = d\n }\n }\n world.scaleX = scaleX\n world.scaleY = scaleY\n return world\n },\n\n reset(t: IMatrixData): void {\n M.set(t)\n }\n}\n\nconst M = MatrixHelper","import { IPointData, IMatrixData, IRadiusPointData, IMatrixWithScaleData } from '@leafer/interface'\nimport { isObject, isUndefined } from '@leafer/data'\n\nimport { MathHelper, OneRadian, getPointData } from './MathHelper'\nimport { MatrixHelper as M } from './MatrixHelper'\n\nconst { float } = MathHelper\nconst { toInnerPoint, toOuterPoint } = M\nconst { sin, cos, abs, sqrt, atan2, min, round } = Math\n\n\nexport const PointHelper = {\n\n defaultPoint: getPointData(),\n\n tempPoint: {} as IPointData,\n tempRadiusPoint: {} as IRadiusPointData,\n\n set(t: IPointData, x = 0, y = 0): void {\n t.x = x\n t.y = y\n },\n\n setRadius(t: IRadiusPointData, x: number, y?: number): void {\n t.radiusX = x\n t.radiusY = isUndefined(y) ? x : y\n },\n\n copy(t: IPointData, point: IPointData): void {\n t.x = point.x\n t.y = point.y\n },\n\n copyFrom(t: IPointData, x: number, y: number): void {\n t.x = x\n t.y = y\n },\n\n round(t: IPointData, halfPixel?: boolean): void {\n t.x = halfPixel ? round(t.x - 0.5) + 0.5 : round(t.x)\n t.y = halfPixel ? round(t.y - 0.5) + 0.5 : round(t.y)\n },\n\n move(t: IPointData, x: number | IPointData, y?: number): void {\n if (isObject(x)) t.x += x.x, t.y += x.y\n else t.x += x, t.y += y\n },\n\n\n scale(t: IPointData, scaleX: number, scaleY = scaleX): void {\n if (t.x) t.x *= scaleX\n if (t.y) t.y *= scaleY\n },\n\n scaleOf(t: IPointData, origin: IPointData, scaleX: number, scaleY = scaleX): void {\n t.x += (t.x - origin.x) * (scaleX - 1)\n t.y += (t.y - origin.y) * (scaleY - 1)\n },\n\n rotate(t: IPointData, rotation: number, origin?: IPointData): void {\n if (!origin) origin = P.defaultPoint\n rotation *= OneRadian\n const cosR = cos(rotation)\n const sinR = sin(rotation)\n const rx = t.x - origin.x\n const ry = t.y - origin.y\n t.x = origin.x + rx * cosR - ry * sinR\n t.y = origin.y + rx * sinR + ry * cosR\n },\n\n\n tempToInnerOf(t: IPointData, matrix: IMatrixData): IPointData {\n const { tempPoint: temp } = P\n copy(temp, t)\n toInnerPoint(matrix, temp, temp)\n return temp\n },\n\n tempToOuterOf(t: IPointData, matrix: IMatrixData): IPointData {\n const { tempPoint: temp } = P\n copy(temp, t)\n toOuterPoint(matrix, temp, temp)\n return temp\n },\n\n tempToInnerRadiusPointOf(t: IRadiusPointData, matrix: IMatrixWithScaleData): IRadiusPointData {\n const { tempRadiusPoint: temp } = P\n copy(temp, t)\n P.toInnerRadiusPointOf(t, matrix, temp)\n return temp\n },\n\n copyRadiusPoint(t: IRadiusPointData, point: IPointData, x: number, y?: number,): IRadiusPointData {\n copy(t, point)\n setRadius(t, x, y)\n return t\n },\n\n toInnerRadiusPointOf(t: IRadiusPointData, matrix: IMatrixWithScaleData, to?: IRadiusPointData): void {\n to || (to = t)\n toInnerPoint(matrix, t, to)\n to.radiusX = Math.abs(t.radiusX / matrix.scaleX)\n to.radiusY = Math.abs(t.radiusY / matrix.scaleY)\n },\n\n\n toInnerOf(t: IPointData, matrix: IMatrixData, to?: IPointData): void {\n toInnerPoint(matrix, t, to)\n },\n\n toOuterOf(t: IPointData, matrix: IMatrixData, to?: IPointData): void {\n toOuterPoint(matrix, t, to)\n },\n\n\n getCenter(t: IPointData, to: IPointData): IPointData {\n return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 }\n },\n\n getCenterX(x1: number, x2: number): number {\n return x1 + (x2 - x1) / 2\n },\n\n getCenterY(y1: number, y2: number): number {\n return y1 + (y2 - y1) / 2\n },\n\n getDistance(t: IPointData, point: IPointData): number {\n return getDistanceFrom(t.x, t.y, point.x, point.y)\n },\n\n getDistanceFrom(x1: number, y1: number, x2: number, y2: number): number {\n const x = abs(x2 - x1)\n const y = abs(y2 - y1)\n return sqrt(x * x + y * y)\n },\n\n getMinDistanceFrom(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): number {\n return min(getDistanceFrom(x1, y1, x2, y2), getDistanceFrom(x2, y2, x3, y3))\n },\n\n getAngle(t: IPointData, to: IPointData): number {\n return getAtan2(t, to) / OneRadian\n },\n\n getRotation(t: IPointData, origin: IPointData, to: IPointData, toOrigin?: IPointData): number {\n if (!toOrigin) toOrigin = origin\n return P.getRadianFrom(t.x, t.y, origin.x, origin.y, to.x, to.y, toOrigin.x, toOrigin.y) / OneRadian\n },\n\n getRadianFrom(fromX: number, fromY: number, originX: number, originY: number, toX: number, toY: number, toOriginX?: number, toOriginY?: number): number {\n if (isUndefined(toOriginX)) toOriginX = originX, toOriginY = originY\n const a = fromX - originX\n const b = fromY - originY\n const c = toX - toOriginX\n const d = toY - toOriginY\n return Math.atan2(a * d - b * c, a * c + b * d)\n },\n\n getAtan2(t: IPointData, to: IPointData): number {\n return atan2(to.y - t.y, to.x - t.x)\n },\n\n\n getDistancePoint(t: IPointData, to: IPointData, distance: number, changeTo?: boolean, fromTo?: boolean): IPointData {\n const r = getAtan2(t, to)\n fromTo && (t = to)\n changeTo || (to = {} as IPointData)\n to.x = t.x + cos(r) * distance\n to.y = t.y + sin(r) * distance\n return to\n },\n\n toNumberPoints(originPoints: number[] | IPointData[]): number[] {\n let points = originPoints as number[]\n if (isObject(originPoints[0])) points = [], (originPoints as IPointData[]).forEach(p => points.push(p.x, p.y))\n return points\n },\n\n isSame(t: IPointData, point: IPointData): boolean {\n return float(t.x) === float(point.x) && float(t.y) === float(point.y)\n },\n\n reset(t: IPointData): void {\n P.reset(t)\n }\n}\n\nconst P = PointHelper\nconst { getDistanceFrom, copy, setRadius, getAtan2 } = P","import { IPoint, IPointData, IMatrixData } from '@leafer/interface'\nimport { isObject } from '@leafer/data'\n\nimport { PointHelper as P } from './PointHelper'\n\nexport class Point implements IPoint {\n\n public x: number\n public y: number\n\n constructor(x?: number | IPointData, y?: number) {\n this.set(x, y)\n }\n\n public set(x?: number | IPointData, y?: number): IPoint {\n isObject(x) ? P.copy(this, x) : P.set(this, x, y)\n return this\n }\n\n public get(): IPointData {\n const { x, y } = this\n return { x, y }\n }\n\n\n public clone(): IPoint {\n return new Point(this)\n }\n\n\n public move(x: number | IPointData, y?: number): IPoint {\n P.move(this, x, y)\n return this\n }\n\n public scale(scaleX: number, scaleY?: number): IPoint {\n P.scale(this, scaleX, scaleY)\n return this\n }\n\n public scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IPoint {\n P.scaleOf(this, origin, scaleX, scaleY)\n return this\n }\n\n public rotate(rotation: number, origin?: IPointData): IPoint {\n P.rotate(this, rotation, origin)\n return this\n }\n\n public rotateOf(origin: IPointData, rotation: number): IPoint {\n P.rotate(this, rotation, origin)\n return this\n }\n\n public getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number {\n return P.getRotation(this, origin, to, toOrigin)\n }\n\n\n public toInnerOf(matrix: IMatrixData, to?: IPointData): IPoint {\n P.toInnerOf(this, matrix, to)\n return this\n }\n\n public toOuterOf(matrix: IMatrixData, to?: IPointData): IPoint {\n P.toOuterOf(this, matrix, to)\n return this\n }\n\n\n public getCenter(to: IPointData): IPoint {\n return new Point(P.getCenter(this, to))\n }\n\n public getDistance(to: IPointData): number {\n return P.getDistance(this, to)\n }\n\n public getDistancePoint(to: IPointData, distance: number, changeTo?: boolean, fromTo?: boolean): IPoint {\n return new Point(P.getDistancePoint(this, to, distance, changeTo, fromTo))\n }\n\n public getAngle(to: IPointData): number {\n return P.getAngle(this, to)\n }\n\n public getAtan2(to: IPointData): number {\n return P.getAtan2(this, to)\n }\n\n public isSame(point: IPointData): boolean {\n return P.isSame(this, point)\n }\n\n public reset(): IPoint {\n P.reset(this)\n return this\n }\n\n}\n\nexport const tempPoint = new Point()","import { IMatrix, IMatrixData, IPointData, ILayoutData, IMatrixWithScaleData } from '@leafer/interface'\nimport { isObject } from '@leafer/data'\n\nimport { MatrixHelper as M } from './MatrixHelper'\n\n\nexport class Matrix implements IMatrix {\n\n public a: number\n public b: number\n public c: number\n public d: number\n public e: number\n public f: number\n\n public scaleX: number\n public scaleY: number\n\n constructor(a?: number | IMatrixData, b?: number, c?: number, d?: number, e?: number, f?: number) {\n this.set(a, b, c, d, e, f)\n }\n\n public set(a?: number | IMatrixData, b?: number, c?: number, d?: number, e?: number, f?: number): IMatrix {\n isObject(a) ? M.copy(this, a) : M.set(this, a, b, c, d, e, f)\n return this\n }\n\n public setWith(dataWithScale: IMatrixWithScaleData): IMatrix {\n M.copy(this, dataWithScale)\n this.scaleX = dataWithScale.scaleX\n this.scaleY = dataWithScale.scaleY\n return this\n }\n\n public get(): IMatrixData {\n const { a, b, c, d, e, f } = this\n return { a, b, c, d, e, f }\n }\n\n public clone(): IMatrix {\n return new Matrix(this)\n }\n\n\n public translate(x: number, y: number): IMatrix {\n M.translate(this, x, y)\n return this\n }\n\n public translateInner(x: number, y: number): IMatrix {\n M.translateInner(this, x, y)\n return this\n }\n\n public scale(x: number, y?: number): IMatrix {\n M.scale(this, x, y)\n return this\n }\n\n public scaleWith(x: number, y?: number): IMatrix {\n M.scale(this, x, y)\n this.scaleX *= x\n this.scaleY *= y || x\n return this\n }\n\n public pixelScale(pixelRatio: number): IMatrix {\n M.pixelScale(this, pixelRatio)\n return this\n }\n\n public scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix {\n M.scaleOfOuter(this, origin, x, y)\n return this\n }\n public scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix {\n M.scaleOfInner(this, origin, x, y)\n return this\n }\n\n public rotate(angle: number): IMatrix {\n M.rotate(this, angle)\n return this\n }\n\n public rotateOfOuter(origin: IPointData, angle: number): IMatrix {\n M.rotateOfOuter(this, origin, angle)\n return this\n }\n\n public rotateOfInner(origin: IPointData, angle: number): IMatrix {\n M.rotateOfInner(this, origin, angle)\n return this\n }\n\n\n public skew(x: number, y?: number): IMatrix {\n M.skew(this, x, y)\n return this\n }\n\n public skewOfOuter(origin: IPointData, x: number, y?: number): IMatrix {\n M.skewOfOuter(this, origin, x, y)\n return this\n }\n\n public skewOfInner(origin: IPointData, x: number, y?: number): IMatrix {\n M.skewOfInner(this, origin, x, y)\n return this\n }\n\n\n public multiply(child: IMatrixData): IMatrix {\n M.multiply(this, child)\n return this\n }\n\n public multiplyParent(parent: IMatrixData): IMatrix {\n M.multiplyParent(this, parent)\n return this\n }\n\n\n public divide(child: IMatrixData): IMatrix {\n M.divide(this, child)\n return this\n }\n\n public divideParent(parent: IMatrixData): IMatrix {\n M.divideParent(this, parent)\n return this\n }\n\n public invert(): IMatrix {\n M.invert(this)\n return this\n }\n\n public invertWith(): IMatrix {\n M.invert(this)\n this.scaleX = 1 / this.scaleX\n this.scaleY = 1 / this.scaleY\n return this\n }\n\n\n public toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void {\n M.toOuterPoint(this, inner, to, distance)\n }\n\n public toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void {\n M.toInnerPoint(this, outer, to, distance)\n }\n\n\n public setLayout(data: ILayoutData, origin?: IPointData, around?: IPointData,): IMatrix {\n M.setLayout(this, data, origin, around)\n return this\n }\n\n public getLayout(origin?: IPointData, around?: IPointData, firstSkewY?: boolean): ILayoutData {\n return M.getLayout(this, origin, around, firstSkewY)\n }\n\n public withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData {\n return M.withScale(this, scaleX, scaleY)\n }\n\n public reset(): void {\n M.reset(this)\n }\n\n}\n\nexport const tempMatrix = new Matrix()","import { ITwoPointBoundsData, IBoundsData } from '@leafer/interface'\n\nexport const TwoPointBoundsHelper = {\n\n tempPointBounds: {} as ITwoPointBoundsData,\n\n setPoint(t: ITwoPointBoundsData, minX: number, minY: number): void {\n t.minX = t.maxX = minX\n t.minY = t.maxY = minY\n },\n\n addPoint(t: ITwoPointBoundsData, x: number, y: number): void {\n t.minX = x < t.minX ? x : t.minX\n t.minY = y < t.minY ? y : t.minY\n t.maxX = x > t.maxX ? x : t.maxX\n t.maxY = y > t.maxY ? y : t.maxY\n },\n\n addBounds(t: ITwoPointBoundsData, x: number, y: number, width: number, height: number): void {\n addPoint(t, x, y)\n addPoint(t, x + width, y + height)\n },\n\n copy(t: ITwoPointBoundsData, pb: ITwoPointBoundsData): void {\n t.minX = pb.minX\n t.minY = pb.minY\n t.maxX = pb.maxX\n t.maxY = pb.maxY\n },\n\n addPointBounds(t: ITwoPointBoundsData, pb: ITwoPointBoundsData): void {\n t.minX = pb.minX < t.minX ? pb.minX : t.minX\n t.minY = pb.minY < t.minY ? pb.minY : t.minY\n t.maxX = pb.maxX > t.maxX ? pb.maxX : t.maxX\n t.maxY = pb.maxY > t.maxY ? pb.maxY : t.maxY\n },\n\n toBounds(t: ITwoPointBoundsData, setBounds: IBoundsData): void {\n setBounds.x = t.minX\n setBounds.y = t.minY\n setBounds.width = t.maxX - t.minX\n setBounds.height = t.maxY - t.minY\n }\n\n}\n\nconst { addPoint } = TwoPointBoundsHelper","export enum Direction4 {\n top,\n right,\n bottom,\n left\n}\n\nexport enum Direction9 {\n topLeft,\n top,\n topRight,\n right,\n bottomRight,\n bottom,\n bottomLeft,\n left,\n center,\n 'top-left' = 0,\n 'top-right' = 2,\n 'bottom-right' = 4,\n 'bottom-left' = 6\n}","import { IAround, IPointData, IBoundsData, IUnitPointData } from '@leafer/interface'\nimport { isString } from '@leafer/data'\n\nimport { Direction9 } from './Direction'\n\n\nconst directionData: IUnitPointData[] = [\n { x: 0, y: 0 }, //topLeft\n { x: 0.5, y: 0 },//top\n { x: 1, y: 0 }, //topRight\n { x: 1, y: 0.5 },// right\n { x: 1, y: 1 }, //bottomRight\n { x: 0.5, y: 1 },//bottom\n { x: 0, y: 1 }, //bottomLeft\n { x: 0, y: 0.5 },//left\n { x: 0.5, y: 0.5 } // center\n]\ndirectionData.forEach(item => item.type = 'percent')\n\nexport const AroundHelper = {\n\n directionData, //