UNPKG

@leafer/core

Version:
1 lines 517 kB
{"version":3,"file":"core.cjs","sources":["../../../../../../src/leafer/packages/platform/platform/src/Platform.ts","../../../../../../src/leafer/packages/platform/platform/src/creator/Creator.ts","../../../../../../src/leafer/packages/math/src/IncrementId.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/BoundsHelper.ts","../../../../../../src/leafer/packages/math/src/Bounds.ts","../../../../../../src/leafer/packages/math/src/AutoBounds.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/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/UICreator.ts","../../../../../../src/leafer/packages/platform/platform/src/creator/EventCreator.ts","../../../../../../src/leafer/packages/canvas/canvas/src/CanvasManager.ts","../../../../../../src/leafer/packages/display-module/data/src/DataHelper.ts","../../../../../../src/leafer/packages/display-module/data/src/LeafData.ts","../../../../../../src/leafer/packages/display-module/data/src/index.ts","../../../../../node_modules/.pnpm/@rollup+plugin-typescript@11.1.6_rollup@4.34.6_tslib@2.8.1_typescript@5.7.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/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/canvas/canvas/src/patch/index.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/decorator/src/class.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/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/list/src/LeafLevelList.ts","../../../../../../src/leafer/packages/core/src/index.ts"],"sourcesContent":["import { IPlatform } from '@leafer/interface'\n\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 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 }\n}","import { ICreator } from '@leafer/interface'\n\n\nexport const Creator: ICreator = {\n\n}","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 { IPointData, IBoundsData, IMatrixData, IRangeSize, IScaleData, ISizeData, IOptionSizeData } from '@leafer/interface'\n\nconst { round, pow, PI } = Math\n\nexport const MathHelper = {\n\n within(value: number, min: number | IRangeSize, max?: number): number {\n if (typeof min === 'object') max = min.max, min = min.min\n if (min !== undefined && value < min) value = min\n if (max !== undefined && value > max) value = max\n return value\n },\n\n fourNumber(num: number | number[], maxValue?: number): number[] { // top right bottom left || topLeft, topRight, bottomRight, bottomLeft\n let data: number[]\n if (num instanceof Array) {\n switch (num.length) {\n case 4:\n data = maxValue === undefined ? 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 (maxValue) for (let i = 0; i < 4; i++) if (data[i] > maxValue) data[i] = maxValue\n return data\n },\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 = maxLength !== undefined ? pow(10, maxLength) : 1000000000000 // default\n num = round(num * a) / a\n return num === -0 ? 0 : num\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 = (typeof size === 'number' ? size : size.width || 0) / originSize.width, scaleY = (typeof size === 'number' ? 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 (typeof scale === 'number') {\n scaleData.scaleX = scaleData.scaleY = scale\n } else {\n scaleData.scaleX = scale.x\n scaleData.scaleY = scale.y\n }\n }\n\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, IScrollPointData } from '@leafer/interface'\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 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, scrollData?: IScrollPointData): void { // = transform\n let { e, f } = t\n if (scrollData) e += scrollData.scrollX, f += scrollData.scrollY\n\n to || (to = t)\n\n if (abcdChanged === undefined) 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 (bcChanged === undefined) 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 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 { OneRadian, PI2, getPointData } from './MathHelper'\n\nimport { MatrixHelper as M } from './MatrixHelper'\n\n\nconst { toInnerPoint, toOuterPoint } = M\nconst { sin, cos, abs, sqrt, atan2, min, PI } = 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 = y === undefined ? 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 move(t: IPointData, x: number, y: number): void {\n t.x += x\n 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 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 (toOriginX === undefined) toOriginX = originX, toOriginY = originY\n let fromAngle = atan2(fromY - originY, fromX - originX)\n let toAngle = atan2(toY - toOriginY, toX - toOriginX)\n const radian = toAngle - fromAngle\n return radian < -PI ? radian + PI2 : radian\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): IPointData {\n const r = getAtan2(t, to)\n to = 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 (typeof originPoints[0] === 'object') points = [], (originPoints as IPointData[]).forEach(p => points.push(p.x, p.y))\n return points\n },\n\n reset(t: IPointData): void {\n P.reset(t)\n }\n}\n\nconst P = PointHelper\nconst { getDistanceFrom, copy, getAtan2 } = P","import { IPoint, IPointData, IMatrixData } from '@leafer/interface'\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 typeof x === 'object' ? 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, 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): IPoint {\n return new Point(P.getDistancePoint(this, to, distance, changeTo))\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\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 { 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 typeof a === 'object' ? 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 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","import { IPointData, IBoundsData, IMatrixData, IFourNumber, IBoundsDataFn, IObject, IMatrix, IOffsetBoundsData, IRadiusPointData, IMatrixWithScaleData, ISide } from '@leafer/interface'\nimport { Matrix } from './Matrix'\nimport { MatrixHelper as M } from './MatrixHelper'\nimport { TwoPointBoundsHelper as TB } from './TwoPointBoundsHelper'\nimport { PointHelper as P } from './PointHelper'\nimport { MathHelper, getBoundsData } from './MathHelper'\n\n\nconst { tempPointBounds, setPoint, addPoint, toBounds } = TB\nconst { toOuterPoint } = M\nconst { float, fourNumber } = MathHelper\nconst { floor, ceil } = Math\n\nlet right: number, bottom: number, boundsRight: number, boundsBottom: number\nconst point = {} as IPointData\nconst toPoint = {} as IPointData\n\nexport const BoundsHelper = {\n\n tempBounds: {} as IBoundsData,\n\n set(t: IBoundsData, x = 0, y = 0, width = 0, height = 0): void {\n t.x = x\n t.y = y\n t.width = width\n t.height = height\n },\n\n copy(t: IBoundsData, bounds: IBoundsData): void {\n t.x = bounds.x\n t.y = bounds.y\n t.width = bounds.width\n t.height = bounds.height\n },\n\n copyAndSpread(t: IBoundsData, bounds: IBoundsData, spread: IFourNumber, isShrink?: boolean, side?: ISide): void {\n const { x, y, width, height } = bounds\n if (spread instanceof Array) {\n const four = fourNumber(spread)\n isShrink\n ? B.set(t, x + four[3], y + four[0], width - four[1] - four[3], height - four[2] - four[0])\n : B.set(t, x - four[3], y - four[0], width + four[1] + four[3], height + four[2] + four[0])\n } else {\n if (isShrink) spread = -spread\n B.set(t, x - spread, y - spread, width + spread * 2, height + spread * 2)\n }\n\n if (side) { // 只扩展/收缩一边\n if (side === 'width') t.y = y, t.height = height\n else t.x = x, t.width = width\n }\n },\n\n\n minX(t: IBoundsData): number { return t.width > 0 ? t.x : t.x + t.width },\n\n minY(t: IBoundsData): number { return t.height > 0 ? t.y : t.y + t.height },\n\n maxX(t: IBoundsData): number { return t.width > 0 ? t.x + t.width : t.x },\n\n maxY(t: IBoundsData): number { return t.height > 0 ? t.y + t.height : t.y },\n\n\n move(t: IBoundsData, x: number, y: number): void {\n t.x += x\n t.y += y\n },\n\n getByMove(t: IBoundsData, x: number, y: number): IBoundsData {\n t = { ...t }\n B.move(t, x, y)\n return t\n },\n\n toOffsetOutBounds(t: IBoundsData, to?: IOffsetBoundsData, parent?: IBoundsData): void {\n if (!to) {\n to = t as IOffsetBoundsData\n } else {\n copy(to, t)\n }\n if (parent) {\n to.offsetX = -(B.maxX(parent) - t.x)\n to.offsetY = -(B.maxY(parent) - t.y)\n } else {\n to.offsetX = t.x + t.width\n to.offsetY = t.y + t.height\n }\n B.move(to, -to.offsetX, -to.offsetY)\n },\n\n\n scale(t: IBoundsData, scaleX: number, scaleY = scaleX): void {\n P.scale(t, scaleX, scaleY)\n t.width *= scaleX\n t.height *= scaleY\n },\n\n scaleOf(t: IBoundsData, origin: IPointData, scaleX: number, scaleY = scaleX): void {\n P.scaleOf(t, origin, scaleX, scaleY)\n t.width *= scaleX\n t.height *= scaleY\n },\n\n tempToOuterOf(t: IBoundsData, matrix: IMatrixData): IBoundsData {\n B.copy(B.tempBounds, t)\n B.toOuterOf(B.tempBounds, matrix)\n return B.tempBounds\n },\n\n getOuterOf(t: IBoundsData, matrix: IMatrixData): IBoundsData {\n t = { ...t }\n B.toOuterOf(t, matrix)\n return t\n },\n\n toOuterOf(t: IBoundsData, matrix: IMatrixData, to?: IBoundsData): void {\n\n to || (to = t)\n\n if (matrix.b === 0 && matrix.c === 0) {\n\n const { a, d } = matrix\n if (a > 0) {\n to.width = t.width * a\n to.x = matrix.e + t.x * a\n } else {\n to.width = t.width * -a\n to.x = matrix.e + t.x * a - to.width\n }\n\n if (d > 0) {\n to.height = t.height * d\n to.y = matrix.f + t.y * d\n } else {\n to.height = t.height * -d\n to.y = matrix.f + t.y * d - to.height\n }\n\n } else {\n\n point.x = t.x\n point.y = t.y\n\n toOuterPoint(matrix, point, toPoint)\n setPoint(tempPointBounds, toPoint.x, toPoint.y)\n\n point.x = t.x + t.width\n\n toOuterPoint(matrix, point, toPoint)\n addPoint(tempPointBounds, toPoint.x, toPoint.y)\n\n point.y = t.y + t.height\n\n toOuterPoint(matrix, point, toPoint)\n addPoint(tempPointBounds, toPoint.x, toPoint.y)\n\n point.x = t.x\n\n toOuterPoint(matrix, point, toPoint)\n addPoint(tempPointBounds, toPoint.x, toPoint.y)\n\n toBounds(tempPointBounds, to)\n }\n },\n\n toInnerOf(t: IBoundsData, matrix: IMatrixData, to?: IBoundsData): void {\n to || (to = t)\n B.move(to, -matrix.e, -matrix.f)\n B.scale(to, 1 / matrix.a, 1 / matrix.d)\n },\n\n getFitMatrix(t: IBoundsData, put: IBoundsData, baseScale = 1): IMatrix {\n const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height))\n return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale)\n },\n\n\n getSpread(t: IBoundsData, spread: IFourNumber, side?: ISide): IBoundsData {\n const n = {} as IBoundsData\n B.copyAndSpread(n, t, spread, false, side)\n return n\n },\n\n spread(t: IBoundsData, spread: IFourNumber, side?: ISide): void {\n B.copyAndSpread(t, t, spread, false, side)\n },\n\n shrink(t: IBoundsData, shrink: IFourNumber, side?: ISide): void {\n B.copyAndSpread(t, t, shrink, true, side)\n },\n\n ceil(t: IBoundsData): void {\n const { x, y } = t\n t.x = floor(t.x)\n t.y = floor(t.y)\n t.width = x > t.x ? ceil(t.width + x - t.x) : ceil(t.width)\n t.height = y > t.y ? ceil(t.height + y - t.y) : ceil(t.height)\n },\n\n unsign(t: IBoundsData): void {\n if (t.width < 0) {\n t.x += t.width\n t.width = -t.width\n }\n if (t.height < 0) {\n t.y += t.height\n t.height = -t.height\n }\n },\n\n float(t: IBoundsData, maxLength?: number): void {\n t.x = float(t.x, maxLength)\n t.y = float(t.y, maxLength)\n t.width = float(t.width, maxLength)\n t.height = float(t.height, maxLength)\n },\n\n add(t: IBoundsData, bounds: IBoundsData, isPoint?: boolean): void {\n right = t.x + t.width\n bottom = t.y + t.height\n boundsRight = bounds.x\n boundsBottom = bounds.y\n\n if (!isPoint) {\n boundsRight += bounds.width\n boundsBottom += bounds.height\n }\n\n right = right > boundsRight ? right : boundsRight\n bottom = bottom > boundsBottom ? bottom : boundsBottom\n\n t.x = t.x < bounds.x ? t.x : bounds.x\n t.y = t.y < bounds.y ? t.y : bounds.y\n t.width = right - t.x\n t.height = bottom - t.y\n },\n\n addList(t: IBoundsData, list: IBoundsData[]): void {\n B.setListWithFn(t, list, undefined, true)\n },\n\n setList(t: IBoundsData, list: IBoundsData[], addMode = false): void {\n B.setListWithFn(t, list, undefined, addMode)\n },\n\n addListWithFn(t: IBoundsData, list: IObject[], boundsDataFn: IBoundsDataFn): void {\n B.setListWithFn(t, list, boundsDataFn, true)\n },\n\n setListWithFn(t: IBoundsData, list: IObject[], boundsDataFn: IBoundsDataFn, addMode = false): void {\n let bounds: IBoundsData, first = true\n for (let i = 0, len = list.length; i < len; i++) {\n bounds = boundsDataFn ? boundsDataFn(list[i]) : list[i] as IBoundsData\n if (bounds && (bounds.width || bounds.height)) {\n if (first) {\n first = false\n if (!addMode) copy(t, bounds)\n } else {\n add(t, bounds)\n }\n }\n }\n\n if (first) B.reset(t)\n },\n\n\n setPoints(t: IBoundsData, points: IPointData[]): void {\n points.forEach((point, index) => index === 0 ? setPoint(tempPointBounds, point.x, point.y) : addPoint(tempPointBounds, point.x, point.y))\n toBounds(tempPointBounds, t)\n },\n\n setPoint(t: IBoundsData, point: IPointData): void {\n B.set(t, point.x, point.y)\n },\n\n addPoint(t: IBoundsData, point: IPointData): void {\n add(t, point as IBoundsData, true)\n },\n\n getPoints(t: IBoundsData): IPointData[] {\n const { x, y, width, height } = t\n return [\n { x, y }, // topLeft\n { x: x + width, y }, // topRight\n { x: x + width, y: y + height }, // bottomRight\n { x, y: y + height } // bottomLeft\n ]\n },\n\n\n hitRadiusPoint(t: IBoundsData, point: IRadiusPointData, pointMatrix?: IMatrixWithScaleData): boolean {\n if (pointMatrix) point = P.tempToInnerRadiusPointOf(point, pointMatrix)\n return (point.x >= t.x - point.radiusX && point.x <= t.x + t.width + point.radiusX) && (point.y >= t.y - point.radiusY && point.y <= t.y + t.height + point.radiusY)\n },\n\n hitPoint(t: IBoundsData, point: IPointData, pointMatrix?: IMatrixData): boolean {\n if (pointMatrix) point = P.tempToInnerOf(point, pointMatrix)\n return (point.x >= t.x && point.x <= t.x + t.width) && (point.y >= t.y && point.y <= t.y + t.height)\n },\n\n\n hit(t: IBoundsData, other: IBoundsData, otherMatrix?: IMatrixData): boolean {\n if (otherMatrix) other = B.tempToOuterOf(other, otherMatrix)\n return !((t.y + t.height < other.y) || (other.y + other.height < t.y) || (t.x + t.width < other.x) || (other.x + other.width < t.x))\n },\n\n includes(t: IBoundsData, other: IBoundsData, otherMatrix?: IMatrixData): boolean {\n if (otherMatrix) other = B.tempToOuterOf(other, otherMatrix)\n return (t.x <= other.x) && (t.y <= other.y) && (t.x + t.width >= other.x + other.width) && (t.y + t.height >= other.y + other.height)\n },\n\n getIntersectData(t: IBoundsData, other: IBoundsData, otherMatrix?: IMatrixData): IBoundsData {\n if (otherMatrix) other = B.tempToOuterOf(other, otherMatrix)\n if (!B.hit(t, other)) return getBoundsData()\n\n let { x, y, width, height } = other\n\n right = x + width\n bottom = y + height\n boundsRight = t.x + t.width\n boundsBottom = t.y + t.height\n\n x = x > t.x ? x : t.x\n y = y > t.y ? y : t.y\n right = right < boundsRight ? right : boundsRight\n bottom = bottom < boundsBottom ? bottom : boundsBottom\n\n width = right - x\n height = bottom - y\n\n return { x, y, width, height }\n },\n\n intersect(t: IBoundsData, other: IBoundsData, otherMatrix?: IMatrixData): void {\n B.copy(t, B.getIntersectData(t, other, otherMatrix))\n },\n\n\n isSame(t: IBoundsData, bounds: IBoundsData): boolean {\n return t.x === bounds.x && t.y === bounds.y && t.width === bounds.width && t.height === bounds.height\n },\n\n isEmpty(t: IBoundsData): boolean {\n return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0\n },\n\n reset(t: IBoundsData): void {\n B.set(t)\n }\n}\n\nconst B = BoundsHelper\nconst { add, copy } = B","import { IBounds, IBoundsData, IMatrixData, IPointData, IBoundsDataFn, IObject, IMatrix, IRadiusPointData, IMatrixWithLayoutData, IFourNumber, ISide } from '@leafer/interface'\nimport { BoundsHelper as B } from './BoundsHelper'\n\n\nexport class Bounds implements IBounds {\n\n public x: number\n public y: number\n public width: number\n public height: number\n\n public get minX(): number { return B.minX(this) }\n public get minY(): number { return B.minY(this) }\n public get maxX(): number { return B.maxX(this) }\n public get maxY(): number { return B.maxY(this) }\n\n constructor(x?: number | IBoundsData, y?: number, width?: number, height?: number) {\n this.set(x, y, width, height)\n }\n\n public set(x?: number | IBoundsData, y?: number, width?: number, height?: number): IBounds {\n typeof x === 'object' ? B.copy(this, x) : B.set(this, x, y, width, height)\n return this\n }\n\n public get(): IBoundsData {\n const { x, y, width, height } = this\n return { x, y, width, height }\n }\n\n public clone(): IBounds {\n return new Bounds(this)\n }\n\n\n public move(x: number, y: number): IBounds {\n B.move(this, x, y)\n return this\n }\n\n public scale(scaleX: number, scaleY?: number): IBounds {\n B.scale(this, scaleX, scaleY)\n return this\n }\n\n public scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds {\n B.scaleOf(this, origin, scaleX, scaleY)\n return this\n }\n\n public toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds {\n B.toOuterOf(this, matrix, to)\n return this\n }\n\n public toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds {\n B.toInnerOf(this, matrix, to)\n return this\n }\n\n public getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix {\n return B.getFitMatrix(this, put, baseScale)\n }\n\n public spread(fourNumber: IFourNumber, side?: ISide): IBounds {\n B.spread(this, fourNumber, side)\n return this\n }\n\n public shrink(fourNumber: IFourNumber, side?: ISide): IBounds {\n B.shrink(this, fourNumber, side)\n return this\n }\n\n public ceil(): IBounds {\n B.ceil(this)\n return this\n }\n\n public unsign(): IBounds {\n B.unsign(this)\n return this\n }\n\n public float(maxLength?: number): IBounds {\n B.float(this, maxLength)\n return this\n }\n\n\n public add(bounds: IBoundsData): IBounds {\n B.add(this, bounds)\n return this\n }\n\n public addList(boundsList: IBoundsData[]): IBounds {\n B.setList(this, boundsList, true)\n return this\n }\n\n public setList(boundsList: IBoundsData[]): IBounds {\n B.setList(this, boundsList)\n return