@visactor/vrender 0.15.0-alpha.14 → 0.15.0-alpha.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animate/animate.d.ts +0 -1
- package/cjs/animate/animate.js +0 -3
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/timeline.d.ts +1 -1
- package/cjs/animate/timeline.js +2 -2
- package/cjs/animate/timeline.js.map +1 -1
- package/cjs/canvas/contributions/browser/context.d.ts +0 -1
- package/cjs/common/contribution-provider.d.ts +0 -1
- package/cjs/common/contribution-provider.js +2 -7
- package/cjs/common/contribution-provider.js.map +1 -1
- package/cjs/common/enums.d.ts +2 -4
- package/cjs/common/enums.js +2 -3
- package/cjs/common/enums.js.map +1 -1
- package/cjs/core/contributions/env/base-contribution.d.ts +1 -11
- package/cjs/core/contributions/env/base-contribution.js +1 -22
- package/cjs/core/contributions/env/base-contribution.js.map +1 -1
- package/cjs/core/contributions/env/browser-contribution.d.ts +2 -11
- package/cjs/core/contributions/env/browser-contribution.js +0 -66
- package/cjs/core/contributions/env/browser-contribution.js.map +1 -1
- package/cjs/core/contributions/textMeasure/layout.js +1 -1
- package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
- package/cjs/core/contributions/window/base-contribution.d.ts +5 -11
- package/cjs/core/contributions/window/base-contribution.js +0 -10
- package/cjs/core/contributions/window/base-contribution.js.map +1 -1
- package/cjs/core/contributions/window/browser-contribution.d.ts +0 -11
- package/cjs/core/contributions/window/browser-contribution.js +2 -33
- package/cjs/core/contributions/window/browser-contribution.js.map +1 -1
- package/cjs/core/global.d.ts +1 -11
- package/cjs/core/global.js +0 -18
- package/cjs/core/global.js.map +1 -1
- package/cjs/core/layer.js +6 -6
- package/cjs/core/layer.js.map +1 -1
- package/cjs/core/stage.d.ts +4 -13
- package/cjs/core/stage.js +25 -54
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.d.ts +0 -6
- package/cjs/core/window.js +1 -10
- package/cjs/core/window.js.map +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-left.js +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-left.js.map +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-right.js +1 -1
- package/cjs/graphic/builtin-symbol/arrow2-right.js.map +1 -1
- package/cjs/graphic/builtin-symbol/index.d.ts +1 -1
- package/cjs/graphic/builtin-symbol/index.js +2 -2
- package/cjs/graphic/builtin-symbol/index.js.map +1 -1
- package/cjs/graphic/builtin-symbol/utils.d.ts +5 -13
- package/cjs/graphic/builtin-symbol/utils.js +9 -23
- package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
- package/cjs/graphic/config.js +6 -7
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/constants.d.ts +0 -22
- package/cjs/graphic/constants.js +2 -20
- package/cjs/graphic/constants.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +0 -3
- package/cjs/graphic/graphic.js +26 -40
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.js +1 -1
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/index.d.ts +0 -1
- package/cjs/graphic/index.js +13 -13
- package/cjs/graphic/index.js.map +1 -1
- package/cjs/graphic/richtext/utils.d.ts +1 -1
- package/cjs/graphic/richtext/utils.js +1 -1
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/symbol.d.ts +1 -2
- package/cjs/graphic/symbol.js +4 -27
- package/cjs/graphic/symbol.js.map +1 -1
- package/cjs/graphic/text.js +23 -33
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/tools.d.ts +2 -3
- package/cjs/graphic/tools.js +3 -58
- package/cjs/graphic/tools.js.map +1 -1
- package/cjs/graphic/wrap-text.js +8 -10
- package/cjs/graphic/wrap-text.js.map +1 -1
- package/cjs/index.d.ts +1 -2
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +1 -3
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/global.d.ts +1 -25
- package/cjs/interface/global.js.map +1 -1
- package/cjs/interface/graphic/image.d.ts +0 -1
- package/cjs/interface/graphic/image.js.map +1 -1
- package/cjs/interface/graphic/line.d.ts +1 -0
- package/cjs/interface/graphic/line.js.map +1 -1
- package/cjs/interface/graphic/symbol.d.ts +2 -3
- package/cjs/interface/graphic/symbol.js.map +1 -1
- package/cjs/interface/graphic/text.d.ts +0 -1
- package/cjs/interface/graphic/text.js.map +1 -1
- package/cjs/interface/graphic.d.ts +3 -25
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/render.d.ts +0 -1
- package/cjs/interface/render.js.map +1 -1
- package/cjs/interface/stage.d.ts +3 -10
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/interface/window.d.ts +0 -12
- package/cjs/interface/window.js.map +1 -1
- package/cjs/picker/contributions/canvas-picker/symbol-picker.js +2 -4
- package/cjs/picker/contributions/canvas-picker/symbol-picker.js.map +1 -1
- package/cjs/picker/pick-interceptor.js +3 -2
- package/cjs/picker/pick-interceptor.js.map +1 -1
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.d.ts +0 -2
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +21 -42
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/cjs/plugins/plugin-modules.js +1 -1
- package/cjs/plugins/plugin-modules.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +31 -21
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +1 -23
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.d.ts +1 -3
- package/cjs/render/contributions/render/draw-contribution.js +1 -3
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +3 -7
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/line-render.js +50 -23
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +5 -12
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.d.ts +2 -2
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/cjs/render/render-service.js +1 -3
- package/cjs/render/render-service.js.map +1 -1
- package/dist/index.js +318 -3342
- package/dist/index.min.js +1 -1
- package/es/animate/animate.d.ts +0 -1
- package/es/animate/animate.js +0 -3
- package/es/animate/animate.js.map +1 -1
- package/es/animate/timeline.d.ts +1 -1
- package/es/animate/timeline.js +2 -2
- package/es/animate/timeline.js.map +1 -1
- package/es/canvas/contributions/browser/context.d.ts +0 -1
- package/es/common/contribution-provider.d.ts +0 -1
- package/es/common/contribution-provider.js +0 -4
- package/es/common/contribution-provider.js.map +1 -1
- package/es/common/enums.d.ts +2 -4
- package/es/common/enums.js +2 -3
- package/es/common/enums.js.map +1 -1
- package/es/core/contributions/env/base-contribution.d.ts +1 -11
- package/es/core/contributions/env/base-contribution.js +0 -23
- package/es/core/contributions/env/base-contribution.js.map +1 -1
- package/es/core/contributions/env/browser-contribution.d.ts +2 -11
- package/es/core/contributions/env/browser-contribution.js +1 -67
- package/es/core/contributions/env/browser-contribution.js.map +1 -1
- package/es/core/contributions/textMeasure/layout.js +1 -1
- package/es/core/contributions/textMeasure/layout.js.map +1 -1
- package/es/core/contributions/window/base-contribution.d.ts +5 -11
- package/es/core/contributions/window/base-contribution.js +0 -10
- package/es/core/contributions/window/base-contribution.js.map +1 -1
- package/es/core/contributions/window/browser-contribution.d.ts +0 -11
- package/es/core/contributions/window/browser-contribution.js +2 -33
- package/es/core/contributions/window/browser-contribution.js.map +1 -1
- package/es/core/global.d.ts +1 -11
- package/es/core/global.js +0 -18
- package/es/core/global.js.map +1 -1
- package/es/core/layer.js +6 -6
- package/es/core/layer.js.map +1 -1
- package/es/core/stage.d.ts +4 -13
- package/es/core/stage.js +24 -57
- package/es/core/stage.js.map +1 -1
- package/es/core/window.d.ts +0 -6
- package/es/core/window.js +1 -10
- package/es/core/window.js.map +1 -1
- package/es/graphic/builtin-symbol/arrow2-left.js +1 -1
- package/es/graphic/builtin-symbol/arrow2-left.js.map +1 -1
- package/es/graphic/builtin-symbol/arrow2-right.js +1 -1
- package/es/graphic/builtin-symbol/arrow2-right.js.map +1 -1
- package/es/graphic/builtin-symbol/index.d.ts +1 -1
- package/es/graphic/builtin-symbol/index.js +1 -11
- package/es/graphic/builtin-symbol/index.js.map +1 -1
- package/es/graphic/builtin-symbol/utils.d.ts +5 -13
- package/es/graphic/builtin-symbol/utils.js +7 -25
- package/es/graphic/builtin-symbol/utils.js.map +1 -1
- package/es/graphic/config.js +6 -7
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/constants.d.ts +0 -22
- package/es/graphic/constants.js +0 -26
- package/es/graphic/constants.js.map +1 -1
- package/es/graphic/graphic.d.ts +0 -3
- package/es/graphic/graphic.js +26 -40
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.js +1 -1
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/index.d.ts +0 -1
- package/es/graphic/index.js +0 -2
- package/es/graphic/index.js.map +1 -1
- package/es/graphic/richtext/utils.d.ts +1 -1
- package/es/graphic/richtext/utils.js +1 -1
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/symbol.d.ts +1 -2
- package/es/graphic/symbol.js +1 -28
- package/es/graphic/symbol.js.map +1 -1
- package/es/graphic/text.js +23 -33
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/tools.d.ts +2 -3
- package/es/graphic/tools.js +0 -59
- package/es/graphic/tools.js.map +1 -1
- package/es/graphic/wrap-text.js +8 -10
- package/es/graphic/wrap-text.js.map +1 -1
- package/es/index.d.ts +1 -2
- package/es/index.js +1 -3
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +1 -3
- package/es/interface/animate.js.map +1 -1
- package/es/interface/global.d.ts +1 -25
- package/es/interface/global.js.map +1 -1
- package/es/interface/graphic/image.d.ts +0 -1
- package/es/interface/graphic/image.js.map +1 -1
- package/es/interface/graphic/line.d.ts +1 -0
- package/es/interface/graphic/line.js.map +1 -1
- package/es/interface/graphic/symbol.d.ts +2 -3
- package/es/interface/graphic/symbol.js.map +1 -1
- package/es/interface/graphic/text.d.ts +0 -1
- package/es/interface/graphic/text.js.map +1 -1
- package/es/interface/graphic.d.ts +3 -25
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/render.d.ts +0 -1
- package/es/interface/render.js.map +1 -1
- package/es/interface/stage.d.ts +3 -10
- package/es/interface/stage.js.map +1 -1
- package/es/interface/window.d.ts +0 -12
- package/es/interface/window.js.map +1 -1
- package/es/picker/contributions/canvas-picker/symbol-picker.js +1 -6
- package/es/picker/contributions/canvas-picker/symbol-picker.js.map +1 -1
- package/es/picker/pick-interceptor.js +3 -2
- package/es/picker/pick-interceptor.js.map +1 -1
- package/es/plugins/builtin-plugin/flex-layout-plugin.d.ts +0 -2
- package/es/plugins/builtin-plugin/flex-layout-plugin.js +20 -47
- package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/es/plugins/plugin-modules.js +2 -2
- package/es/plugins/plugin-modules.js.map +1 -1
- package/es/render/contributions/render/area-render.js +30 -20
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js +0 -27
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.d.ts +1 -3
- package/es/render/contributions/render/draw-contribution.js +0 -4
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/image-render.js +2 -10
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/line-render.js +49 -22
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +5 -12
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/utils.d.ts +2 -2
- package/es/render/contributions/render/utils.js.map +1 -1
- package/es/render/render-service.js +1 -3
- package/es/render/render-service.js.map +1 -1
- package/package.json +13 -10
- package/cjs/graphic/builtin-symbol/arrow2-down.d.ts +0 -12
- package/cjs/graphic/builtin-symbol/arrow2-down.js +0 -30
- package/cjs/graphic/builtin-symbol/arrow2-down.js.map +0 -1
- package/cjs/graphic/builtin-symbol/arrow2-up.d.ts +0 -12
- package/cjs/graphic/builtin-symbol/arrow2-up.js +0 -30
- package/cjs/graphic/builtin-symbol/arrow2-up.js.map +0 -1
- package/cjs/graphic/builtin-symbol/close.d.ts +0 -13
- package/cjs/graphic/builtin-symbol/close.js +0 -33
- package/cjs/graphic/builtin-symbol/close.js.map +0 -1
- package/cjs/graphic/builtin-symbol/line-h.d.ts +0 -13
- package/cjs/graphic/builtin-symbol/line-h.js +0 -32
- package/cjs/graphic/builtin-symbol/line-h.js.map +0 -1
- package/cjs/graphic/builtin-symbol/line-v.d.ts +0 -13
- package/cjs/graphic/builtin-symbol/line-v.js +0 -32
- package/cjs/graphic/builtin-symbol/line-v.js.map +0 -1
- package/cjs/jsx/graphicType.d.ts +0 -172
- package/cjs/jsx/graphicType.js +0 -133
- package/cjs/jsx/graphicType.js.map +0 -1
- package/cjs/jsx/index.d.ts +0 -2
- package/cjs/jsx/index.js +0 -21
- package/cjs/jsx/index.js.map +0 -1
- package/cjs/jsx/jsx-classic.d.ts +0 -3
- package/cjs/jsx/jsx-classic.js +0 -58
- package/cjs/jsx/jsx-classic.js.map +0 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.d.ts +0 -13
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +0 -79
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +0 -1
- package/es/graphic/builtin-symbol/arrow2-down.d.ts +0 -12
- package/es/graphic/builtin-symbol/arrow2-down.js +0 -24
- package/es/graphic/builtin-symbol/arrow2-down.js.map +0 -1
- package/es/graphic/builtin-symbol/arrow2-up.d.ts +0 -12
- package/es/graphic/builtin-symbol/arrow2-up.js +0 -24
- package/es/graphic/builtin-symbol/arrow2-up.js.map +0 -1
- package/es/graphic/builtin-symbol/close.d.ts +0 -13
- package/es/graphic/builtin-symbol/close.js +0 -27
- package/es/graphic/builtin-symbol/close.js.map +0 -1
- package/es/graphic/builtin-symbol/line-h.d.ts +0 -13
- package/es/graphic/builtin-symbol/line-h.js +0 -26
- package/es/graphic/builtin-symbol/line-h.js.map +0 -1
- package/es/graphic/builtin-symbol/line-v.d.ts +0 -13
- package/es/graphic/builtin-symbol/line-v.js +0 -26
- package/es/graphic/builtin-symbol/line-v.js.map +0 -1
- package/es/jsx/graphicType.d.ts +0 -172
- package/es/jsx/graphicType.js +0 -126
- package/es/jsx/graphicType.js.map +0 -1
- package/es/jsx/index.d.ts +0 -2
- package/es/jsx/index.js +0 -4
- package/es/jsx/index.js.map +0 -1
- package/es/jsx/jsx-classic.d.ts +0 -3
- package/es/jsx/jsx-classic.js +0 -56
- package/es/jsx/jsx-classic.js.map +0 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.d.ts +0 -13
- package/es/plugins/builtin-plugin/html-attribute-plugin.js +0 -75
- package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +0 -1
package/es/graphic/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/tools.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAoB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG1D,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,OAAiB;IAC/D,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAIxC,CAAC;AAED,MAAM,UAAgB,mBAAmB,CAAC,KAAa;;QACrD,MAAM,WAAW,GAAmB,EAAE,CAAC;QACvC,MAAM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,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC3E,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAe,CAAC;IACrC,IAAI,KAAK,EAAE;QACT,MAAM,CAAC,KAAK,GAAI,KAAa,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;KACtG;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","file":"tools.js","sourcesContent":["import { application } from '../application';\nimport type { IGraphic, IGroup, ILayer, IRichTextCharacter, IRichTextImageCharacter, IStage } from '../interface';\nimport { isArray, type IAABBBounds } from '@visactor/vutils';\nimport { XMLValidator, XMLParser } from 'fast-xml-parser';\n\n// 不触发外部的render\nexport function incrementalAddTo(group: IGroup, graphic: IGraphic) {\n group.incrementalAppendChild(graphic);\n // if (group.layer && group.layer.subLayers) {\n // // const subLayer = group.layer.subLayers.get(group._uid);\n // }\n}\n\nexport async function waitForAllSubLayers(stage: IStage) {\n const promiseList: Promise<any>[] = [];\n const layers = stage.getChildren() as ILayer[];\n await new Promise(resolve => {\n application.global.getRequestAnimationFrame()(() => {\n resolve(null);\n });\n });\n layers.forEach(l => {\n if (l.subLayers.size) {\n l.subLayers.forEach(sl => {\n if (sl.drawContribution && sl.drawContribution.hooks && sl.drawContribution.rendering) {\n promiseList.push(\n new Promise(resolve => {\n sl.drawContribution!.hooks!.completeDraw.tap('outWait', () => {\n sl.drawContribution!.hooks!.completeDraw.taps = sl.drawContribution!.hooks!.completeDraw.taps.filter(\n i => {\n return i.name !== 'outWait';\n }\n );\n resolve(null);\n });\n })\n );\n }\n });\n }\n });\n await Promise.all(promiseList);\n}\n\nexport function boundStroke(bounds: IAABBBounds, halfW: number, miter: boolean, pad = 0) {\n bounds.expand(halfW + (pad / 2 + (miter ? miterAdjustment(miter, halfW) : 0)));\n return bounds;\n}\n\nfunction miterAdjustment(miter: boolean, strokeWidth: number) {\n return miter ? strokeWidth : 0;\n}\n\n// function attachShadow(graphic: Graphic) {\n// graphic.shadowRoot = createShadowRoot(graphic);\n// graphic.addUpdateBoundTag();\n// return graphic.shadowRoot;\n// }\n\n// function detachShadow(graphic: Graphic) {\n// if (graphic.shadowRoot) {\n// graphic.addUpdateBoundTag();\n// graphic.shadowRoot = null;\n// }\n// }\n\nlet NUMBER_TYPE: number = 0;\nexport function genNumberType() {\n return NUMBER_TYPE++;\n}\n\nexport enum TextDirection {\n HORIZONTAL = 0,\n VERTICAL = 1\n}\nexport function verticalLayout(text: string) {\n const nextCharacter: { text: string; direction: TextDirection }[] = [];\n let flag = 0; // 0: 竖排,1: 旋转\n let currStr = '';\n for (let i = 0; i < text.length; i++) {\n if (rotateText(text[i])) {\n if (flag) {\n currStr += text[i];\n } else {\n flag = 1;\n currStr = text[i];\n }\n } else {\n if (flag) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n currStr = '';\n flag = 0;\n }\n nextCharacter.push({\n text: text[i],\n direction: TextDirection.HORIZONTAL\n });\n }\n }\n\n if (currStr) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n }\n return nextCharacter;\n}\n\n// ——, ……, (, )\nconst rotateCharList = ['…', '(', ')', '—', '【', '】', '「', '」', '《', '》'];\nconst rotateCharMap = new Map();\nrotateCharList.forEach(c => rotateCharMap.set(c, true));\nconst noRotateCharList = [''];\nconst noRotateCharMap = new Map();\nnoRotateCharList.forEach(c => noRotateCharMap.set(c, true));\n\nfunction rotateText(c: string) {\n if (rotateCharMap.has(c)) {\n return true;\n }\n if (noRotateCharMap.has(c)) {\n return false;\n }\n const cp = c.codePointAt(0);\n let rotate = false;\n // 默认ascii码就旋转\n if (cp < 256) {\n rotate = true;\n }\n return rotate;\n}\n\nexport function xul(str: string | string[]): IRichTextCharacter[] {\n const xmlStr = isArray(str) ? str[0] : str;\n const config: IRichTextCharacter[] = [];\n if (!xmlStr) {\n return config;\n }\n const isXML = XMLValidator.validate(xmlStr, {\n allowBooleanAttributes: true\n });\n if (isXML === true) {\n const parser = new XMLParser({ ignoreAttributes: false });\n const data = parser.parse(xmlStr);\n data.tc &&\n Object.keys(data.tc).forEach(k => {\n if (k === 'text') {\n config.push(parseRTTextXML(data.tc[k]));\n } else {\n config.push(parseRTImageXML(data.tc[k]));\n }\n });\n }\n return config;\n}\n\nfunction parseRTTextXML(str: string): IRichTextCharacter {\n const output: IRichTextCharacter = { text: '' };\n parseCommonXML(str, output);\n const inlineText = str['#text'];\n if (inlineText) {\n output.text = inlineText;\n }\n\n return output;\n}\n\nfunction parseCommonXML(str: string, output: IRichTextCharacter) {\n const attr = str['@_attribute'];\n if (attr) {\n const attrList = attr.split(';');\n attrList.forEach((attrItem: string) => {\n if (!attrItem) {\n return;\n }\n const kv = attrItem.split(':');\n\n if (kv.length === 2) {\n const val = parseFloat(kv[1]);\n output[kv[0].trim()] = isFinite(val) ? val : kv[1].trim();\n } else {\n let val = '';\n for (let i = 1; i < kv.length; i++) {\n if (i > 1) {\n val += ':';\n }\n val += kv[i].trim();\n }\n output[kv[0].trim()] = val;\n }\n });\n }\n}\n\nfunction parseRTImageXML(str: string): IRichTextCharacter {\n const output: IRichTextImageCharacter = { image: '', width: 0, height: 0 };\n parseCommonXML(str, output);\n const image = output.image as string;\n if (image) {\n output.image = (image as any).replaceAll('"', '\"').replaceAll('<', '<').replaceAll('>', '>');\n }\n return output;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/tools.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK7C,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,OAAiB;IAC/D,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AA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,MAAM,GAAG,KAAK,CAAC;IAEnB,IAAI,EAAE,GAAG,GAAG,EAAE;QACZ,MAAM,GAAG,IAAI,CAAC;KACf;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","file":"tools.js","sourcesContent":["import { application } from '../application';\nimport type { IGraphic, IGroup, ILayer, IStage } from '../interface';\nimport type { IAABBBounds } from '@visactor/vutils';\n\n// 不触发外部的render\nexport function incrementalAddTo(group: IGroup, graphic: IGraphic) {\n group.incrementalAppendChild(graphic);\n // if (group.layer && group.layer.subLayers) {\n // // const subLayer = group.layer.subLayers.get(group._uid);\n // }\n}\n\nexport async function waitForAllSubLayers(stage: IStage) {\n const promiseList: Promise<any>[] = [];\n const layers = stage.getChildren() as ILayer[];\n await new Promise(resolve => {\n application.global.getRequestAnimationFrame()(() => {\n resolve(null);\n });\n });\n layers.forEach(l => {\n if (l.subLayers.size) {\n l.subLayers.forEach(sl => {\n if (sl.drawContribution && sl.drawContribution.hooks && sl.drawContribution.rendering) {\n promiseList.push(\n new Promise(resolve => {\n sl.drawContribution!.hooks!.completeDraw.tap('outWait', () => {\n sl.drawContribution!.hooks!.completeDraw.taps = sl.drawContribution!.hooks!.completeDraw.taps.filter(\n i => {\n return i.name !== 'outWait';\n }\n );\n resolve(null);\n });\n })\n );\n }\n });\n }\n });\n await Promise.all(promiseList);\n}\n\nexport function boundStroke(bounds: IAABBBounds, halfW: number, miter: boolean, pad = 0) {\n bounds.expand(halfW + (pad / 2 + (miter ? miterAdjustment(miter, halfW) : 0)));\n return bounds;\n}\n\nfunction miterAdjustment(miter: boolean, strokeWidth: number) {\n return miter ? strokeWidth : 0;\n}\n\n// function attachShadow(graphic: Graphic) {\n// graphic.shadowRoot = createShadowRoot(graphic);\n// graphic.addUpdateBoundTag();\n// return graphic.shadowRoot;\n// }\n\n// function detachShadow(graphic: Graphic) {\n// if (graphic.shadowRoot) {\n// graphic.addUpdateBoundTag();\n// graphic.shadowRoot = null;\n// }\n// }\n\nlet NUMBER_TYPE: number = 0;\nexport function genNumberType() {\n return NUMBER_TYPE++;\n}\n\nexport enum TextDirection {\n HORIZONTAL = 0,\n VERTICAL = 1\n}\nexport function verticalLayout(text: string) {\n const nextCharacter: { text: string; direction: TextDirection }[] = [];\n let flag = 0; // 0: 竖排,1: 旋转\n let currStr = '';\n for (let i = 0; i < text.length; i++) {\n if (rotateText(text[i])) {\n if (flag) {\n currStr += text[i];\n } else {\n flag = 1;\n currStr = text[i];\n }\n } else {\n if (flag) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n currStr = '';\n flag = 0;\n }\n nextCharacter.push({\n text: text[i],\n direction: TextDirection.HORIZONTAL\n });\n }\n }\n\n if (currStr) {\n nextCharacter.push({\n text: currStr,\n direction: TextDirection.VERTICAL\n });\n }\n return nextCharacter;\n}\n\n// ——, ……, (, )\nconst rotateCharList = ['…', '(', ')', '—', '【', '】', '「', '」', '《', '》'];\nconst rotateCharMap = new Map();\nrotateCharList.forEach(c => rotateCharMap.set(c, true));\nconst noRotateCharList = [''];\nconst noRotateCharMap = new Map();\nnoRotateCharList.forEach(c => noRotateCharMap.set(c, true));\n\nfunction rotateText(c: string) {\n if (rotateCharMap.has(c)) {\n return true;\n }\n if (noRotateCharMap.has(c)) {\n return false;\n }\n const cp = c.codePointAt(0);\n let rotate = false;\n // 默认ascii码就旋转\n if (cp < 256) {\n rotate = true;\n }\n return rotate;\n}\n"]}
|
package/es/graphic/wrap-text.js
CHANGED
|
@@ -17,16 +17,14 @@ export class WrapText extends Text {
|
|
|
17
17
|
}
|
|
18
18
|
updateMultilineAABBBounds(text) {
|
|
19
19
|
var _a, _b, _c;
|
|
20
|
-
const textTheme = getTheme(this).text, {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, lineHeight: lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth,
|
|
20
|
+
const textTheme = getTheme(this).text, {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, lineHeight: lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth, heightLimit: heightLimit = 0, lineClamp: lineClamp} = this.attribute;
|
|
21
21
|
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
22
22
|
const bbox = this.cache.layoutData.bbox;
|
|
23
23
|
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
|
|
24
24
|
stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
25
25
|
}
|
|
26
26
|
const textMeasure = application.graphicUtil.textMeasure, layoutObj = new CanvasTextLayout(fontFamily, {
|
|
27
|
-
fontSize: fontSize
|
|
28
|
-
fontWeight: fontWeight,
|
|
29
|
-
fontFamily: fontFamily
|
|
27
|
+
fontSize: fontSize
|
|
30
28
|
}, textMeasure), lines = text.map((l => l.toString())), linesLayout = [], bboxWH = [ 0, 0 ];
|
|
31
29
|
let lineCountLimit = 1 / 0;
|
|
32
30
|
if (heightLimit > 0 && (lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1)),
|
|
@@ -35,17 +33,17 @@ export class WrapText extends Text {
|
|
|
35
33
|
const str = lines[i];
|
|
36
34
|
let needCut = !0;
|
|
37
35
|
if (i === lineCountLimit - 1) {
|
|
38
|
-
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis
|
|
36
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);
|
|
39
37
|
linesLayout.push({
|
|
40
38
|
str: clip.str,
|
|
41
39
|
width: clip.width
|
|
42
40
|
});
|
|
43
41
|
break;
|
|
44
42
|
}
|
|
45
|
-
const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth
|
|
43
|
+
const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth);
|
|
46
44
|
if ("" !== str && "" === clip.str) {
|
|
47
45
|
if (ellipsis) {
|
|
48
|
-
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis
|
|
46
|
+
const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);
|
|
49
47
|
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
50
48
|
} else clip.str = "", clip.width = 0;
|
|
51
49
|
needCut = !1;
|
|
@@ -66,14 +64,14 @@ export class WrapText extends Text {
|
|
|
66
64
|
let width, text, lineWidth = 0;
|
|
67
65
|
for (let i = 0, len = lines.length; i < len; i++) {
|
|
68
66
|
if (i === lineCountLimit - 1) {
|
|
69
|
-
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis
|
|
67
|
+
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis);
|
|
70
68
|
linesLayout.push({
|
|
71
69
|
str: clip.str,
|
|
72
70
|
width: clip.width
|
|
73
71
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
74
72
|
break;
|
|
75
73
|
}
|
|
76
|
-
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions
|
|
74
|
+
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions),
|
|
77
75
|
lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
78
76
|
str: text,
|
|
79
77
|
width: width
|
|
@@ -81,7 +79,7 @@ export class WrapText extends Text {
|
|
|
81
79
|
}
|
|
82
80
|
bboxWH[0] = lineWidth;
|
|
83
81
|
}
|
|
84
|
-
bboxWH[1] = linesLayout.length * (lineHeight +
|
|
82
|
+
bboxWH[1] = linesLayout.length * (lineHeight + 2);
|
|
85
83
|
const bbox = {
|
|
86
84
|
xOffset: 0,
|
|
87
85
|
yOffset: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAAM,OAAO,QAAS,SAAQ,IAAI;IAGtB,QAAQ;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,OAAO,CAAE,IAAc,CAAC,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;IACrC,CAAC;IAOD,yBAAyB,CAAC,IAAyB;;QACjD,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;QACtC,MAAM,EACJ,UAAU,GAAG,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G,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = getTheme(this).text;\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n wordBreak = textTheme.wordBreak,\n fontWeight = textTheme.fontWeight,\n // widthLimit,\n ignoreBuf = textTheme.ignoreBuf,\n heightLimit = 0,\n lineClamp\n } = this.attribute;\n const buf = ignoreBuf ? 0 : 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n wordBreak === 'break-word'\n );\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAAM,OAAO,QAAS,SAAQ,IAAI;IAGtB,QAAQ;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,OAAO,CAAE,IAAc,CAAC,KAAK,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;IACrC,CAAC;IAOD,yBAAyB,CAAC,IAAyB;;QACjD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ACb;SACF;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACF","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = getTheme(this).text;\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n // widthLimit,\n heightLimit = 0,\n lineClamp\n } = this.attribute;\n const buf = 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis);\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth);\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions);\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n}\n"]}
|
package/es/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'core-js/proposals/reflect-metadata';
|
|
2
2
|
import './modules';
|
|
3
|
-
export declare const version = "0.15.0-alpha.
|
|
3
|
+
export declare const version = "0.15.0-alpha.16";
|
|
4
4
|
export * from './container';
|
|
5
5
|
export * from './core/global';
|
|
6
6
|
export * from './graphic';
|
|
@@ -40,4 +40,3 @@ export * from './common/generator';
|
|
|
40
40
|
export * from './plugins/constants';
|
|
41
41
|
export * from './animate/default-ticker';
|
|
42
42
|
export { wrapCanvas, wrapContext } from './canvas/util';
|
|
43
|
-
export * from './jsx';
|
package/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import "core-js/proposals/reflect-metadata";
|
|
|
2
2
|
|
|
3
3
|
import "./modules";
|
|
4
4
|
|
|
5
|
-
export const version = "0.15.0-alpha.
|
|
5
|
+
export const version = "0.15.0-alpha.16";
|
|
6
6
|
|
|
7
7
|
export * from "./container";
|
|
8
8
|
|
|
@@ -81,6 +81,4 @@ export * from "./plugins/constants";
|
|
|
81
81
|
export * from "./animate/default-ticker";
|
|
82
82
|
|
|
83
83
|
export { wrapCanvas, wrapContext } from "./canvas/util";
|
|
84
|
-
|
|
85
|
-
export * from "./jsx";
|
|
86
84
|
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAC;AAC5C,OAAO,WAAW,CAAC;AAGnB,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AA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B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,2CAA2C,CAAC;AAC1D,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,0BAA0B,CAAC;AAGzC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AAEpC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","file":"index.js","sourcesContent":["import 'core-js/proposals/reflect-metadata';\nimport './modules';\n\n// 导出版本号\nexport const version = \"0.15.0-alpha.16\";\n\nexport * from './container';\nexport * from './core/global';\nexport * from './graphic';\nexport * from './modules';\nexport * from './create';\nexport * from './event';\nexport * from './interface';\nexport * from './render';\nexport * from './render/contributions/render/base-render';\nexport * from './canvas';\nexport * from './core';\nexport * from './picker';\nexport * from './kits';\nexport * from './animate';\nexport * from './resource-loader/loader';\n\n/* export common */\nexport * from './common/text';\nexport * from './common/bezier-utils';\nexport * from './common/bounds-context';\nexport * from './common/seg-context';\nexport * from './common/custom-path2d';\nexport * from './common/segment';\nexport * from './common/canvas-utils';\nexport * from './common/contribution-provider';\nexport * from './common/generator';\nexport * from './common/utils';\nexport * from './common/shape/arc';\nexport * from './common/shape/rect';\n\nexport * from './common/path-svg';\nexport * from './common/render-curve';\nexport * from './common/render-area';\nexport * from './common/render-command-list';\nexport * from './common/sort';\nexport * from './common/morphing-utils';\nexport * from './common/split-path';\nexport * from './common/enums';\nexport * from './common/generator';\nexport * from './plugins/constants';\n\nexport * from './animate/default-ticker';\nexport { wrapCanvas, wrapContext } from './canvas/util';\n"]}
|
|
@@ -101,7 +101,6 @@ export interface IAnimate {
|
|
|
101
101
|
_onRemove?: (() => void)[];
|
|
102
102
|
getStartProps: () => Record<string, any>;
|
|
103
103
|
getEndProps: () => Record<string, any>;
|
|
104
|
-
setTimeline: (timeline: ITimeline) => void;
|
|
105
104
|
bind: (target: IAnimateTarget) => this;
|
|
106
105
|
to: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;
|
|
107
106
|
from: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;
|
|
@@ -158,7 +157,7 @@ export interface ITimeline {
|
|
|
158
157
|
id: number;
|
|
159
158
|
animateCount: number;
|
|
160
159
|
addAnimate: (animate: IAnimate) => void;
|
|
161
|
-
removeAnimate: (animate: IAnimate
|
|
160
|
+
removeAnimate: (animate: IAnimate) => void;
|
|
162
161
|
tick: (delta: number) => void;
|
|
163
162
|
clear: () => void;
|
|
164
163
|
pause: () => void;
|
|
@@ -187,5 +186,4 @@ export interface ITicker {
|
|
|
187
186
|
resume: () => boolean;
|
|
188
187
|
start: (force?: boolean) => boolean;
|
|
189
188
|
stop: () => void;
|
|
190
|
-
addTimeline: (timeline: ITimeline) => void;
|
|
191
189
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { AnimateMode, AnimateStatus, AnimateStepType } from '../common/enums';\nimport type { Releaseable } from './common';\nimport type { IGraphic } from './graphic';\n\n// export type EasingType = (...args: any) => any;\n\nexport declare class Easing {\n static linear(t: number): number;\n static none(): typeof Easing.linear;\n /**\n * 获取缓动函数,amount指示这个缓动函数的插值方式\n * @param amount\n * @returns\n */\n static get(amount: number): (t: number) => number;\n static getPowIn(pow: number): (t: number) => number;\n static getPowOut(pow: number): (t: number) => number;\n static getPowInOut(pow: number): (t: number) => number;\n static quadIn: (t: number) => number;\n static quadOut: (t: number) => number;\n static quadInOut: (t: number) => number;\n static cubicIn: (t: number) => number;\n static cubicOut: (t: number) => number;\n static cubicInOut: (t: number) => number;\n static quartIn: (t: number) => number;\n static quartOut: (t: number) => number;\n static quartInOut: (t: number) => number;\n static quintIn: (t: number) => number;\n static quintOut: (t: number) => number;\n static quintInOut: (t: number) => number;\n static getBackIn(amount: number): (t: number) => number;\n static getBackOut(amount: number): (t: number) => number;\n static getBackInOut(amount: number): (t: number) => number;\n static backIn: (t: number) => number;\n static backOut: (t: number) => number;\n static backInOut: (t: number) => number;\n static circIn(t: number): number;\n static circOut(t: number): number;\n static circInOut(t: number): number;\n static bounceOut(t: number): number;\n static bounceIn(t: number): number;\n static bounceInOut(t: number): number;\n static getElasticIn(amplitude: number, period: number): (t: number) => number;\n static getElasticOut(amplitude: number, period: number): (t: number) => number;\n static getElasticInOut(amplitude: number, period: number): (t: number) => number;\n static elasticIn: (t: number) => number;\n static elasticOut: (t: number) => number;\n static elasticInOut: (t: number) => number;\n}\n\n// timeline管理一堆的animate,多个timeline互不影响\n// timeline主要作用是基于layer层面的整体管理\n// 每个layer默认带有一个timeline\nexport interface Timeline {\n AnimateList: IAnimate[];\n}\n\ntype IStopType = 'end' | 'start' | 'current';\n\n// TODO: 提供options配置可序列化\ninterface AnimateSpecItem {\n type: 'to' | 'delay' | 'stop' | 'any';\n params: any[];\n}\n\nexport type EasingTypeStr =\n | 'linear'\n | 'quadIn'\n | 'quadOut'\n | 'quadInOut'\n | 'quadInOut'\n | 'cubicIn'\n | 'cubicOut'\n | 'cubicInOut'\n | 'quartIn'\n | 'quartOut'\n | 'quartInOut'\n | 'quintIn'\n | 'quintOut'\n | 'quintInOut'\n | 'backIn'\n | 'backOut'\n | 'backInOut'\n | 'circIn'\n | 'circOut'\n | 'circInOut'\n | 'bounceOut'\n | 'bounceIn'\n | 'bounceInOut'\n | 'elasticIn'\n | 'elasticOut'\n | 'elasticInOut'\n | 'sineIn'\n | 'sineOut'\n | 'sineInOut'\n | 'expoIn'\n | 'expoOut'\n | 'expoInOut'\n | '';\nexport type EasingTypeFunc = (t: number) => number;\n\nexport type EasingType = EasingTypeStr | EasingTypeFunc;\n\nexport type IAnimateStepType = keyof typeof AnimateStepType;\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 在animate中的位置\n position: number;\n next?: IStep;\n props?: any;\n parsedProps?: any;\n propKeys?: string[];\n easing?: EasingTypeFunc;\n customAnimate?: ICustomAnimate;\n\n append: (step: IStep) => void;\n getLastProps: () => any;\n}\n\nexport interface IStepConfig {\n tempProps?: boolean; // props为临时props,可以直接使用不用拷贝\n noPreventAttrs?: boolean;\n}\n\nexport interface IAnimateTarget {\n onAnimateBind?: (animte: IAnimate | ISubAnimate) => void;\n // 添加动画step的时候调用\n onAddStep?: (step: IStep) => void;\n // step时调用\n onStep: (subAnimate: ISubAnimate, animate: IAnimate, step: IStep, ratio: number, end: boolean) => void;\n // 插值函数\n stepInterpolate: (\n subAnimate: ISubAnimate,\n animate: IAnimate,\n nextAttributes: Record<string, any>,\n step: IStep,\n ratio: number,\n end: boolean,\n nextProps: Record<string, any>,\n lastProps?: Record<string, any>,\n nextParsedProps?: any,\n propKeys?: string[]\n ) => void;\n // 获取属性\n getComputedAttribute: (name: string) => any;\n // 获取默认属性\n getDefaultAttribute: (name: string) => any;\n onStop: (props?: Record<string, any>) => void;\n animates: Map<string | number, IAnimate>;\n [key: string]: any;\n}\n\nexport interface ICustomAnimate {\n duration: number;\n easing: EasingType;\n step?: IStep;\n mode?: AnimateMode;\n\n bind: (target: IAnimateTarget, subAni: ISubAnimate) => void;\n // 在第一次调用的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: () => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n}\n\n// 每一个animate绑定一个graphic,用于描述这个graphic的动画内容\n// 在timeline层面,animate相当于是一段timeslice\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n\n interpolateFunc: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n getStartProps: () => Record<string, any>;\n getEndProps: () => Record<string, any>;\n\n setTimeline: (timeline: ITimeline) => void;\n\n bind: (target: IAnimateTarget) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n pause: () => void;\n resume: () => void;\n onStart: (cb: () => void) => void;\n onEnd: (cb: () => void) => void;\n onFrame: (cb: (step: IStep, ratio: number) => void) => void;\n // 屏蔽属性\n preventAttr: (key: string) => void;\n // 屏蔽属性\n preventAttrs: (key: string[]) => void;\n // 属性是否合法\n validAttr: (key: string) => boolean;\n\n runCb: (cb: (a: IAnimate, step: IStep) => void) => IAnimate;\n\n // 自定义插值,返回false表示没有匹配上\n customInterpolate: (\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IAnimateTarget,\n ret: Record<string, any>\n ) => boolean;\n //\n play: (customAnimate: ICustomAnimate) => this;\n\n // 获取该属性的上一个值\n // getLastPropByName: (name: string, step: IStep) => any;\n // delay: (duration: number) => IAnimate;\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // done: (cb: (_: any) => any) => IAnimate;\n // pause: () => IAnimate;\n // spec: (spec: AnimateSpecItem[]) => IAnimate;\n // start: () => void; // 有start方法,避免动画提前开始(VGrammar需要时间处理数据)\n wait: (delay: number) => this;\n\n // // 编排\n afterAll: (list: IAnimate[]) => this;\n after: (animate: IAnimate) => this;\n parallel: (animate: IAnimate) => this;\n\n // // timislice (getter)\n // startTime: number;\n // endTime: number;\n // startTimes: number[];\n // endTimes: number[];\n\n // // 高级参数,frame到frameEnd之间可以进行reverse,loop,bounce效果\n // frame: () => IAnimate;\n // frameEnd: () => IAnimate;\n reversed: (r: boolean) => IAnimate;\n loop: (n: number) => IAnimate;\n bounce: (b: boolean) => IAnimate;\n\n nextAnimate?: IAnimate;\n prevAnimate?: IAnimate;\n\n advance: (delta: number) => void;\n\n startAt: (t: number) => IAnimate;\n\n // // 语法糖\n // create: (duration: number) => IAnimate;\n // fadeIn: (duration: number) => IAnimate;\n}\n\nexport interface ISubAnimate {\n getLastStep: () => IStep;\n animate: IAnimate;\n // 获取该属性的上一个值\n getLastPropByName: (name: string, step: IStep) => any;\n}\n\n// rect.animate().abc().to({}, 1000).delay(1000).frame().to().delay().to().frameEnd().loop().bounce()\n\nexport interface BaseAnimateConfig {\n id?: number | string;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n}\n\n// VGrammar和 vrender命名不一致,好尴尬\nexport interface MorphingAnimateConfig extends Omit<BaseAnimateConfig, 'interpolate'> {\n duration?: number;\n easing?: EasingType; // 统一到easing\n delay?: number;\n}\n\nexport interface MultiMorphingAnimateConfig extends MorphingAnimateConfig {\n splitPath?: 'clone' | ((graphic: IGraphic, count: number, needAppend?: boolean) => IGraphic[]);\n individualDelay?: (index: number, count: number, fromGraphic: IGraphic, toGraphic: IGraphic) => number;\n}\n\nexport interface ITimeline {\n id: number;\n animateCount: number;\n addAnimate: (animate: IAnimate) => void;\n removeAnimate: (animate: IAnimate, release?: boolean) => void;\n tick: (delta: number) => void;\n clear: () => void;\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ITickHandler extends Releaseable {\n avaliable: () => boolean;\n /**\n * 开始执行tick\n * @param interval 延时 ms\n * @param cb 执行的回调\n */\n tick: (interval: number, cb: (handler: ITickHandler) => void) => void; // 开始\n tickTo?: (t: number, cb: (handler: ITickHandler, params?: { once: boolean }) => void) => void;\n getTime: () => number; // 获取时间\n}\n\nexport interface ITickerHandlerStatic {\n Avaliable: () => boolean;\n new (): ITickHandler;\n}\n\nexport interface ITicker {\n setFPS?: (fps: number) => void;\n setInterval?: (interval: number) => void;\n getFPS?: () => number;\n getInterval?: () => number;\n tick: (interval: number) => void;\n tickAt?: (time: number) => void;\n pause: () => boolean;\n resume: () => boolean;\n /**\n * 开启tick,force为true强制开启,否则如果timeline为空则不开启\n */\n start: (force?: boolean) => boolean;\n stop: () => void;\n addTimeline: (timeline: ITimeline) => void;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/animate.ts"],"names":[],"mappings":"","file":"animate.js","sourcesContent":["import type { AnimateMode, AnimateStatus, AnimateStepType } from '../common/enums';\nimport type { Releaseable } from './common';\nimport type { IGraphic } from './graphic';\n\n// export type EasingType = (...args: any) => any;\n\nexport declare class Easing {\n static linear(t: number): number;\n static none(): typeof Easing.linear;\n /**\n * 获取缓动函数,amount指示这个缓动函数的插值方式\n * @param amount\n * @returns\n */\n static get(amount: number): (t: number) => number;\n static getPowIn(pow: number): (t: number) => number;\n static getPowOut(pow: number): (t: number) => number;\n static getPowInOut(pow: number): (t: number) => number;\n static quadIn: (t: number) => number;\n static quadOut: (t: number) => number;\n static quadInOut: (t: number) => number;\n static cubicIn: (t: number) => number;\n static cubicOut: (t: number) => number;\n static cubicInOut: (t: number) => number;\n static quartIn: (t: number) => number;\n static quartOut: (t: number) => number;\n static quartInOut: (t: number) => number;\n static quintIn: (t: number) => number;\n static quintOut: (t: number) => number;\n static quintInOut: (t: number) => number;\n static getBackIn(amount: number): (t: number) => number;\n static getBackOut(amount: number): (t: number) => number;\n static getBackInOut(amount: number): (t: number) => number;\n static backIn: (t: number) => number;\n static backOut: (t: number) => number;\n static backInOut: (t: number) => number;\n static circIn(t: number): number;\n static circOut(t: number): number;\n static circInOut(t: number): number;\n static bounceOut(t: number): number;\n static bounceIn(t: number): number;\n static bounceInOut(t: number): number;\n static getElasticIn(amplitude: number, period: number): (t: number) => number;\n static getElasticOut(amplitude: number, period: number): (t: number) => number;\n static getElasticInOut(amplitude: number, period: number): (t: number) => number;\n static elasticIn: (t: number) => number;\n static elasticOut: (t: number) => number;\n static elasticInOut: (t: number) => number;\n}\n\n// timeline管理一堆的animate,多个timeline互不影响\n// timeline主要作用是基于layer层面的整体管理\n// 每个layer默认带有一个timeline\nexport interface Timeline {\n AnimateList: IAnimate[];\n}\n\ntype IStopType = 'end' | 'start' | 'current';\n\n// TODO: 提供options配置可序列化\ninterface AnimateSpecItem {\n type: 'to' | 'delay' | 'stop' | 'any';\n params: any[];\n}\n\nexport type EasingTypeStr =\n | 'linear'\n | 'quadIn'\n | 'quadOut'\n | 'quadInOut'\n | 'quadInOut'\n | 'cubicIn'\n | 'cubicOut'\n | 'cubicInOut'\n | 'quartIn'\n | 'quartOut'\n | 'quartInOut'\n | 'quintIn'\n | 'quintOut'\n | 'quintInOut'\n | 'backIn'\n | 'backOut'\n | 'backInOut'\n | 'circIn'\n | 'circOut'\n | 'circInOut'\n | 'bounceOut'\n | 'bounceIn'\n | 'bounceInOut'\n | 'elasticIn'\n | 'elasticOut'\n | 'elasticInOut'\n | 'sineIn'\n | 'sineOut'\n | 'sineInOut'\n | 'expoIn'\n | 'expoOut'\n | 'expoInOut'\n | '';\nexport type EasingTypeFunc = (t: number) => number;\n\nexport type EasingType = EasingTypeStr | EasingTypeFunc;\n\nexport type IAnimateStepType = keyof typeof AnimateStepType;\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 在animate中的位置\n position: number;\n next?: IStep;\n props?: any;\n parsedProps?: any;\n propKeys?: string[];\n easing?: EasingTypeFunc;\n customAnimate?: ICustomAnimate;\n\n append: (step: IStep) => void;\n getLastProps: () => any;\n}\n\nexport interface IStepConfig {\n tempProps?: boolean; // props为临时props,可以直接使用不用拷贝\n noPreventAttrs?: boolean;\n}\n\nexport interface IAnimateTarget {\n onAnimateBind?: (animte: IAnimate | ISubAnimate) => void;\n // 添加动画step的时候调用\n onAddStep?: (step: IStep) => void;\n // step时调用\n onStep: (subAnimate: ISubAnimate, animate: IAnimate, step: IStep, ratio: number, end: boolean) => void;\n // 插值函数\n stepInterpolate: (\n subAnimate: ISubAnimate,\n animate: IAnimate,\n nextAttributes: Record<string, any>,\n step: IStep,\n ratio: number,\n end: boolean,\n nextProps: Record<string, any>,\n lastProps?: Record<string, any>,\n nextParsedProps?: any,\n propKeys?: string[]\n ) => void;\n // 获取属性\n getComputedAttribute: (name: string) => any;\n // 获取默认属性\n getDefaultAttribute: (name: string) => any;\n onStop: (props?: Record<string, any>) => void;\n animates: Map<string | number, IAnimate>;\n [key: string]: any;\n}\n\nexport interface ICustomAnimate {\n duration: number;\n easing: EasingType;\n step?: IStep;\n mode?: AnimateMode;\n\n bind: (target: IAnimateTarget, subAni: ISubAnimate) => void;\n // 在第一次调用的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: () => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n}\n\n// 每一个animate绑定一个graphic,用于描述这个graphic的动画内容\n// 在timeline层面,animate相当于是一段timeslice\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n\n interpolateFunc: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n\n _onStart?: (() => void)[];\n _onFrame?: ((step: IStep, ratio: number) => void)[];\n _onEnd?: (() => void)[];\n _onRemove?: (() => void)[];\n\n getStartProps: () => Record<string, any>;\n getEndProps: () => Record<string, any>;\n\n bind: (target: IAnimateTarget) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType, params?: IStepConfig) => this;\n pause: () => void;\n resume: () => void;\n onStart: (cb: () => void) => void;\n onEnd: (cb: () => void) => void;\n onFrame: (cb: (step: IStep, ratio: number) => void) => void;\n // 屏蔽属性\n preventAttr: (key: string) => void;\n // 屏蔽属性\n preventAttrs: (key: string[]) => void;\n // 属性是否合法\n validAttr: (key: string) => boolean;\n\n runCb: (cb: (a: IAnimate, step: IStep) => void) => IAnimate;\n\n // 自定义插值,返回false表示没有匹配上\n customInterpolate: (\n key: string,\n ratio: number,\n from: any,\n to: any,\n target: IAnimateTarget,\n ret: Record<string, any>\n ) => boolean;\n //\n play: (customAnimate: ICustomAnimate) => this;\n\n // 获取该属性的上一个值\n // getLastPropByName: (name: string, step: IStep) => any;\n // delay: (duration: number) => IAnimate;\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // done: (cb: (_: any) => any) => IAnimate;\n // pause: () => IAnimate;\n // spec: (spec: AnimateSpecItem[]) => IAnimate;\n // start: () => void; // 有start方法,避免动画提前开始(VGrammar需要时间处理数据)\n wait: (delay: number) => this;\n\n // // 编排\n afterAll: (list: IAnimate[]) => this;\n after: (animate: IAnimate) => this;\n parallel: (animate: IAnimate) => this;\n\n // // timislice (getter)\n // startTime: number;\n // endTime: number;\n // startTimes: number[];\n // endTimes: number[];\n\n // // 高级参数,frame到frameEnd之间可以进行reverse,loop,bounce效果\n // frame: () => IAnimate;\n // frameEnd: () => IAnimate;\n reversed: (r: boolean) => IAnimate;\n loop: (n: number) => IAnimate;\n bounce: (b: boolean) => IAnimate;\n\n nextAnimate?: IAnimate;\n prevAnimate?: IAnimate;\n\n advance: (delta: number) => void;\n\n startAt: (t: number) => IAnimate;\n\n // // 语法糖\n // create: (duration: number) => IAnimate;\n // fadeIn: (duration: number) => IAnimate;\n}\n\nexport interface ISubAnimate {\n getLastStep: () => IStep;\n animate: IAnimate;\n // 获取该属性的上一个值\n getLastPropByName: (name: string, step: IStep) => any;\n}\n\n// rect.animate().abc().to({}, 1000).delay(1000).frame().to().delay().to().frameEnd().loop().bounce()\n\nexport interface BaseAnimateConfig {\n id?: number | string;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n}\n\n// VGrammar和 vrender命名不一致,好尴尬\nexport interface MorphingAnimateConfig extends Omit<BaseAnimateConfig, 'interpolate'> {\n duration?: number;\n easing?: EasingType; // 统一到easing\n delay?: number;\n}\n\nexport interface MultiMorphingAnimateConfig extends MorphingAnimateConfig {\n splitPath?: 'clone' | ((graphic: IGraphic, count: number, needAppend?: boolean) => IGraphic[]);\n individualDelay?: (index: number, count: number, fromGraphic: IGraphic, toGraphic: IGraphic) => number;\n}\n\nexport interface ITimeline {\n id: number;\n animateCount: number;\n addAnimate: (animate: IAnimate) => void;\n removeAnimate: (animate: IAnimate) => void;\n tick: (delta: number) => void;\n clear: () => void;\n pause: () => void;\n resume: () => void;\n}\n\nexport interface ITickHandler extends Releaseable {\n avaliable: () => boolean;\n /**\n * 开始执行tick\n * @param interval 延时 ms\n * @param cb 执行的回调\n */\n tick: (interval: number, cb: (handler: ITickHandler) => void) => void; // 开始\n tickTo?: (t: number, cb: (handler: ITickHandler, params?: { once: boolean }) => void) => void;\n getTime: () => number; // 获取时间\n}\n\nexport interface ITickerHandlerStatic {\n Avaliable: () => boolean;\n new (): ITickHandler;\n}\n\nexport interface ITicker {\n setFPS?: (fps: number) => void;\n setInterval?: (interval: number) => void;\n getFPS?: () => number;\n getInterval?: () => number;\n tick: (interval: number) => void;\n tickAt?: (time: number) => void;\n pause: () => boolean;\n resume: () => boolean;\n /**\n * 开启tick,force为true强制开启,否则如果timeline为空则不开启\n */\n start: (force?: boolean) => boolean;\n stop: () => void;\n}\n"]}
|
package/es/interface/global.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Dict,
|
|
1
|
+
import type { Dict, IPointLike } from '@visactor/vutils';
|
|
2
2
|
import type { ICanvasLike } from './canvas';
|
|
3
3
|
import type { IEventElement } from './common';
|
|
4
4
|
import type { IContribution } from './contribution';
|
|
@@ -25,15 +25,6 @@ export interface IEnvContribution extends IContribution<IGlobal>, Omit<IEventEle
|
|
|
25
25
|
createCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;
|
|
26
26
|
createOffscreenCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;
|
|
27
27
|
releaseCanvas: (canvas: ICanvasLike | string | any) => void;
|
|
28
|
-
getNativeAABBBounds: (dom: string | HTMLElement | any) => IAABBBoundsLike;
|
|
29
|
-
removeDom: (dom: HTMLElement) => boolean;
|
|
30
|
-
createDom: (params: CreateDOMParamsType) => HTMLElement | null;
|
|
31
|
-
getElementTop: (dom: any, baseWindow?: boolean) => number;
|
|
32
|
-
getElementLeft: (dom: any, baseWindow?: boolean) => number;
|
|
33
|
-
getElementTopLeft: (dom: any, baseWindow?: boolean) => {
|
|
34
|
-
top: number;
|
|
35
|
-
left: number;
|
|
36
|
-
};
|
|
37
28
|
getDynamicCanvasCount: () => number;
|
|
38
29
|
getStaticCanvasCount: () => number;
|
|
39
30
|
getDevicePixelRatio: () => number;
|
|
@@ -87,13 +78,6 @@ export interface IEnvParamsMap {
|
|
|
87
78
|
readonly lynx: any;
|
|
88
79
|
readonly wx: any;
|
|
89
80
|
}
|
|
90
|
-
export type CreateDOMParamsType = {
|
|
91
|
-
tagName?: string;
|
|
92
|
-
width?: number;
|
|
93
|
-
height?: number;
|
|
94
|
-
style?: string | Record<string, any>;
|
|
95
|
-
parent?: string | HTMLElement;
|
|
96
|
-
};
|
|
97
81
|
export interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {
|
|
98
82
|
env: EnvType;
|
|
99
83
|
devicePixelRatio: number;
|
|
@@ -142,12 +126,4 @@ export interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'em
|
|
|
142
126
|
loadState: 'success' | 'fail';
|
|
143
127
|
data: Blob | null;
|
|
144
128
|
}>;
|
|
145
|
-
removeDom: (dom: HTMLElement) => boolean;
|
|
146
|
-
createDom: (params: CreateDOMParamsType) => HTMLElement | null;
|
|
147
|
-
getElementTop: (dom: any, baseWindow?: boolean) => number;
|
|
148
|
-
getElementLeft: (dom: any, baseWindow?: boolean) => number;
|
|
149
|
-
getElementTopLeft: (dom: any, baseWindow?: boolean) => {
|
|
150
|
-
top: number;
|
|
151
|
-
left: number;
|
|
152
|
-
};
|
|
153
129
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/global.ts"],"names":[],"mappings":"","file":"global.js","sourcesContent":["import type { Dict,
|
|
1
|
+
{"version":3,"sources":["../src/interface/global.ts"],"names":[],"mappings":"","file":"global.js","sourcesContent":["import type { Dict, IPointLike } from '@visactor/vutils';\nimport type { ICanvasLike } from './canvas';\nimport type { IEventElement } from './common';\nimport type { IContribution } from './contribution';\nimport type { ISyncHook } from './sync-hook';\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\n// 环境定义\nexport type EnvType = 'browser' | 'feishu' | 'tt' | 'taro' | 'node' | 'native' | 'lynx' | 'wx';\n\n// 创建canvas需要的参数\nexport interface ICreateCanvasParams {\n id?: string;\n // 像素宽\n width?: number;\n // 像素高\n height?: number;\n dpr?: number;\n}\n\nexport interface ILoader {\n loadImage: (url: string) => HTMLImageElement | ImageData;\n loadJson: (url: string) => JSON;\n}\n\nexport interface IEnvContribution\n extends IContribution<IGlobal>,\n Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n type: EnvType;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n // 开始配置环境,相当于init\n configure: (global: IGlobal, ...p: any) => void;\n\n // 创建销毁\n createCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => ICanvasLike | any;\n releaseCanvas: (canvas: ICanvasLike | string | any) => void;\n\n /**\n * 获取动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n /**\n * 获取静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n // 设备信息\n getDevicePixelRatio: () => number;\n\n // 通用接口\n getRequestAnimationFrame: () => (callback: FrameRequestCallback) => number;\n getCancelAnimationFrame: () => (h: number) => void;\n\n // DOM接口\n getElementById?: (str: string) => HTMLElement | null;\n getRootElement?: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument?: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint?: (event: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n}\n\nexport type IMiniAppEnvParams = {\n /** dom 容器对象 */\n domref?: Dict<any>;\n /**\n * 强行设置env,如果env重复设置也设置\n */\n force?: boolean;\n /**\n * 可用的canvas列表\n */\n canvasIdLists?: (string | number)[];\n /**\n * 表示可以自由使用的canvas索引\n */\n freeCanvasIdx?: string | number;\n /** taro 环境使用 */\n taro?: any;\n pixelRatio?: number;\n [key: string]: any;\n};\n\nexport interface IEnvParamsMap {\n readonly taro: IMiniAppEnvParams;\n readonly feishu: IMiniAppEnvParams;\n readonly tt: IMiniAppEnvParams;\n readonly browser: any;\n readonly node: any;\n readonly native: any;\n readonly lynx: any;\n readonly wx: any;\n}\nexport interface IGlobal extends Omit<IEventElement, 'on' | 'off' | 'once' | 'emit' | 'removeAllListeners'> {\n // 当前代码所运行的环境\n env: EnvType;\n\n // 设备的dpr\n devicePixelRatio: number;\n\n // 当设置env的时候被调用\n hooks: {\n onSetEnv: ISyncHook<[EnvType | undefined, EnvType, IGlobal]>;\n };\n\n // 设置env的时候传入的参数\n // node环境需要传入整个node-canvas包\n // 小程序环境需要传入小程序要用到的参数\n envParams?: any;\n\n // 是否支持事件\n // node环境不需要事件\n supportEvent: boolean;\n\n setEnv: (env: EnvType, params?: IEnvParamsMap[EnvType]) => void;\n setActiveEnvContribution: (contribution: IEnvContribution) => void;\n createCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n createOffscreenCanvas: (params: ICreateCanvasParams) => HTMLCanvasElement | any;\n releaseCanvas: (canvas: HTMLCanvasElement | string | any) => void;\n\n /**\n * 获取环境中最大动态canvas的数量,offscreenCanvas或者framebuffer\n */\n getDynamicCanvasCount: () => number;\n\n isChrome: () => boolean;\n isSafari: () => boolean;\n\n /**\n * 获取环境中最大静态canvas的数量,纯粹canvas\n */\n getStaticCanvasCount: () => number;\n\n /* 浏览器环境 - dom tree */\n getElementById: (str: string) => HTMLElement | null;\n getRootElement: () => HTMLElement | null;\n /**\n * get document instance\n */\n getDocument: () => Document | null;\n /**\n * whether supports TouchEvent.\n */\n supportsTouchEvents: boolean;\n /**\n * whether supports PointerEvent.\n */\n supportsPointerEvents: boolean;\n /**\n * whether supports MouseEvent.\n */\n supportsMouseEvents: boolean;\n /**\n * Whether to allow setting the cursor style\n */\n applyStyles?: boolean;\n /**\n * 测量文字的方法\n */\n measureTextMethod: 'native' | 'simple' | 'quick';\n\n getRequestAnimationFrame: () => null | ((callback: FrameRequestCallback) => number);\n getCancelAnimationFrame: () => null | ((h: number) => void);\n\n /**\n * 将窗口坐标转换为画布坐标,小程序/小组件环境需要兼容\n */\n mapToCanvasPoint: (nativeEvent: any, domElement?: any) => IPointLike | null;\n\n loadImage: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadSvg: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }>;\n loadJson: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Record<string, unknown> | null;\n }>;\n loadArrayBuffer: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: ArrayBuffer | null;\n }>;\n loadBlob: (url: string) => Promise<{\n loadState: 'success' | 'fail';\n data: Blob | null;\n }>;\n}\n"]}
|
|
@@ -6,7 +6,6 @@ export type IImageAttribute = {
|
|
|
6
6
|
repeatX: IRepeatType;
|
|
7
7
|
repeatY: IRepeatType;
|
|
8
8
|
image: string | HTMLImageElement | HTMLCanvasElement;
|
|
9
|
-
cornerRadius: number | number[];
|
|
10
9
|
};
|
|
11
10
|
export type IImageGraphicAttribute = Partial<IGraphicAttribute> & Partial<IImageAttribute>;
|
|
12
11
|
export interface IImage extends IGraphic<IImageGraphicAttribute> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/image.ts"],"names":[],"mappings":"","file":"image.js","sourcesContent":["import type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport type IRepeatType = 'no-repeat' | 'repeat';\n\nexport type IImageAttribute = {\n width: number;\n height: number;\n repeatX: IRepeatType;\n repeatY: IRepeatType;\n image: string | HTMLImageElement | HTMLCanvasElement;\n
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/image.ts"],"names":[],"mappings":"","file":"image.js","sourcesContent":["import type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport type IRepeatType = 'no-repeat' | 'repeat';\n\nexport type IImageAttribute = {\n width: number;\n height: number;\n repeatX: IRepeatType;\n repeatY: IRepeatType;\n image: string | HTMLImageElement | HTMLCanvasElement;\n};\n\nexport type IImageGraphicAttribute = Partial<IGraphicAttribute> & Partial<IImageAttribute>;\n\nexport interface IImage extends IGraphic<IImageGraphicAttribute> {\n successCallback?: () => void;\n failCallback?: () => void;\n}\n"]}
|
|
@@ -9,6 +9,7 @@ export type ILineAttribute = {
|
|
|
9
9
|
curveType: ICurveType;
|
|
10
10
|
clipRange: number;
|
|
11
11
|
clipRangeByDimension: IClipRangeByDimensionType;
|
|
12
|
+
closePath: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type ILineGraphicAttribute = Partial<IGraphicAttribute> & Partial<ILineAttribute> & Partial<IConnectedStyle>;
|
|
14
15
|
export interface ILine extends IGraphic<ILineGraphicAttribute> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/line.ts"],"names":[],"mappings":"","file":"line.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic, IConnectedStyle } from '../graphic';\nimport type { ICurveType } from '../common';\nimport type { ISegPath2D } from '../curve';\n\n// 依据x纬度做clipRange\n// 依据y纬度做clipRange\n// 依据线段自动匹配纬度做clipRange\n// 依据线长纬度做clipRange\nexport type IClipRangeByDimensionType = 'x' | 'y' | 'auto' | 'default';\n\nexport type ILineAttribute = {\n segments: ISegment[]; // 分段设置point和样式\n points: IPointLike[]; // segments points 二选一\n curveType: ICurveType;\n clipRange: number;\n clipRangeByDimension: IClipRangeByDimensionType;\n};\n\nexport type ILineGraphicAttribute = Partial<IGraphicAttribute> & Partial<ILineAttribute> & Partial<IConnectedStyle>;\n\nexport interface ILine extends IGraphic<ILineGraphicAttribute> {\n cache?: ISegPath2D | ISegPath2D[];\n}\n\ntype ISegmentStyle = Pick<\n IGraphicAttribute,\n 'stroke' | 'strokeOpacity' | 'lineDash' | 'lineDashOffset' | 'lineCap' | 'lineJoin' | 'lineWidth' | 'miterLimit'\n>;\n\nexport interface ISegment extends Partial<ISegmentStyle>, Partial<IConnectedStyle> {\n points: IPointLike[];\n simplify?: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/line.ts"],"names":[],"mappings":"","file":"line.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic, IConnectedStyle } from '../graphic';\nimport type { ICurveType } from '../common';\nimport type { ISegPath2D } from '../curve';\n\n// 依据x纬度做clipRange\n// 依据y纬度做clipRange\n// 依据线段自动匹配纬度做clipRange\n// 依据线长纬度做clipRange\nexport type IClipRangeByDimensionType = 'x' | 'y' | 'auto' | 'default';\n\nexport type ILineAttribute = {\n segments: ISegment[]; // 分段设置point和样式\n points: IPointLike[]; // segments points 二选一\n curveType: ICurveType;\n clipRange: number;\n clipRangeByDimension: IClipRangeByDimensionType;\n closePath: boolean; // 是否封闭路径\n};\n\nexport type ILineGraphicAttribute = Partial<IGraphicAttribute> & Partial<ILineAttribute> & Partial<IConnectedStyle>;\n\nexport interface ILine extends IGraphic<ILineGraphicAttribute> {\n cache?: ISegPath2D | ISegPath2D[];\n}\n\ntype ISegmentStyle = Pick<\n IGraphicAttribute,\n 'stroke' | 'strokeOpacity' | 'lineDash' | 'lineDashOffset' | 'lineCap' | 'lineJoin' | 'lineWidth' | 'miterLimit'\n>;\n\nexport interface ISegment extends Partial<ISegmentStyle>, Partial<IConnectedStyle> {\n points: IPointLike[];\n simplify?: boolean;\n}\n"]}
|
|
@@ -14,9 +14,8 @@ export interface ISymbolClass {
|
|
|
14
14
|
type: SymbolType | string;
|
|
15
15
|
path?: ICustomPath2D;
|
|
16
16
|
pathStr: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
drawOffset: (ctx: IPath2D, size: number | [number, number], x: number, y: number, offset: number, z?: number, cb?: (p: ICustomPath2D, a: any) => void) => boolean;
|
|
17
|
+
draw: (ctx: IPath2D, size: number | [number, number], x: number, y: number, z?: number) => boolean;
|
|
18
|
+
drawOffset: (ctx: IPath2D, size: number | [number, number], x: number, y: number, offset: number, z?: number) => boolean;
|
|
20
19
|
drawToSvgPath?: (size: number | [number, number], x: number, y: number, z?: number) => string;
|
|
21
20
|
bounds: (size: number | [number, number], bounds: IBounds) => void;
|
|
22
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/symbol.ts"],"names":[],"mappings":"","file":"symbol.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D, IPath2D } from '../path';\n\nexport type ISymbolAttribute = {\n symbolType: SymbolType;\n size: number | [number, number];\n};\n\nexport type ISymbolGraphicAttribute = Partial<IGraphicAttribute> & Partial<ISymbolAttribute>;\n\nexport interface ISymbol extends IGraphic<ISymbolGraphicAttribute> {\n getParsedPath: () => ISymbolClass;\n}\n\nexport type SymbolType =\n | 'circle'\n | 'cross'\n | 'diamond'\n | 'square'\n | 'arrow'\n | 'arrow2Left'\n | 'arrow2Right'\n | 'wedge'\n | 'thinTriangle'\n | 'triangle'\n | 'triangleUp'\n | 'triangleDown'\n | 'triangleRight'\n | 'triangleLeft'\n | 'stroke'\n | 'star'\n | 'wye'\n | 'rect'\n | string;\n\nexport interface ISymbolClass {\n type: SymbolType | string;\n path?: ICustomPath2D;\n pathStr: string;\n
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/symbol.ts"],"names":[],"mappings":"","file":"symbol.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { ICustomPath2D, IPath2D } from '../path';\n\nexport type ISymbolAttribute = {\n symbolType: SymbolType;\n size: number | [number, number];\n};\n\nexport type ISymbolGraphicAttribute = Partial<IGraphicAttribute> & Partial<ISymbolAttribute>;\n\nexport interface ISymbol extends IGraphic<ISymbolGraphicAttribute> {\n getParsedPath: () => ISymbolClass;\n}\n\nexport type SymbolType =\n | 'circle'\n | 'cross'\n | 'diamond'\n | 'square'\n | 'arrow'\n | 'arrow2Left'\n | 'arrow2Right'\n | 'wedge'\n | 'thinTriangle'\n | 'triangle'\n | 'triangleUp'\n | 'triangleDown'\n | 'triangleRight'\n | 'triangleLeft'\n | 'stroke'\n | 'star'\n | 'wye'\n | 'rect'\n | string;\n\nexport interface ISymbolClass {\n type: SymbolType | string;\n path?: ICustomPath2D;\n pathStr: string;\n\n // 返回true表示内部已经调用closePath,返回false表示没有调用closePath,外部需要调用closePath\n draw: (ctx: IPath2D, size: number | [number, number], x: number, y: number, z?: number) => boolean;\n drawOffset: (\n ctx: IPath2D,\n size: number | [number, number],\n x: number,\n y: number,\n offset: number,\n z?: number\n ) => boolean;\n\n drawToSvgPath?: (size: number | [number, number], x: number, y: number, z?: number) => string;\n\n bounds: (size: number | [number, number], bounds: IBounds) => void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n wordBreak: 'break-word' | 'break-all';\n
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n wordBreak: 'break-word' | 'break-all';\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n};\nexport type ITextCache = {\n // 单行文本的时候缓存用\n clipedText?: string;\n clipedWidth?: number;\n // 多行文本的布局缓存\n layoutData?: LayoutType;\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n cache?: ITextCache;\n\n updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
|
|
@@ -32,6 +32,7 @@ export type ITransform = {
|
|
|
32
32
|
angle: number;
|
|
33
33
|
alpha: number;
|
|
34
34
|
beta: number;
|
|
35
|
+
scaleCenter: [number, number];
|
|
35
36
|
anchor: [number | string, number | string];
|
|
36
37
|
anchor3d: [number | string, number | string, number] | [number | string, number | string];
|
|
37
38
|
postMatrix: IMatrix;
|
|
@@ -83,33 +84,16 @@ export type IConnectedStyle = {
|
|
|
83
84
|
connectedX: number;
|
|
84
85
|
connectedY: number;
|
|
85
86
|
};
|
|
86
|
-
export type IBackgroundConfig = {
|
|
87
|
-
stroke?: string | boolean;
|
|
88
|
-
fill?: string | boolean;
|
|
89
|
-
lineWidth?: number;
|
|
90
|
-
cornerRadius?: number;
|
|
91
|
-
expandX?: number;
|
|
92
|
-
expandY?: number;
|
|
93
|
-
};
|
|
94
87
|
export type IGraphicStyle = IFillStyle & IStrokeStyle & {
|
|
95
88
|
opacity: number;
|
|
96
89
|
backgroundMode: number;
|
|
97
|
-
background: string | HTMLImageElement | HTMLCanvasElement |
|
|
90
|
+
background: string | HTMLImageElement | HTMLCanvasElement | null;
|
|
98
91
|
texture: TextureType | string;
|
|
99
92
|
textureColor: string;
|
|
100
93
|
textureSize: number;
|
|
101
94
|
texturePadding: number;
|
|
102
95
|
blur: number;
|
|
103
96
|
cursor: Cursor | null;
|
|
104
|
-
html: {
|
|
105
|
-
dom: string | HTMLElement;
|
|
106
|
-
container: string | HTMLElement | null;
|
|
107
|
-
width: number;
|
|
108
|
-
height: number;
|
|
109
|
-
style: string | Record<string, any>;
|
|
110
|
-
visible?: boolean;
|
|
111
|
-
anchorType?: 'position' | 'boundsLeftTop';
|
|
112
|
-
} | null;
|
|
113
97
|
};
|
|
114
98
|
export type IGraphicAttribute = IGraphicStyle & ITransform & {
|
|
115
99
|
strokeSeg: IStrokeSeg | null;
|
|
@@ -156,11 +140,6 @@ export interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphi
|
|
|
156
140
|
shadowRoot?: IShadowRoot;
|
|
157
141
|
glyphHost?: IGraphic<IGlyphGraphicAttribute>;
|
|
158
142
|
backgroundImg?: boolean;
|
|
159
|
-
bindDom?: Map<string | HTMLElement, {
|
|
160
|
-
container: HTMLElement | string;
|
|
161
|
-
dom: HTMLElement;
|
|
162
|
-
wrapGroup: HTMLDivElement;
|
|
163
|
-
}>;
|
|
164
143
|
valid: boolean;
|
|
165
144
|
parent: IGroup | null;
|
|
166
145
|
isContainer?: boolean;
|
|
@@ -206,7 +185,6 @@ export interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphi
|
|
|
206
185
|
skewTo: (b: number, c: number) => this;
|
|
207
186
|
addUpdateBoundTag: () => void;
|
|
208
187
|
addUpdateShapeAndBoundsTag: () => void;
|
|
209
|
-
addUpdateLayoutTag: () => void;
|
|
210
188
|
update: (d?: {
|
|
211
189
|
bounds: boolean;
|
|
212
190
|
trans: boolean;
|
|
@@ -230,7 +208,7 @@ export interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphi
|
|
|
230
208
|
toJson: () => IGraphicJson;
|
|
231
209
|
createPathProxy: (path?: string) => void;
|
|
232
210
|
toCustomPath?: () => ICustomPath2D;
|
|
233
|
-
resources?: Map<string | HTMLImageElement | HTMLCanvasElement
|
|
211
|
+
resources?: Map<string | HTMLImageElement | HTMLCanvasElement, {
|
|
234
212
|
state: 'init' | 'loading' | 'success' | 'fail';
|
|
235
213
|
data?: HTMLImageElement | HTMLCanvasElement;
|
|
236
214
|
}>;
|