@visactor/vrender-core 1.0.0-alpha.4 → 1.0.0-alpha.6
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/config.d.ts +0 -1
- package/cjs/animate/config.js +1 -5
- package/cjs/animate/config.js.map +1 -1
- package/cjs/application.d.ts +2 -1
- package/cjs/application.js.map +1 -1
- package/cjs/color-string/interpolate.js +5 -2
- package/cjs/color-string/interpolate.js.map +1 -1
- package/cjs/common/canvas-utils.js +6 -3
- package/cjs/common/canvas-utils.js.map +1 -1
- package/cjs/common/custom-path2d.js +2 -2
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/morphing-utils.js +32 -124
- package/cjs/common/morphing-utils.js.map +1 -1
- package/cjs/common/segment/index.js +3 -0
- package/cjs/common/segment/index.js.map +1 -1
- package/cjs/common/segment/step.d.ts +6 -0
- package/cjs/common/segment/step.js +19 -2
- package/cjs/common/segment/step.js.map +1 -1
- package/cjs/common/shape/arc.d.ts +1 -1
- package/cjs/common/shape/arc.js +7 -3
- package/cjs/common/shape/arc.js.map +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/common/split-path.js.map +1 -1
- package/cjs/common/utils.d.ts +0 -2
- package/cjs/common/utils.js +4 -8
- package/cjs/common/utils.js.map +1 -1
- package/cjs/core/stage.js +4 -4
- package/cjs/core/stage.js.map +1 -1
- package/cjs/graphic/arc.d.ts +1 -2
- package/cjs/graphic/arc.js +4 -3
- package/cjs/graphic/arc.js.map +1 -1
- package/cjs/graphic/area.d.ts +1 -2
- package/cjs/graphic/area.js +5 -2
- package/cjs/graphic/area.js.map +1 -1
- package/cjs/graphic/circle.d.ts +1 -2
- package/cjs/graphic/circle.js +7 -3
- package/cjs/graphic/circle.js.map +1 -1
- package/cjs/graphic/config.d.ts +2 -1
- package/cjs/graphic/config.js +10 -3
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/constants.d.ts +1 -0
- package/cjs/graphic/constants.js +4 -3
- package/cjs/graphic/constants.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +7 -1
- package/cjs/graphic/graphic.js +20 -15
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/image.js +2 -1
- package/cjs/graphic/image.js.map +1 -1
- package/cjs/graphic/index.d.ts +1 -0
- package/cjs/graphic/index.js +8 -8
- package/cjs/graphic/index.js.map +1 -1
- package/cjs/graphic/line.d.ts +1 -2
- package/cjs/graphic/line.js +7 -2
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/path.js +2 -1
- package/cjs/graphic/path.js.map +1 -1
- package/cjs/graphic/polygon.js +2 -1
- package/cjs/graphic/polygon.js.map +1 -1
- package/cjs/graphic/rect.js +7 -3
- package/cjs/graphic/rect.js.map +1 -1
- package/cjs/graphic/richtext/icon.d.ts +1 -1
- package/cjs/graphic/richtext/icon.js.map +1 -1
- package/cjs/graphic/richtext.js +3 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/star.d.ts +52 -0
- package/cjs/graphic/star.js +78 -0
- package/cjs/graphic/star.js.map +1 -0
- package/cjs/graphic/symbol.js +3 -1
- package/cjs/graphic/symbol.js.map +1 -1
- package/cjs/graphic/text.js +1 -0
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/theme.js +2 -0
- package/cjs/graphic/theme.js.map +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +7 -6
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animation/animate.d.ts +17 -0
- package/cjs/interface/animation/animate.js.map +1 -1
- package/cjs/interface/animation/ticker.d.ts +2 -0
- package/cjs/interface/animation/ticker.js.map +1 -1
- package/cjs/interface/common.d.ts +1 -1
- package/cjs/interface/common.js.map +1 -1
- package/cjs/interface/contribution.d.ts +2 -0
- package/cjs/interface/contribution.js.map +1 -1
- package/cjs/interface/graphic/index.d.ts +1 -0
- package/cjs/interface/graphic/index.js +3 -2
- package/cjs/interface/graphic/index.js.map +1 -1
- package/cjs/interface/graphic/star.d.ts +12 -0
- package/cjs/interface/graphic/star.js +6 -0
- package/cjs/interface/graphic/star.js.map +1 -0
- package/cjs/interface/graphic/theme.d.ts +3 -0
- package/cjs/interface/graphic/theme.js.map +1 -1
- package/cjs/interface/graphic.d.ts +11 -0
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/render.d.ts +1 -0
- package/cjs/interface/render.js.map +1 -1
- package/cjs/modules.d.ts +2 -1
- package/cjs/modules.js +4 -3
- package/cjs/modules.js.map +1 -1
- package/cjs/register/register-star.d.ts +1 -0
- package/cjs/register/register-star.js +14 -0
- package/cjs/register/register-star.js.map +1 -0
- package/cjs/render/contributions/render/area-render.js +2 -2
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/constants.d.ts +1 -0
- package/cjs/render/contributions/render/contributions/constants.js +3 -2
- package/cjs/render/contributions/render/contributions/constants.js.map +1 -1
- package/cjs/render/contributions/render/contributions/index.d.ts +1 -0
- package/cjs/render/contributions/render/contributions/index.js +2 -2
- package/cjs/render/contributions/render/contributions/index.js.map +1 -1
- package/cjs/render/contributions/render/contributions/star-contribution-render.d.ts +2 -0
- package/cjs/render/contributions/render/contributions/star-contribution-render.js +11 -0
- package/cjs/render/contributions/render/contributions/star-contribution-render.js.map +1 -0
- package/cjs/render/contributions/render/line-render.js +1 -1
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/render/contributions/render/star-module.d.ts +2 -0
- package/cjs/render/contributions/render/star-module.js +15 -0
- package/cjs/render/contributions/render/star-module.js.map +1 -0
- package/cjs/render/contributions/render/star-render.d.ts +10 -0
- package/cjs/render/contributions/render/star-render.js +54 -0
- package/cjs/render/contributions/render/star-render.js.map +1 -0
- package/cjs/render/contributions/render/symbol.d.ts +1 -0
- package/cjs/render/contributions/render/symbol.js +2 -2
- package/cjs/render/contributions/render/symbol.js.map +1 -1
- package/cjs/render/render-service.d.ts +1 -1
- package/cjs/render/render-service.js.map +1 -1
- package/dist/index.es.js +12265 -12093
- package/es/animate/config.d.ts +0 -1
- package/es/animate/config.js +0 -5
- package/es/animate/config.js.map +1 -1
- package/es/application.d.ts +2 -1
- package/es/application.js.map +1 -1
- package/es/color-string/interpolate.js +4 -1
- package/es/color-string/interpolate.js.map +1 -1
- package/es/common/canvas-utils.js +6 -3
- package/es/common/canvas-utils.js.map +1 -1
- package/es/common/custom-path2d.js +2 -2
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/morphing-utils.js +29 -124
- package/es/common/morphing-utils.js.map +1 -1
- package/es/common/segment/index.js +4 -1
- package/es/common/segment/index.js.map +1 -1
- package/es/common/segment/step.d.ts +6 -0
- package/es/common/segment/step.js +13 -0
- package/es/common/segment/step.js.map +1 -1
- package/es/common/shape/arc.d.ts +1 -1
- package/es/common/shape/arc.js +7 -3
- package/es/common/shape/arc.js.map +1 -1
- package/es/common/split-path.js +1 -1
- package/es/common/split-path.js.map +1 -1
- package/es/common/utils.d.ts +0 -2
- package/es/common/utils.js +0 -4
- package/es/common/utils.js.map +1 -1
- package/es/core/stage.js +4 -4
- package/es/core/stage.js.map +1 -1
- package/es/graphic/arc.d.ts +1 -2
- package/es/graphic/arc.js +4 -3
- package/es/graphic/arc.js.map +1 -1
- package/es/graphic/area.d.ts +1 -2
- package/es/graphic/area.js +5 -2
- package/es/graphic/area.js.map +1 -1
- package/es/graphic/circle.d.ts +1 -2
- package/es/graphic/circle.js +6 -3
- package/es/graphic/circle.js.map +1 -1
- package/es/graphic/config.d.ts +2 -1
- package/es/graphic/config.js +11 -2
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/constants.d.ts +1 -0
- package/es/graphic/constants.js +2 -0
- package/es/graphic/constants.js.map +1 -1
- package/es/graphic/graphic.d.ts +7 -1
- package/es/graphic/graphic.js +21 -14
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/image.js +2 -1
- package/es/graphic/image.js.map +1 -1
- package/es/graphic/index.d.ts +1 -0
- package/es/graphic/index.js +2 -0
- package/es/graphic/index.js.map +1 -1
- package/es/graphic/line.d.ts +1 -2
- package/es/graphic/line.js +7 -2
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/path.js +2 -1
- package/es/graphic/path.js.map +1 -1
- package/es/graphic/polygon.js +2 -1
- package/es/graphic/polygon.js.map +1 -1
- package/es/graphic/rect.js +7 -3
- package/es/graphic/rect.js.map +1 -1
- package/es/graphic/richtext/icon.d.ts +1 -1
- package/es/graphic/richtext/icon.js.map +1 -1
- package/es/graphic/richtext.js +3 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/star.d.ts +52 -0
- package/es/graphic/star.js +82 -0
- package/es/graphic/star.js.map +1 -0
- package/es/graphic/symbol.js +3 -1
- package/es/graphic/symbol.js.map +1 -1
- package/es/graphic/text.js +1 -0
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/theme.js +3 -1
- package/es/graphic/theme.js.map +1 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +4 -0
- package/es/index.js.map +1 -1
- package/es/interface/animation/animate.d.ts +17 -0
- package/es/interface/animation/animate.js.map +1 -1
- package/es/interface/animation/ticker.d.ts +2 -0
- package/es/interface/animation/ticker.js.map +1 -1
- package/es/interface/common.d.ts +1 -1
- package/es/interface/common.js.map +1 -1
- package/es/interface/contribution.d.ts +2 -0
- package/es/interface/contribution.js.map +1 -1
- package/es/interface/graphic/index.d.ts +1 -0
- package/es/interface/graphic/index.js +2 -0
- package/es/interface/graphic/index.js.map +1 -1
- package/es/interface/graphic/star.d.ts +12 -0
- package/es/interface/graphic/star.js +2 -0
- package/es/interface/graphic/star.js.map +1 -0
- package/es/interface/graphic/theme.d.ts +3 -0
- package/es/interface/graphic/theme.js.map +1 -1
- package/es/interface/graphic.d.ts +11 -0
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/render.d.ts +1 -0
- package/es/interface/render.js.map +1 -1
- package/es/modules.d.ts +2 -1
- package/es/modules.js +6 -0
- package/es/modules.js.map +1 -1
- package/es/register/register-star.d.ts +1 -0
- package/es/register/register-star.js +8 -0
- package/es/register/register-star.js.map +1 -0
- package/es/render/contributions/render/area-render.js +2 -2
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/contributions/constants.d.ts +1 -0
- package/es/render/contributions/render/contributions/constants.js +2 -0
- package/es/render/contributions/render/contributions/constants.js.map +1 -1
- package/es/render/contributions/render/contributions/index.d.ts +1 -0
- package/es/render/contributions/render/contributions/index.js +2 -0
- package/es/render/contributions/render/contributions/index.js.map +1 -1
- package/es/render/contributions/render/contributions/star-contribution-render.d.ts +2 -0
- package/es/render/contributions/render/contributions/star-contribution-render.js +8 -0
- package/es/render/contributions/render/contributions/star-contribution-render.js.map +1 -0
- package/es/render/contributions/render/line-render.js +1 -1
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/render/contributions/render/star-module.d.ts +2 -0
- package/es/render/contributions/render/star-module.js +13 -0
- package/es/render/contributions/render/star-module.js.map +1 -0
- package/es/render/contributions/render/star-render.d.ts +10 -0
- package/es/render/contributions/render/star-render.js +59 -0
- package/es/render/contributions/render/star-render.js.map +1 -0
- package/es/render/contributions/render/symbol.d.ts +1 -0
- package/es/render/contributions/render/symbol.js +2 -0
- package/es/render/contributions/render/symbol.js.map +1 -1
- package/es/render/render-service.d.ts +1 -1
- package/es/render/render-service.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/animation/animate.ts"],"names":[],"mappings":"AAsKA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,iDAAe,CAAA;IACf,6EAA6B,CAAA;AAC/B,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","file":"animate.js","sourcesContent":["import type { IGraphic } from '../graphic';\nimport type { EasingType, EasingTypeFunc } from './easing';\nimport type { AnimateStatus, IAnimateStepType } from './type';\nimport type { ITimeline } from './timeline';\n\nexport interface ICustomAnimate extends IStep {\n type: IAnimateStepType;\n}\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 链表,下一个\n next?: IStep;\n // 属性\n props?: Record<string, any>;\n // 解析后的属性(用于性能优化,避免每次tick都解析)\n fromParsedProps?: Record<string, any>;\n toParsedProps?: Record<string, any>;\n fromProps?: Record<string, any>;\n // 解析后的属性列表(用于性能优化,避免每次tick都解析)\n propKeys?: string[];\n // 缓动函数\n easing?: EasingTypeFunc;\n\n // 添加一个\n append: (step: IStep) => void;\n // 获取上一个props,用于完成这次的fromValue 和 toValue的插值\n getLastProps: () => any;\n\n animate: IAnimate;\n\n // 设置持续时间\n setDuration: (duration: number, updateDownstream?: boolean) => void;\n // 获取持续时间\n getDuration: () => number;\n // 确定插值更新函数(在开始的时候就确定,避免每次tick都解析)\n determineInterpolateUpdateFunction: () => void;\n\n // 设置开始时间\n setStartTime: (time: number, updateDownstream?: boolean) => void;\n // 获取开始时间\n getStartTime: () => number;\n\n bind: (target: IGraphic, animate: IAnimate) => void;\n // 在第一次绑定到Animate的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: (cb?: (animate: IAnimate, step: IStep) => void) => void;\n // 更新执行的时候调用(如果有循环,那每个周期都会调用)\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n\n // 屏蔽自身属性,会直接从props等内容里删除掉\n deleteSelfAttr: (key: string) => void;\n\n // 停止\n stop: () => void;\n}\n\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n priority: number;\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\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 // 设置timeline\n setTimeline: (timeline: ITimeline) => void;\n // 获取timeline\n getTimeline: () => ITimeline;\n readonly timeline: ITimeline;\n\n bind: (target: IGraphic) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType) => 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 onRemove: (cb?: () => 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: IGraphic,\n ret: Record<string, any>\n ) => boolean;\n play: (customAnimate: ICustomAnimate) => this;\n\n getFromValue: () => Record<string, any>;\n getToValue: () => Record<string, any>;\n // 停止,可以设置停止后设置target的属性为开始的值(fromValue),还是结束的值(toValue)\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n getTotalDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // 等待delay\n wait: (delay: number) => this;\n\n /* 动画编排 */\n // 所有动画结束后执行\n afterAll: (list: IAnimate[]) => this;\n // 在某个动画结束后执行\n after: (animate: IAnimate) => this;\n // 并行执行\n parallel: (animate: IAnimate) => this;\n\n getLoop: () => number;\n\n // 反转动画\n // reversed: (r: boolean) => IAnimate;\n // 循环动画\n loop: (n: number | boolean) => IAnimate;\n // 反弹动画\n bounce: (b: boolean) => IAnimate;\n\n advance: (delta: number) => void;\n\n // 设置开始时间(startAt之前是完全不会进入动画生命周期的)\n // 它和wait不一样,如果调用的是wait,wait过程中还算是一个动画阶段,只是空的阶段,而startAt之前是完全不会进入动画生命周期的\n startAt: (t: number) => IAnimate;\n\n // 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n reSyncProps: () => void;\n\n // 更新duration\n updateDuration: () => void;\n}\n\nexport enum AnimateMode {\n NORMAL = 0b0000,\n SET_ATTR_IMMEDIATELY = 0b0001\n}\n\nexport interface IAnimateTarget {\n onAnimateBind?: (animte: IAnimate) => 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"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/animation/animate.ts"],"names":[],"mappings":"AAsKA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,iDAAe,CAAA;IACf,6EAA6B,CAAA;AAC/B,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB","file":"animate.js","sourcesContent":["import type { IGraphic } from '../graphic';\nimport type { EasingType, EasingTypeFunc } from './easing';\nimport type { AnimateStatus, IAnimateStepType } from './type';\nimport type { ITimeline } from './timeline';\n\nexport interface ICustomAnimate extends IStep {\n type: IAnimateStepType;\n}\n\nexport interface IStep {\n type: IAnimateStepType;\n prev?: IStep;\n // 持续时间\n duration: number;\n // 链表,下一个\n next?: IStep;\n // 属性\n props?: Record<string, any>;\n // 解析后的属性(用于性能优化,避免每次tick都解析)\n fromParsedProps?: Record<string, any>;\n toParsedProps?: Record<string, any>;\n fromProps?: Record<string, any>;\n // 解析后的属性列表(用于性能优化,避免每次tick都解析)\n propKeys?: string[];\n // 缓动函数\n easing?: EasingTypeFunc;\n\n // 添加一个\n append: (step: IStep) => void;\n // 获取上一个props,用于完成这次的fromValue 和 toValue的插值\n getLastProps: () => any;\n\n animate: IAnimate;\n\n // 设置持续时间\n setDuration: (duration: number, updateDownstream?: boolean) => void;\n // 获取持续时间\n getDuration: () => number;\n // 确定插值更新函数(在开始的时候就确定,避免每次tick都解析)\n determineInterpolateUpdateFunction: () => void;\n\n // 设置开始时间\n setStartTime: (time: number, updateDownstream?: boolean) => void;\n // 获取开始时间\n getStartTime: () => number;\n\n bind: (target: IGraphic, animate: IAnimate) => void;\n // 在第一次绑定到Animate的时候触发\n onBind: () => void;\n // 第一次执行的时候调用\n onFirstRun: () => void;\n // 开始执行的时候调用(如果有循环,那每个周期都会调用)\n onStart: () => void;\n // 结束执行的时候调用(如果有循环,那每个周期都会调用)\n onEnd: (cb?: (animate: IAnimate, step: IStep) => void) => void;\n // 更新执行的时候调用(如果有循环,那每个周期都会调用)\n update: (end: boolean, ratio: number, out: Record<string, any>) => void;\n onUpdate: (end: boolean, ratio: number, out: Record<string, any>) => void;\n\n getEndProps: () => Record<string, any> | void;\n getFromProps: () => Record<string, any> | void;\n getMergedEndProps: () => Record<string, any> | void;\n\n // 屏蔽自身属性,会直接从props等内容里删除掉\n deleteSelfAttr: (key: string) => void;\n\n // 停止\n stop: () => void;\n}\n\nexport interface IAnimate {\n readonly id: string | number;\n status: AnimateStatus;\n target: IGraphic;\n priority: number;\n interpolateUpdateFunction:\n | ((from: Record<string, any>, to: Record<string, any>, ratio: number, step: IStep, target: IGraphic) => void)\n | null;\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 // 设置timeline\n setTimeline: (timeline: ITimeline) => void;\n // 获取timeline\n getTimeline: () => ITimeline;\n readonly timeline: ITimeline;\n\n bind: (target: IGraphic) => this;\n to: (props: Record<string, any>, duration: number, easing: EasingType) => this;\n from: (props: Record<string, any>, duration: number, easing: EasingType) => 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 onRemove: (cb?: () => 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: IGraphic,\n ret: Record<string, any>\n ) => boolean;\n play: (customAnimate: ICustomAnimate) => this;\n\n getFromValue: () => Record<string, any>;\n getToValue: () => Record<string, any>;\n // 停止,可以设置停止后设置target的属性为开始的值(fromValue),还是结束的值(toValue)\n stop: (type?: 'start' | 'end' | Record<string, any>) => void;\n /** 打上END标志,下一帧被删除 */\n release: () => void;\n // 获取持续的时长\n getDuration: () => number;\n getTotalDuration: () => number;\n // 获取动画开始时间(注意并不是子动画的startAt)\n getStartTime: () => number;\n // 等待delay\n wait: (delay: number) => this;\n\n /* 动画编排 */\n // 所有动画结束后执行\n afterAll: (list: IAnimate[]) => this;\n // 在某个动画结束后执行\n after: (animate: IAnimate) => this;\n // 并行执行\n parallel: (animate: IAnimate) => this;\n\n getLoop: () => number;\n\n // 反转动画\n // reversed: (r: boolean) => IAnimate;\n // 循环动画\n loop: (n: number | boolean) => IAnimate;\n // 反弹动画\n bounce: (b: boolean) => IAnimate;\n\n advance: (delta: number) => void;\n\n // 设置开始时间(startAt之前是完全不会进入动画生命周期的)\n // 它和wait不一样,如果调用的是wait,wait过程中还算是一个动画阶段,只是空的阶段,而startAt之前是完全不会进入动画生命周期的\n startAt: (t: number) => IAnimate;\n\n // 重新同步和计算props,用于内部某些step发生了变更后,重新计算自身\n reSyncProps: () => void;\n\n // 更新duration\n updateDuration: () => void;\n}\n\nexport enum AnimateMode {\n NORMAL = 0b0000,\n SET_ATTR_IMMEDIATELY = 0b0001\n}\n\nexport interface IAnimateTarget {\n onAnimateBind?: (animte: IAnimate) => 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 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\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"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EventEmitter } from '@visactor/vutils';
|
|
2
2
|
import type { ITimeline } from './timeline';
|
|
3
|
+
import type { IStage } from '../stage';
|
|
3
4
|
export type TickerMode = 'raf' | 'timeout' | 'manual';
|
|
4
5
|
export declare enum STATUS {
|
|
5
6
|
INITIAL = 0,
|
|
@@ -33,5 +34,6 @@ export interface ITicker extends EventEmitter {
|
|
|
33
34
|
trySyncTickStatus: () => void;
|
|
34
35
|
getTimelines: () => ITimeline[];
|
|
35
36
|
release: () => void;
|
|
37
|
+
bindStage: (stage: IStage) => void;
|
|
36
38
|
autoStop: boolean;
|
|
37
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/animation/ticker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/interface/animation/ticker.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,MAIX;AAJD,WAAY,MAAM;IAChB,yCAAW,CAAA;IACX,yCAAW,CAAA;IACX,qCAAS,CAAA;AACX,CAAC,EAJW,MAAM,KAAN,MAAM,QAIjB","file":"ticker.js","sourcesContent":["/**\n * Ticker Types for Animation Graph\n */\n\nimport type { EventEmitter } from '@visactor/vutils';\nimport type { ITimeline } from './timeline';\nimport type { IStage } from '../stage';\n\nexport type TickerMode = 'raf' | 'timeout' | 'manual';\n\nexport enum STATUS {\n INITIAL = 0, // initial represents initial state\n RUNNING = 1, // running represents executing\n PAUSE = 2 // PAUSE represents tick continues but functions are not executed\n}\n\nexport interface ITickHandler {\n /**\n * Start executing tick\n * @param interval Delay in ms\n * @param cb Callback to execute\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; // Get current time\n release: () => void;\n}\n\nexport interface ITickerHandlerStatic {\n new (): ITickHandler;\n}\n\nexport interface ITicker extends EventEmitter {\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 * Start ticking, if force is true, start regardless;\n * otherwise, don't start if timeline is empty\n */\n start: (force?: boolean) => boolean;\n stop: () => void;\n addTimeline: (timeline: ITimeline) => void;\n remTimeline: (timeline: ITimeline) => void;\n trySyncTickStatus: () => void;\n getTimelines: () => ITimeline[];\n release: () => void;\n\n bindStage: (stage: IStage) => void;\n\n // Whether to automatically stop, default is true\n autoStop: boolean;\n}\n"]}
|
package/es/interface/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ICurveType = 'basis' | 'basisClosed' | 'basisOpen' | 'bundle' | 'cardinal' | 'cardinalClosed' | 'cardinalOpen' | 'stepBefore' | 'stepAfter' | 'catmullRom' | 'catmullRomClosed' | 'catmullRomOpen' | 'linear' | 'linearClosed' | 'monotoneX' | 'monotoneY' | 'natural' | 'radial' | 'step';
|
|
1
|
+
export type ICurveType = 'basis' | 'basisClosed' | 'basisOpen' | 'bundle' | 'cardinal' | 'cardinalClosed' | 'cardinalOpen' | 'stepBefore' | 'stepAfter' | 'stepClosed' | 'catmullRom' | 'catmullRomClosed' | 'catmullRomOpen' | 'linear' | 'linearClosed' | 'monotoneX' | 'monotoneY' | 'natural' | 'radial' | 'step';
|
|
2
2
|
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
3
3
|
export interface Releaseable {
|
|
4
4
|
release: (...params: any) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/common.ts"],"names":[],"mappings":"","file":"common.js","sourcesContent":["export type ICurveType =\n | 'basis'\n | 'basisClosed'\n | 'basisOpen'\n | 'bundle'\n | 'cardinal'\n | 'cardinalClosed'\n | 'cardinalOpen'\n | 'stepBefore'\n | 'stepAfter'\n | 'catmullRom'\n | 'catmullRomClosed'\n | 'catmullRomOpen'\n | 'linear'\n | 'linearClosed'\n | 'monotoneX'\n | 'monotoneY'\n | 'natural'\n | 'radial'\n | 'step';\n\nexport type MaybePromise<T> = T | PromiseLike<T>;\n\n// 所有的接口都应当继承这个,避免内存没有释放\nexport interface Releaseable {\n release: (...params: any) => void;\n}\n\nexport interface IEventElement {\n // event接口\n addEventListener: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n on: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n once: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n removeEventListener: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n off: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n removeAllListeners: (<K extends keyof DocumentEventMap>(type: K) => void) & ((type: string) => void);\n dispatchEvent: (event: any) => boolean;\n emit: (event: any, ...args: any) => boolean;\n}\n\nexport interface IDomRectLike {\n bottom: number;\n left: number;\n right: number;\n top: number;\n height: number;\n width: number;\n x: number;\n y: number;\n}\n\nexport type IDirection = 1 | 2;\n\nexport type AsArray<T> = T extends any[] ? T : [T];\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/common.ts"],"names":[],"mappings":"","file":"common.js","sourcesContent":["export type ICurveType =\n | 'basis'\n | 'basisClosed'\n | 'basisOpen'\n | 'bundle'\n | 'cardinal'\n | 'cardinalClosed'\n | 'cardinalOpen'\n | 'stepBefore'\n | 'stepAfter'\n | 'stepClosed'\n | 'catmullRom'\n | 'catmullRomClosed'\n | 'catmullRomOpen'\n | 'linear'\n | 'linearClosed'\n | 'monotoneX'\n | 'monotoneY'\n | 'natural'\n | 'radial'\n | 'step';\n\nexport type MaybePromise<T> = T | PromiseLike<T>;\n\n// 所有的接口都应当继承这个,避免内存没有释放\nexport interface Releaseable {\n release: (...params: any) => void;\n}\n\nexport interface IEventElement {\n // event接口\n addEventListener: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n on: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n once: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n removeEventListener: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n off: (<K extends keyof DocumentEventMap>(\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ) => void) &\n ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);\n removeAllListeners: (<K extends keyof DocumentEventMap>(type: K) => void) & ((type: string) => void);\n dispatchEvent: (event: any) => boolean;\n emit: (event: any, ...args: any) => boolean;\n}\n\nexport interface IDomRectLike {\n bottom: number;\n left: number;\n right: number;\n top: number;\n height: number;\n width: number;\n x: number;\n y: number;\n}\n\nexport type IDirection = 1 | 2;\n\nexport type AsArray<T> = T extends any[] ? T : [T];\n"]}
|
|
@@ -13,6 +13,7 @@ import type { IImage, IImageGraphicAttribute } from './graphic/image';
|
|
|
13
13
|
import type { IPath, IPathGraphicAttribute } from './graphic/path';
|
|
14
14
|
import type { IPolygon, IPolygonGraphicAttribute } from './graphic/polygon';
|
|
15
15
|
import type { IRect, IRectGraphicAttribute } from './graphic/rect';
|
|
16
|
+
import type { IStar, IStarGraphicAttribute } from './graphic/star';
|
|
16
17
|
import type { IStage } from './stage';
|
|
17
18
|
import type { ICanvasLike } from './canvas';
|
|
18
19
|
import type { IDrawContext } from './render';
|
|
@@ -31,6 +32,7 @@ export type IArcRenderContribution = IBaseRenderContribution<IArc, IArcGraphicAt
|
|
|
31
32
|
export type ITextRenderContribution = IBaseRenderContribution<IText, ITextGraphicAttribute>;
|
|
32
33
|
export type IAreaRenderContribution = IBaseRenderContribution<IArea, IAreaGraphicAttribute>;
|
|
33
34
|
export type ICircleRenderContribution = IBaseRenderContribution<ICircle, ICircleGraphicAttribute>;
|
|
35
|
+
export type IStarRenderContribution = IBaseRenderContribution<IStar, IStarGraphicAttribute>;
|
|
34
36
|
export type IGroupRenderContribution = IBaseRenderContribution<IGroup, IGroupGraphicAttribute>;
|
|
35
37
|
export type IImageRenderContribution = IBaseRenderContribution<IImage, IImageGraphicAttribute>;
|
|
36
38
|
export type IPathRenderContribution = IBaseRenderContribution<IPath, IPathGraphicAttribute>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/contribution.ts"],"names":[],"mappings":"","file":"contribution.js","sourcesContent":["import type { MaybePromise, Releaseable } from './common';\nimport type { IContext2d } from './context';\nimport type { IThemeAttribute, IMarkAttribute } from './graphic/creator';\nimport type { IGraphicAttribute } from './graphic';\nimport type { ISymbol, ISymbolGraphicAttribute } from './graphic/symbol';\nimport type { BaseRenderContributionTime } from '../common/enums';\nimport type { IArc, IArcGraphicAttribute } from './graphic/arc';\nimport type { IArea, IAreaGraphicAttribute } from './graphic/area';\nimport type { IText, ITextGraphicAttribute } from './graphic/text';\nimport type { ICircle, ICircleGraphicAttribute } from './graphic/circle';\nimport type { IGroup, IGroupGraphicAttribute } from './graphic/group';\nimport type { IImage, IImageGraphicAttribute } from './graphic/image';\nimport type { IPath, IPathGraphicAttribute } from './graphic/path';\nimport type { IPolygon, IPolygonGraphicAttribute } from './graphic/polygon';\nimport type { IRect, IRectGraphicAttribute } from './graphic/rect';\nimport type { IStage } from './stage';\nimport type { ICanvasLike } from './canvas';\nimport type { IDrawContext } from './render';\n\nexport interface IContribution<T> extends Releaseable {\n configure: (service: T, ...data: any) => void;\n}\n\nexport interface IBaseRenderContribution<GraphicType, AttributeType> {\n time: BaseRenderContributionTime;\n useStyle: boolean;\n order: number;\n supportedAppName?: string | string[];\n\n drawShape: (\n graphic: GraphicType,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<AttributeType>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n params?: any\n ) => void;\n}\n\nexport type ISymbolRenderContribution = IBaseRenderContribution<ISymbol, ISymbolGraphicAttribute>;\n\nexport type IArcRenderContribution = IBaseRenderContribution<IArc, IArcGraphicAttribute>;\n\nexport type ITextRenderContribution = IBaseRenderContribution<IText, ITextGraphicAttribute>;\n\nexport type IAreaRenderContribution = IBaseRenderContribution<IArea, IAreaGraphicAttribute>;\n\nexport type ICircleRenderContribution = IBaseRenderContribution<ICircle, ICircleGraphicAttribute>;\n\nexport type IGroupRenderContribution = IBaseRenderContribution<IGroup, IGroupGraphicAttribute>;\n\nexport type IImageRenderContribution = IBaseRenderContribution<IImage, IImageGraphicAttribute>;\n\nexport type IPathRenderContribution = IBaseRenderContribution<IPath, IPathGraphicAttribute>;\n\nexport type IPolygonRenderContribution = IBaseRenderContribution<IPolygon, IPolygonGraphicAttribute>;\n\nexport type IRectRenderContribution = IBaseRenderContribution<IRect, IRectGraphicAttribute>;\n\nexport interface IContributionProvider<T> {\n getContributions: () => T[];\n}\n\nexport interface IApplicationContribution {\n // 调用初始化函数\n initialize?: () => void;\n\n configure?: (stage: IStage) => MaybePromise<void>;\n\n onDestroy?: (stage: IStage) => MaybePromise<void>;\n}\n\nexport interface ITTCanvas extends ICanvasLike {\n width: number;\n height: number;\n offsetWidth: number;\n offsetHeight: number;\n getContext: () => any;\n // 构造 getBoundingClientRect 方法\n getBoundingClientRect: () => { width: number; height: number };\n id: string;\n}\n\nexport interface ILynxCanvas extends ICanvasLike {\n width: number;\n height: number;\n offsetWidth: number;\n offsetHeight: number;\n getContext: () => any;\n // 构造 getBoundingClientRect 方法\n getBoundingClientRect: () => { width: number; height: number };\n id: string;\n}\n\nexport interface IDomRef {\n id: string;\n width: number;\n height: number;\n left: number;\n top: number;\n right: number;\n bottom: number;\n x: number;\n y: number;\n\n requestAnimationFrame?: any;\n cancelAnimationFrame?: any;\n getBoundingClientRect?: () => { height: number; width: number };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/contribution.ts"],"names":[],"mappings":"","file":"contribution.js","sourcesContent":["import type { MaybePromise, Releaseable } from './common';\nimport type { IContext2d } from './context';\nimport type { IThemeAttribute, IMarkAttribute } from './graphic/creator';\nimport type { IGraphicAttribute } from './graphic';\nimport type { ISymbol, ISymbolGraphicAttribute } from './graphic/symbol';\nimport type { BaseRenderContributionTime } from '../common/enums';\nimport type { IArc, IArcGraphicAttribute } from './graphic/arc';\nimport type { IArea, IAreaGraphicAttribute } from './graphic/area';\nimport type { IText, ITextGraphicAttribute } from './graphic/text';\nimport type { ICircle, ICircleGraphicAttribute } from './graphic/circle';\nimport type { IGroup, IGroupGraphicAttribute } from './graphic/group';\nimport type { IImage, IImageGraphicAttribute } from './graphic/image';\nimport type { IPath, IPathGraphicAttribute } from './graphic/path';\nimport type { IPolygon, IPolygonGraphicAttribute } from './graphic/polygon';\nimport type { IRect, IRectGraphicAttribute } from './graphic/rect';\nimport type { IStar, IStarGraphicAttribute } from './graphic/star';\nimport type { IStage } from './stage';\nimport type { ICanvasLike } from './canvas';\nimport type { IDrawContext } from './render';\n\nexport interface IContribution<T> extends Releaseable {\n configure: (service: T, ...data: any) => void;\n}\n\nexport interface IBaseRenderContribution<GraphicType, AttributeType> {\n time: BaseRenderContributionTime;\n useStyle: boolean;\n order: number;\n supportedAppName?: string | string[];\n\n drawShape: (\n graphic: GraphicType,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<AttributeType>,\n drawContext: IDrawContext,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n params?: any\n ) => void;\n}\n\nexport type ISymbolRenderContribution = IBaseRenderContribution<ISymbol, ISymbolGraphicAttribute>;\n\nexport type IArcRenderContribution = IBaseRenderContribution<IArc, IArcGraphicAttribute>;\n\nexport type ITextRenderContribution = IBaseRenderContribution<IText, ITextGraphicAttribute>;\n\nexport type IAreaRenderContribution = IBaseRenderContribution<IArea, IAreaGraphicAttribute>;\n\nexport type ICircleRenderContribution = IBaseRenderContribution<ICircle, ICircleGraphicAttribute>;\n\nexport type IStarRenderContribution = IBaseRenderContribution<IStar, IStarGraphicAttribute>;\n\nexport type IGroupRenderContribution = IBaseRenderContribution<IGroup, IGroupGraphicAttribute>;\n\nexport type IImageRenderContribution = IBaseRenderContribution<IImage, IImageGraphicAttribute>;\n\nexport type IPathRenderContribution = IBaseRenderContribution<IPath, IPathGraphicAttribute>;\n\nexport type IPolygonRenderContribution = IBaseRenderContribution<IPolygon, IPolygonGraphicAttribute>;\n\nexport type IRectRenderContribution = IBaseRenderContribution<IRect, IRectGraphicAttribute>;\n\nexport interface IContributionProvider<T> {\n getContributions: () => T[];\n}\n\nexport interface IApplicationContribution {\n // 调用初始化函数\n initialize?: () => void;\n\n configure?: (stage: IStage) => MaybePromise<void>;\n\n onDestroy?: (stage: IStage) => MaybePromise<void>;\n}\n\nexport interface ITTCanvas extends ICanvasLike {\n width: number;\n height: number;\n offsetWidth: number;\n offsetHeight: number;\n getContext: () => any;\n // 构造 getBoundingClientRect 方法\n getBoundingClientRect: () => { width: number; height: number };\n id: string;\n}\n\nexport interface ILynxCanvas extends ICanvasLike {\n width: number;\n height: number;\n offsetWidth: number;\n offsetHeight: number;\n getContext: () => any;\n // 构造 getBoundingClientRect 方法\n getBoundingClientRect: () => { width: number; height: number };\n id: string;\n}\n\nexport interface IDomRef {\n id: string;\n width: number;\n height: number;\n left: number;\n top: number;\n right: number;\n bottom: number;\n x: number;\n y: number;\n\n requestAnimationFrame?: any;\n cancelAnimationFrame?: any;\n getBoundingClientRect?: () => { height: number; width: number };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["export * from './creator';\nexport * from './theme';\nexport * from './arc';\nexport * from './arc3d';\nexport * from './area';\nexport * from './bounds';\nexport * from './circle';\nexport * from './ellipse';\nexport * from './face3d';\nexport * from './glyph';\nexport * from './group';\nexport * from './image';\nexport * from './isogon';\nexport * from './line';\nexport * from './path';\nexport * from './polygon';\nexport * from './polyline';\nexport * from './pyramid3d';\nexport * from './rect';\nexport * from './rect3d';\nexport * from './richText';\nexport * from './shadow-root';\nexport * from './svg';\nexport * from './symbol';\nexport * from './text';\nexport * from './util';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["export * from './creator';\nexport * from './theme';\nexport * from './arc';\nexport * from './arc3d';\nexport * from './area';\nexport * from './bounds';\nexport * from './circle';\nexport * from './ellipse';\nexport * from './face3d';\nexport * from './glyph';\nexport * from './group';\nexport * from './image';\nexport * from './isogon';\nexport * from './line';\nexport * from './path';\nexport * from './polygon';\nexport * from './polyline';\nexport * from './pyramid3d';\nexport * from './rect';\nexport * from './rect3d';\nexport * from './richText';\nexport * from './shadow-root';\nexport * from './star';\nexport * from './svg';\nexport * from './symbol';\nexport * from './text';\nexport * from './util';\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IPointLike } from '@visactor/vutils';
|
|
2
|
+
import type { IGraphicAttribute, IGraphic } from '../graphic';
|
|
3
|
+
export type IStarAttribute = {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
spikes: number;
|
|
7
|
+
thickness: number;
|
|
8
|
+
};
|
|
9
|
+
export type IStarGraphicAttribute = Partial<IGraphicAttribute> & Partial<IStarAttribute>;
|
|
10
|
+
export type IStar = IGraphic<IStarGraphicAttribute> & {
|
|
11
|
+
getCachedPoints: () => IPointLike[];
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/star.ts"],"names":[],"mappings":"","file":"star.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport type IStarAttribute = {\n /**\n * Width of the star\n */\n width: number;\n\n /**\n * Height of the star\n */\n height: number;\n\n /**\n * Number of spikes/corners (must be >= 3)\n */\n spikes: number;\n\n /**\n * How much the corners protrude (0-1)\n * 0 means a regular polygon, 1 means maximum protrusion\n */\n thickness: number;\n};\n\nexport type IStarGraphicAttribute = Partial<IGraphicAttribute> & Partial<IStarAttribute>;\n\nexport type IStar = IGraphic<IStarGraphicAttribute> & {\n getCachedPoints: () => IPointLike[];\n};\n"]}
|
|
@@ -10,6 +10,7 @@ import type { IPathGraphicAttribute } from './path';
|
|
|
10
10
|
import type { IPolygonGraphicAttribute } from './polygon';
|
|
11
11
|
import type { IRectGraphicAttribute } from './rect';
|
|
12
12
|
import type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';
|
|
13
|
+
import type { IStarGraphicAttribute } from './star';
|
|
13
14
|
import type { ISymbolGraphicAttribute } from './symbol';
|
|
14
15
|
import type { ITextGraphicAttribute } from './text';
|
|
15
16
|
export interface IThemeSpec {
|
|
@@ -21,6 +22,7 @@ export interface IThemeSpec {
|
|
|
21
22
|
line?: Partial<ILineGraphicAttribute>;
|
|
22
23
|
path?: Partial<IPathGraphicAttribute>;
|
|
23
24
|
symbol?: Partial<ISymbolGraphicAttribute>;
|
|
25
|
+
star?: Partial<IStarGraphicAttribute>;
|
|
24
26
|
group?: Partial<IGroupGraphicAttribute>;
|
|
25
27
|
polygon?: Partial<IPolygonGraphicAttribute>;
|
|
26
28
|
image?: Partial<IImageGraphicAttribute>;
|
|
@@ -38,6 +40,7 @@ export interface IFullThemeSpec {
|
|
|
38
40
|
glyph: Required<IGlyphGraphicAttribute>;
|
|
39
41
|
group: Required<IGroupGraphicAttribute>;
|
|
40
42
|
polygon: Required<IPolygonGraphicAttribute>;
|
|
43
|
+
star: Required<IStarGraphicAttribute>;
|
|
41
44
|
richtext: Required<IRichTextGraphicAttribute>;
|
|
42
45
|
richtextIcon: Required<IRichTextIconGraphicAttribute>;
|
|
43
46
|
image: Required<IImageGraphicAttribute>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IGraphicAttribute } from '../graphic';\nimport type { IArcGraphicAttribute } from './arc';\nimport type { IAreaGraphicAttribute } from './area';\nimport type { ICircleGraphicAttribute } from './circle';\nimport type { IGlyphGraphicAttribute } from './glyph';\nimport type { IGroup, IGroupGraphicAttribute } from './group';\nimport type { IImageGraphicAttribute } from './image';\nimport type { ILineGraphicAttribute } from './line';\nimport type { IPathGraphicAttribute } from './path';\nimport type { IPolygonGraphicAttribute } from './polygon';\nimport type { IRectGraphicAttribute } from './rect';\nimport type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';\nimport type { ISymbolGraphicAttribute } from './symbol';\nimport type { ITextGraphicAttribute } from './text';\n\nexport interface IThemeSpec {\n text?: Partial<ITextGraphicAttribute>;\n rect?: Partial<IRectGraphicAttribute>;\n arc?: Partial<IArcGraphicAttribute>;\n area?: Partial<IAreaGraphicAttribute>;\n circle?: Partial<ICircleGraphicAttribute>;\n line?: Partial<ILineGraphicAttribute>;\n path?: Partial<IPathGraphicAttribute>;\n symbol?: Partial<ISymbolGraphicAttribute>;\n group?: Partial<IGroupGraphicAttribute>;\n polygon?: Partial<IPolygonGraphicAttribute>;\n image?: Partial<IImageGraphicAttribute>;\n common?: Partial<IGraphicAttribute>;\n}\n\nexport interface IFullThemeSpec {\n arc: Required<IArcGraphicAttribute>;\n area: Required<IAreaGraphicAttribute>;\n circle: Required<ICircleGraphicAttribute>;\n line: Required<ILineGraphicAttribute>;\n path: Required<IPathGraphicAttribute>;\n symbol: Required<ISymbolGraphicAttribute>;\n text: Required<ITextGraphicAttribute>;\n rect: Required<IRectGraphicAttribute>;\n glyph: Required<IGlyphGraphicAttribute>;\n group: Required<IGroupGraphicAttribute>;\n polygon: Required<IPolygonGraphicAttribute>;\n richtext: Required<IRichTextGraphicAttribute>;\n richtextIcon: Required<IRichTextIconGraphicAttribute>;\n image: Required<IImageGraphicAttribute>;\n}\n\nexport interface ITheme {\n getTheme: (g: IGroup) => IFullThemeSpec;\n combinedTheme?: IFullThemeSpec;\n userTheme?: IThemeSpec;\n nextTheme?: IThemeSpec;\n applyTheme: (group: IGroup, pt: IThemeSpec, force?: boolean) => IThemeSpec;\n setTheme: (t: IThemeSpec, g: IGroup) => void;\n dirty: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/theme.ts"],"names":[],"mappings":"","file":"theme.js","sourcesContent":["import type { IGraphicAttribute } from '../graphic';\nimport type { IArcGraphicAttribute } from './arc';\nimport type { IAreaGraphicAttribute } from './area';\nimport type { ICircleGraphicAttribute } from './circle';\nimport type { IGlyphGraphicAttribute } from './glyph';\nimport type { IGroup, IGroupGraphicAttribute } from './group';\nimport type { IImageGraphicAttribute } from './image';\nimport type { ILineGraphicAttribute } from './line';\nimport type { IPathGraphicAttribute } from './path';\nimport type { IPolygonGraphicAttribute } from './polygon';\nimport type { IRectGraphicAttribute } from './rect';\nimport type { IRichTextGraphicAttribute, IRichTextIconGraphicAttribute } from './richText';\nimport type { IStarGraphicAttribute } from './star';\nimport type { ISymbolGraphicAttribute } from './symbol';\nimport type { ITextGraphicAttribute } from './text';\n\nexport interface IThemeSpec {\n text?: Partial<ITextGraphicAttribute>;\n rect?: Partial<IRectGraphicAttribute>;\n arc?: Partial<IArcGraphicAttribute>;\n area?: Partial<IAreaGraphicAttribute>;\n circle?: Partial<ICircleGraphicAttribute>;\n line?: Partial<ILineGraphicAttribute>;\n path?: Partial<IPathGraphicAttribute>;\n symbol?: Partial<ISymbolGraphicAttribute>;\n star?: Partial<IStarGraphicAttribute>;\n group?: Partial<IGroupGraphicAttribute>;\n polygon?: Partial<IPolygonGraphicAttribute>;\n image?: Partial<IImageGraphicAttribute>;\n common?: Partial<IGraphicAttribute>;\n}\n\nexport interface IFullThemeSpec {\n arc: Required<IArcGraphicAttribute>;\n area: Required<IAreaGraphicAttribute>;\n circle: Required<ICircleGraphicAttribute>;\n line: Required<ILineGraphicAttribute>;\n path: Required<IPathGraphicAttribute>;\n symbol: Required<ISymbolGraphicAttribute>;\n text: Required<ITextGraphicAttribute>;\n rect: Required<IRectGraphicAttribute>;\n glyph: Required<IGlyphGraphicAttribute>;\n group: Required<IGroupGraphicAttribute>;\n polygon: Required<IPolygonGraphicAttribute>;\n star: Required<IStarGraphicAttribute>;\n richtext: Required<IRichTextGraphicAttribute>;\n richtextIcon: Required<IRichTextIconGraphicAttribute>;\n image: Required<IImageGraphicAttribute>;\n}\n\nexport interface ITheme {\n getTheme: (g: IGroup) => IFullThemeSpec;\n combinedTheme?: IFullThemeSpec;\n userTheme?: IThemeSpec;\n nextTheme?: IThemeSpec;\n applyTheme: (group: IGroup, pt: IThemeSpec, force?: boolean) => IThemeSpec;\n setTheme: (t: IThemeSpec, g: IGroup) => void;\n dirty: boolean;\n}\n"]}
|
|
@@ -113,6 +113,11 @@ export interface CommonDomOptions {
|
|
|
113
113
|
penetrateEventList?: string[];
|
|
114
114
|
anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;
|
|
115
115
|
}
|
|
116
|
+
export type IRoughStyle = {
|
|
117
|
+
fillStyle: 'hachure' | 'solid' | 'zigzag' | 'cross-hatch' | 'dots' | 'sunburst' | 'dashed' | 'zigzag-line';
|
|
118
|
+
roughness: number;
|
|
119
|
+
bowing: number;
|
|
120
|
+
};
|
|
116
121
|
export type IGraphicStyle = ILayout & IFillStyle & IStrokeStyle & IPickStyle & {
|
|
117
122
|
forceBoundsWidth: number | (() => number) | undefined;
|
|
118
123
|
forceBoundsHeight: number | (() => number) | undefined;
|
|
@@ -147,12 +152,16 @@ export type IGraphicStyle = ILayout & IFillStyle & IStrokeStyle & IPickStyle & {
|
|
|
147
152
|
cursor: Cursor | null;
|
|
148
153
|
filter: string;
|
|
149
154
|
renderStyle?: 'default' | 'rough' | any;
|
|
155
|
+
roughStyle?: IRoughStyle | null;
|
|
150
156
|
html: ({
|
|
151
157
|
dom: string | HTMLElement;
|
|
152
158
|
} & SimpleDomStyleOptions & CommonDomOptions) | null;
|
|
153
159
|
react: ({
|
|
154
160
|
element: any;
|
|
155
161
|
} & SimpleDomStyleOptions & CommonDomOptions) | null;
|
|
162
|
+
vue: ({
|
|
163
|
+
element: any;
|
|
164
|
+
} & SimpleDomStyleOptions & CommonDomOptions) | null;
|
|
156
165
|
};
|
|
157
166
|
export type IPickStyle = {
|
|
158
167
|
pickStrokeBuffer: number;
|
|
@@ -233,6 +242,8 @@ export interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphi
|
|
|
233
242
|
parent: IGroup | null;
|
|
234
243
|
isContainer?: boolean;
|
|
235
244
|
in3dMode?: boolean;
|
|
245
|
+
widthWithoutTransform?: number;
|
|
246
|
+
heightWithoutTransform?: number;
|
|
236
247
|
stamp?: number;
|
|
237
248
|
animationBackUps?: {
|
|
238
249
|
from: Record<string, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType, IOBBBounds } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget, ITimeline } from './animation';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\nimport type { ISymbolClass } from './graphic/symbol';\n\ntype IStrokeSeg = {\n /**\n * 百分比\n */\n start: number;\n /**\n * 百分比\n * end和length二选一\n */\n end: number;\n /**\n * 像素长度\n */\n length: number;\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph'\n | string;\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n /**\n * x坐标\n */\n x: number;\n /**\n * y坐标\n */\n y: number;\n /**\n * z坐标\n */\n z: number;\n /**\n * x方向偏移量\n */\n dx: number;\n /**\n * y方向偏移量\n */\n dy: number;\n /**\n * z方向偏移量\n */\n dz: number;\n /**\n * x方向的滚动值\n */\n scrollX: number;\n /**\n * y方向的滚动值\n */\n scrollY: number;\n /**\n * x方向的缩放值\n */\n scaleX: number;\n /**\n * y方向的缩放值\n */\n scaleY: number;\n /**\n * z方向的缩放值\n */\n scaleZ: number;\n /**\n * 绕z轴的转角,即xy平面上的旋转角度\n */\n angle: number;\n /**\n * 绕x轴的转角\n */\n alpha: number;\n /**\n * 绕y轴的转角\n */\n beta: number;\n /**\n * 应用缩放的中心\n */\n scaleCenter: [number | string, number | string];\n /**\n * 基于AABB的锚点位置,用于简单的定位某些path\n */\n anchor: [number | string, number | string];\n /**\n * 3d的锚点位置\n */\n anchor3d: [number | string, number | string, number] | [number | string, number | string];\n /**\n * 处理矩阵,在正常计算完变换矩阵之后,会将该矩阵乘到变换矩阵上得到最终的变换矩阵\n */\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n /**\n * 图形的填充透明度\n */\n fillOpacity: number;\n /**\n * 图形模糊效果程度\n */\n shadowBlur: number;\n /**\n * 图形的阴影颜色\n */\n shadowColor: string;\n /**\n * 阴影水平偏移距离\n */\n shadowOffsetX: number;\n /**\n * 阴影垂直偏移距离\n */\n shadowOffsetY: number;\n /**\n * 图形的填充颜色\n */\n fill: IFillType;\n};\n\nexport type ILayout = {\n /**\n * 设置对齐方式\n */\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n /**\n * 边距离边缘的距离\n */\n distance: number | string;\n /**\n * 是否显示边框,默认是不显示的\n */\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n /**\n * 外部边框的样式配置,默认不展示外部边框\n */\n outerBorder: Partial<IBorderStyle>;\n /**\n * 内部边框的样式配置\n */\n innerBorder: Partial<IBorderStyle>;\n /**\n * 描边的透明度\n */\n strokeOpacity: number;\n /**\n * 设置线条虚线样式的属性,它通过定义实线和空白的交替长度来创建虚线效果\n */\n lineDash: number[];\n\n /**\n * 设置虚线样式的起始偏移量\n */\n lineDashOffset: number;\n\n /**\n * 设置线条的宽度\n */\n lineWidth: number;\n\n /**\n * 设置线条末端的样式\n */\n lineCap: CanvasLineCap;\n\n /**\n * 设置线条拐角的样式\n */\n lineJoin: CanvasLineJoin;\n\n /**\n * 设置线条拐角处的斜接限制\n */\n miterLimit: number;\n /**\n * 描边的boundsBuffer,用于控制bounds的buffer\n */\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n /**\n * 连接,取零或者断开\n */\n connectedType: 'connect' | 'none';\n /**\n * 连接线的样式配置\n */\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport interface SimpleDomStyleOptions {\n /**\n * 容器的宽度\n */\n width: number;\n /**\n * 容器的高度\n */\n height: number;\n /**\n * 容器的样式设置\n */\n style?:\n | string\n | Record<string, any>\n | ((\n pos: { top: number; left: number; width: number; height: number },\n graphic: IGraphic,\n wrapContainer: HTMLElement\n ) => Record<string, any>); // 容器的样式\n}\n\nexport interface CommonDomOptions {\n /**\n * 全局唯一的id\n */\n id?: string;\n /**\n * 容器元素的id或者dom元素\n */\n container: string | HTMLElement | null;\n /**\n * 是否显示\n */\n visible?: boolean;\n /**\n * 是否支持事件冒泡\n */\n pointerEvents?: boolean | string;\n /**\n * 可穿透的事件列表\n * @since 0.21.2\n */\n penetrateEventList?: string[];\n /**\n * 定位类型\n * 'position' - 根据挂载图形节点的坐标也就是x,y进行定位\n * 'boundsLeftTop' - 定位到挂载图形节点bounds的左上角\n * 'left' - 定位到挂载图形节点bounds 的左侧\n * 'right' - 定位到挂载图形节点bounds 的右侧\n * 'bottom' - 定位到挂载图形节点bounds 的底部\n * 'top' - 定位到挂载图形节点bounds 的顶部\n * 'center' - 定位到挂载图形节点bounds 的中心\n * 'top-left' - 定位到挂载图形节点bounds 的左上角\n * 'top-right' - 定位到挂载图形节点bounds 的右上角\n * 'bottom-left' - 定位到挂载图形节点bounds 的左下角\n * 'bottom-right' - 定位到挂载图形节点bounds 的右下角\n */\n anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;\n}\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n /**\n * 强制设置的bounds宽度,主要用于使用html或者react展示图形的时候,设置一个固定的宽度\n */\n forceBoundsWidth: number | (() => number) | undefined;\n /**\n * 强制设置的bounds高度,主要用于使用html或者react展示图形的时候,设置一个固定的高度\n */\n forceBoundsHeight: number | (() => number) | undefined;\n /**\n * 透明度,会同时影响填充和描边\n */\n opacity: number;\n /**\n * 影子节点\n */\n shadowGraphic?: IGraphic | undefined;\n /**\n * 背景填充模式(与具体图元有关)\n */\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n /**\n * 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n */\n backgroundFit: boolean;\n /**\n * 是否保持背景图的宽高比\n */\n backgroundKeepAspectRatio: boolean;\n /**\n * 背景图缩放,只在no-repeat的时候生效\n */\n backgroundScale: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetX: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetY: number;\n /**\n * 背景图是否裁切,是否调用clip避免绘制到图元外部\n */\n backgroundClip: boolean;\n /**\n * 背景圆角半径\n */\n backgroundCornerRadius: number | number[];\n /**\n * 背景透明度\n */\n backgroundOpacity: number;\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n // 纹理是否自动做动画\n autoAnimateTexture: boolean;\n // 如果做动画的话,这里代表ratio\n textureRatio: number;\n textureOptions: any;\n background:\n | IBackgroundType\n | {\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n background: IBackgroundType;\n /**\n * 背景的x方向偏移量\n */\n dx?: number;\n /**\n * 背景的y方向偏移量\n */\n dy?: number;\n /**\n * 背景宽度\n */\n width?: number;\n /**\n * 背景高度\n */\n height?: number;\n /**\n * 背景的x坐标\n */\n x?: number;\n /**\n * 背景的y坐标\n */\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n /**\n * 纹理的类型\n */\n texture: TextureType | string;\n /**\n * 纹理的颜色\n */\n textureColor: string;\n /**\n * 纹理的大小\n */\n textureSize: number;\n /**\n * 纹理的间隙\n */\n texturePadding: number;\n\n blur: number;\n /**\n * 设置图形对应的鼠标样式\n */\n cursor: Cursor | null;\n // @deprecated 用处少废弃,后续考虑新设计API\n filter: string;\n renderStyle?: 'default' | 'rough' | any;\n /**\n * HTML的dom或者string\n */\n html:\n | ({\n /**\n * dom字符串或者dom\n */\n dom: string | HTMLElement;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n /**\n * 使用react元素渲染内容\n */\n react:\n | ({\n /**\n * react场景节点\n */\n element: any;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n };\n\nexport type IPickStyle = {\n /**\n * 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n */\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n /**\n * 包围盒的padding\n */\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise' | 'empty';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n /**\n * 分组下的层级,层级越小越先绘制\n */\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n shadowPickMode?: 'full' | 'graphic';\n /**\n * 全局范围的层级,设置了这个属性的图形,会提取到交互层进行渲染\n */\n globalZIndex: number;\n /**\n * canvas 的合成方式\n */\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n /**\n * 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n */\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n /**\n * 绘制fill和stroke的顺序,为0表示fill先绘制,1表示stroke先绘制\n */\n fillStrokeOrder: number;\n /**\n * @since 0.20.15\n * 保持stroke的scale,默认为false,为true的话stroke显示的宽度会随着scale变化\n */\n keepStrokeScale: boolean;\n\n /**\n * @since 0.22.2\n * 裁剪路径,用于裁剪图形,用于普通图元的裁剪\n * 由于一般情况下普通图元只需要一个形状即可,所以这里不需要配置具体的位置和大小,强制中心在图元中心,宽高和图元Bounds宽高一致\n * 不考虑其他复杂情况,否则配置项就非常多了,比如多路径,或者配置位置大小等,如果配置大小那还得用户自己去拿图元的大小,目前没有这种需求\n */\n clipConfig: {\n shape: string;\n } | null;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n slience?: boolean;\n id?: number | string;\n timeline?: ITimeline;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n /**\n * 保存语法上下文\n */\n context?: Record<string, any>;\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n getClipPath: () => ISymbolClass | null;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate?: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n getGraphicTheme: () => T;\n\n getAttributes: (final?: boolean) => Partial<T>;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType, IOBBBounds } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget, ITimeline } from './animation';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\nimport type { ISymbolClass } from './graphic/symbol';\n\ntype IStrokeSeg = {\n /**\n * 百分比\n */\n start: number;\n /**\n * 百分比\n * end和length二选一\n */\n end: number;\n /**\n * 像素长度\n */\n length: number;\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph'\n | string;\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n /**\n * x坐标\n */\n x: number;\n /**\n * y坐标\n */\n y: number;\n /**\n * z坐标\n */\n z: number;\n /**\n * x方向偏移量\n */\n dx: number;\n /**\n * y方向偏移量\n */\n dy: number;\n /**\n * z方向偏移量\n */\n dz: number;\n /**\n * x方向的滚动值\n */\n scrollX: number;\n /**\n * y方向的滚动值\n */\n scrollY: number;\n /**\n * x方向的缩放值\n */\n scaleX: number;\n /**\n * y方向的缩放值\n */\n scaleY: number;\n /**\n * z方向的缩放值\n */\n scaleZ: number;\n /**\n * 绕z轴的转角,即xy平面上的旋转角度\n */\n angle: number;\n /**\n * 绕x轴的转角\n */\n alpha: number;\n /**\n * 绕y轴的转角\n */\n beta: number;\n /**\n * 应用缩放的中心\n */\n scaleCenter: [number | string, number | string];\n /**\n * 基于AABB的锚点位置,用于简单的定位某些path\n */\n anchor: [number | string, number | string];\n /**\n * 3d的锚点位置\n */\n anchor3d: [number | string, number | string, number] | [number | string, number | string];\n /**\n * 处理矩阵,在正常计算完变换矩阵之后,会将该矩阵乘到变换矩阵上得到最终的变换矩阵\n */\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n /**\n * 图形的填充透明度\n */\n fillOpacity: number;\n /**\n * 图形模糊效果程度\n */\n shadowBlur: number;\n /**\n * 图形的阴影颜色\n */\n shadowColor: string;\n /**\n * 阴影水平偏移距离\n */\n shadowOffsetX: number;\n /**\n * 阴影垂直偏移距离\n */\n shadowOffsetY: number;\n /**\n * 图形的填充颜色\n */\n fill: IFillType;\n};\n\nexport type ILayout = {\n /**\n * 设置对齐方式\n */\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n /**\n * 边距离边缘的距离\n */\n distance: number | string;\n /**\n * 是否显示边框,默认是不显示的\n */\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n /**\n * 外部边框的样式配置,默认不展示外部边框\n */\n outerBorder: Partial<IBorderStyle>;\n /**\n * 内部边框的样式配置\n */\n innerBorder: Partial<IBorderStyle>;\n /**\n * 描边的透明度\n */\n strokeOpacity: number;\n /**\n * 设置线条虚线样式的属性,它通过定义实线和空白的交替长度来创建虚线效果\n */\n lineDash: number[];\n\n /**\n * 设置虚线样式的起始偏移量\n */\n lineDashOffset: number;\n\n /**\n * 设置线条的宽度\n */\n lineWidth: number;\n\n /**\n * 设置线条末端的样式\n */\n lineCap: CanvasLineCap;\n\n /**\n * 设置线条拐角的样式\n */\n lineJoin: CanvasLineJoin;\n\n /**\n * 设置线条拐角处的斜接限制\n */\n miterLimit: number;\n /**\n * 描边的boundsBuffer,用于控制bounds的buffer\n */\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n /**\n * 连接,取零或者断开\n */\n connectedType: 'connect' | 'none';\n /**\n * 连接线的样式配置\n */\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport interface SimpleDomStyleOptions {\n /**\n * 容器的宽度\n */\n width: number;\n /**\n * 容器的高度\n */\n height: number;\n /**\n * 容器的样式设置\n */\n style?:\n | string\n | Record<string, any>\n | ((\n pos: { top: number; left: number; width: number; height: number },\n graphic: IGraphic,\n wrapContainer: HTMLElement\n ) => Record<string, any>); // 容器的样式\n}\n\nexport interface CommonDomOptions {\n /**\n * 全局唯一的id\n */\n id?: string;\n /**\n * 容器元素的id或者dom元素\n */\n container: string | HTMLElement | null;\n /**\n * 是否显示\n */\n visible?: boolean;\n /**\n * 是否支持事件冒泡\n */\n pointerEvents?: boolean | string;\n /**\n * 可穿透的事件列表\n * @since 0.21.2\n */\n penetrateEventList?: string[];\n /**\n * 定位类型\n * 'position' - 根据挂载图形节点的坐标也就是x,y进行定位\n * 'boundsLeftTop' - 定位到挂载图形节点bounds的左上角\n * 'left' - 定位到挂载图形节点bounds 的左侧\n * 'right' - 定位到挂载图形节点bounds 的右侧\n * 'bottom' - 定位到挂载图形节点bounds 的底部\n * 'top' - 定位到挂载图形节点bounds 的顶部\n * 'center' - 定位到挂载图形节点bounds 的中心\n * 'top-left' - 定位到挂载图形节点bounds 的左上角\n * 'top-right' - 定位到挂载图形节点bounds 的右上角\n * 'bottom-left' - 定位到挂载图形节点bounds 的左下角\n * 'bottom-right' - 定位到挂载图形节点bounds 的右下角\n */\n anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;\n}\n\nexport type IRoughStyle = {\n fillStyle: 'hachure' | 'solid' | 'zigzag' | 'cross-hatch' | 'dots' | 'sunburst' | 'dashed' | 'zigzag-line';\n roughness: number;\n bowing: number;\n};\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n /**\n * 强制设置的bounds宽度,主要用于使用html或者react展示图形的时候,设置一个固定的宽度\n */\n forceBoundsWidth: number | (() => number) | undefined;\n /**\n * 强制设置的bounds高度,主要用于使用html或者react展示图形的时候,设置一个固定的高度\n */\n forceBoundsHeight: number | (() => number) | undefined;\n /**\n * 透明度,会同时影响填充和描边\n */\n opacity: number;\n /**\n * 影子节点\n */\n shadowGraphic?: IGraphic | undefined;\n /**\n * 背景填充模式(与具体图元有关)\n */\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n /**\n * 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n */\n backgroundFit: boolean;\n /**\n * 是否保持背景图的宽高比\n */\n backgroundKeepAspectRatio: boolean;\n /**\n * 背景图缩放,只在no-repeat的时候生效\n */\n backgroundScale: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetX: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetY: number;\n /**\n * 背景图是否裁切,是否调用clip避免绘制到图元外部\n */\n backgroundClip: boolean;\n /**\n * 背景圆角半径\n */\n backgroundCornerRadius: number | number[];\n /**\n * 背景透明度\n */\n backgroundOpacity: number;\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n // 纹理是否自动做动画\n autoAnimateTexture: boolean;\n // 如果做动画的话,这里代表ratio\n textureRatio: number;\n textureOptions: any;\n background:\n | IBackgroundType\n | {\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n background: IBackgroundType;\n /**\n * 背景的x方向偏移量\n */\n dx?: number;\n /**\n * 背景的y方向偏移量\n */\n dy?: number;\n /**\n * 背景宽度\n */\n width?: number;\n /**\n * 背景高度\n */\n height?: number;\n /**\n * 背景的x坐标\n */\n x?: number;\n /**\n * 背景的y坐标\n */\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n /**\n * 纹理的类型\n */\n texture: TextureType | string;\n /**\n * 纹理的颜色\n */\n textureColor: string;\n /**\n * 纹理的大小\n */\n textureSize: number;\n /**\n * 纹理的间隙\n */\n texturePadding: number;\n\n blur: number;\n /**\n * 设置图形对应的鼠标样式\n */\n cursor: Cursor | null;\n // @deprecated 用处少废弃,后续考虑新设计API\n filter: string;\n renderStyle?: 'default' | 'rough' | any;\n roughStyle?: IRoughStyle | null;\n /**\n * HTML的dom或者string\n */\n html:\n | ({\n /**\n * dom字符串或者dom\n */\n dom: string | HTMLElement;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n /**\n * 使用react元素渲染内容\n */\n react:\n | ({\n /**\n * react场景节点\n */\n element: any;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n /**\n * 使用vue组件渲染内容\n */\n vue:\n | ({\n /**\n * vue 虚拟节点\n */\n element: any;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n };\n\nexport type IPickStyle = {\n /**\n * 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n */\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n /**\n * 包围盒的padding\n */\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise' | 'empty';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n /**\n * 分组下的层级,层级越小越先绘制\n */\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n shadowPickMode?: 'full' | 'graphic';\n /**\n * 全局范围的层级,设置了这个属性的图形,会提取到交互层进行渲染\n */\n globalZIndex: number;\n /**\n * canvas 的合成方式\n */\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n /**\n * 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n */\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n /**\n * 绘制fill和stroke的顺序,为0表示fill先绘制,1表示stroke先绘制\n */\n fillStrokeOrder: number;\n /**\n * @since 0.20.15\n * 保持stroke的scale,默认为false,为true的话stroke显示的宽度会随着scale变化\n */\n keepStrokeScale: boolean;\n\n /**\n * @since 0.22.2\n * 裁剪路径,用于裁剪图形,用于普通图元的裁剪\n * 由于一般情况下普通图元只需要一个形状即可,所以这里不需要配置具体的位置和大小,强制中心在图元中心,宽高和图元Bounds宽高一致\n * 不考虑其他复杂情况,否则配置项就非常多了,比如多路径,或者配置位置大小等,如果配置大小那还得用户自己去拿图元的大小,目前没有这种需求\n */\n clipConfig: {\n shape: string;\n } | null;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n slience?: boolean;\n id?: number | string;\n timeline?: ITimeline;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n /**\n * 保存语法上下文\n */\n context?: Record<string, any>;\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 不考虑transform的宽高,特殊情况下会使用到\n widthWithoutTransform?: number;\n heightWithoutTransform?: number;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n getClipPath: () => ISymbolClass | null;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate?: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n getGraphicTheme: () => T;\n\n getAttributes: (final?: boolean) => Partial<T>;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
|
package/es/interface/render.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ export interface IRenderService {
|
|
|
25
25
|
renderTreeRoots: IGraphic[];
|
|
26
26
|
renderLists: IGraphic[];
|
|
27
27
|
drawParams: IRenderServiceDrawParams;
|
|
28
|
+
drawContribution: IDrawContribution;
|
|
28
29
|
prepare: (updateBounds: boolean) => void;
|
|
29
30
|
prepareRenderList: () => void;
|
|
30
31
|
beforeDraw: (params: IRenderServiceDrawParams) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/render.ts"],"names":[],"mappings":"","file":"render.js","sourcesContent":["import type { IAABBBounds, IBounds, IMatrix, IMatrixLike } from '@visactor/vutils';\nimport type { IColor } from './color';\nimport type { IContext2d } from './context';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IMarkAttribute, IThemeAttribute } from './graphic/creator';\nimport type { IFullThemeSpec } from './graphic/theme';\nimport type { ILayer } from './layer';\nimport type { IStage } from './stage';\nimport type { IGroup } from './graphic/group';\nimport type { MaybePromise } from './common';\nimport type { ISyncHook } from './sync-hook';\n\n// 用于绘制的参数,提供context\n// TODO: 考虑是否可以隐藏上下文类型\nexport interface IRenderServiceDrawParams {\n context?: IContext2d;\n\n // 绘制的区域以及是否需要清屏\n clear?: string | IColor | boolean;\n viewBox: IBounds;\n transMatrix?: IMatrixLike;\n stage: IStage;\n layer: ILayer;\n renderService: IRenderService;\n updateBounds: boolean;\n renderStyle?: string;\n}\n\nexport interface IRenderService {\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n\n prepare: (updateBounds: boolean) => void;\n prepareRenderList: () => void;\n beforeDraw: (params: IRenderServiceDrawParams) => void;\n draw: (params: IRenderServiceDrawParams) => void;\n afterDraw: (params: IRenderServiceDrawParams) => void;\n render: (groups: IGroup[], params: IRenderServiceDrawParams) => MaybePromise<void>;\n}\n\nexport interface IDrawContext extends IRenderServiceDrawParams {\n startAtId?: number;\n break?: boolean;\n restartIncremental?: boolean;\n // multi图元开始的位置\n multiGraphicOptions?: {\n startAtIdx: number;\n length: number;\n };\n in3dInterceptor?: boolean;\n drawContribution?: IDrawContribution;\n // hack内容\n hack_pieFace?: 'inside' | 'bottom' | 'top' | 'outside';\n // group是否有旋转,每一个renderGroup都会更新,用于在renderItem的时候给子节点使用\n isGroupScroll?: boolean;\n}\n\nexport interface IDrawContribution {\n hooks?: {\n completeDraw: ISyncHook<[]>;\n };\n dirtyBounds?: IAABBBounds;\n backupDirtyBounds?: IAABBBounds;\n rendering?: boolean;\n currentRenderMap: Map<number, IGraphicRender>;\n defaultRenderMap: Map<number, IGraphicRender>;\n styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n draw: (renderService: IRenderService, drawParams: IDrawContext) => MaybePromise<void>;\n afterDraw?: (renderService: IRenderService, drawParams: IDrawContext) => MaybePromise<void>;\n getRenderContribution: (graphic: IGraphic) => IGraphicRender | null;\n renderGroup: (group: IGroup, drawContext: IDrawContext, matrix: IMatrixLike, skipSort?: boolean) => void;\n renderItem: (graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) => void;\n}\n\nexport interface IGraphicRenderDrawParams {\n beforeDrawCb?: () => void;\n afterDrawCb?: () => void;\n drawingCb?: () => void;\n skipDraw?: boolean;\n theme?: IFullThemeSpec;\n // TODO 这里是为了性能优化,之前使用匿名函数的方式闭包等逻辑会影响性能,现在直接将函数显示定义,将参数传入提升性能,就是牺牲了代码可读性\n // 用于在group中进行递归渲染的参数\n renderInGroupParams?: {\n skipSort?: boolean;\n nextM?: IMatrixLike;\n };\n // 用于在group中进行递归渲染的函数\n renderInGroup?: (skipSort: boolean, group: IGroup, drawContext: IDrawContext, nextM: IMatrixLike) => void;\n}\n\nexport interface IGraphicRender {\n type: string; // 图元类型\n numberType: number;\n style?: string;\n z?: number;\n draw: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) => void;\n drawShape?: (\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) => void;\n}\n\nexport interface IBeforeRenderConstribution {\n apply: (renderService: IRenderService) => MaybePromise<void>;\n}\n\nexport interface IRenderSelector {\n selector: (graphic: IGraphic) => IGraphicRender | null;\n}\n\nexport interface IDrawItemInterceptorContribution {\n order: number;\n beforeDrawItem?: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) => boolean;\n afterDrawItem?: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) => boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/interface/render.ts"],"names":[],"mappings":"","file":"render.js","sourcesContent":["import type { IAABBBounds, IBounds, IMatrix, IMatrixLike } from '@visactor/vutils';\nimport type { IColor } from './color';\nimport type { IContext2d } from './context';\nimport type { IGraphic, IGraphicAttribute } from './graphic';\nimport type { IMarkAttribute, IThemeAttribute } from './graphic/creator';\nimport type { IFullThemeSpec } from './graphic/theme';\nimport type { ILayer } from './layer';\nimport type { IStage } from './stage';\nimport type { IGroup } from './graphic/group';\nimport type { MaybePromise } from './common';\nimport type { ISyncHook } from './sync-hook';\n\n// 用于绘制的参数,提供context\n// TODO: 考虑是否可以隐藏上下文类型\nexport interface IRenderServiceDrawParams {\n context?: IContext2d;\n\n // 绘制的区域以及是否需要清屏\n clear?: string | IColor | boolean;\n viewBox: IBounds;\n transMatrix?: IMatrixLike;\n stage: IStage;\n layer: ILayer;\n renderService: IRenderService;\n updateBounds: boolean;\n renderStyle?: string;\n}\n\nexport interface IRenderService {\n dirtyBounds: IBounds;\n renderTreeRoots: IGraphic[]; // 此次render的数组\n renderLists: IGraphic[];\n drawParams: IRenderServiceDrawParams;\n drawContribution: IDrawContribution;\n\n prepare: (updateBounds: boolean) => void;\n prepareRenderList: () => void;\n beforeDraw: (params: IRenderServiceDrawParams) => void;\n draw: (params: IRenderServiceDrawParams) => void;\n afterDraw: (params: IRenderServiceDrawParams) => void;\n render: (groups: IGroup[], params: IRenderServiceDrawParams) => MaybePromise<void>;\n}\n\nexport interface IDrawContext extends IRenderServiceDrawParams {\n startAtId?: number;\n break?: boolean;\n restartIncremental?: boolean;\n // multi图元开始的位置\n multiGraphicOptions?: {\n startAtIdx: number;\n length: number;\n };\n in3dInterceptor?: boolean;\n drawContribution?: IDrawContribution;\n // hack内容\n hack_pieFace?: 'inside' | 'bottom' | 'top' | 'outside';\n // group是否有旋转,每一个renderGroup都会更新,用于在renderItem的时候给子节点使用\n isGroupScroll?: boolean;\n}\n\nexport interface IDrawContribution {\n hooks?: {\n completeDraw: ISyncHook<[]>;\n };\n dirtyBounds?: IAABBBounds;\n backupDirtyBounds?: IAABBBounds;\n rendering?: boolean;\n currentRenderMap: Map<number, IGraphicRender>;\n defaultRenderMap: Map<number, IGraphicRender>;\n styleRenderMap: Map<string, Map<number, IGraphicRender>>;\n draw: (renderService: IRenderService, drawParams: IDrawContext) => MaybePromise<void>;\n afterDraw?: (renderService: IRenderService, drawParams: IDrawContext) => MaybePromise<void>;\n getRenderContribution: (graphic: IGraphic) => IGraphicRender | null;\n renderGroup: (group: IGroup, drawContext: IDrawContext, matrix: IMatrixLike, skipSort?: boolean) => void;\n renderItem: (graphic: IGraphic, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) => void;\n}\n\nexport interface IGraphicRenderDrawParams {\n beforeDrawCb?: () => void;\n afterDrawCb?: () => void;\n drawingCb?: () => void;\n skipDraw?: boolean;\n theme?: IFullThemeSpec;\n // TODO 这里是为了性能优化,之前使用匿名函数的方式闭包等逻辑会影响性能,现在直接将函数显示定义,将参数传入提升性能,就是牺牲了代码可读性\n // 用于在group中进行递归渲染的参数\n renderInGroupParams?: {\n skipSort?: boolean;\n nextM?: IMatrixLike;\n };\n // 用于在group中进行递归渲染的函数\n renderInGroup?: (skipSort: boolean, group: IGroup, drawContext: IDrawContext, nextM: IMatrixLike) => void;\n}\n\nexport interface IGraphicRender {\n type: string; // 图元类型\n numberType: number;\n style?: string;\n z?: number;\n draw: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) => void;\n drawShape?: (\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ) => void;\n}\n\nexport interface IBeforeRenderConstribution {\n apply: (renderService: IRenderService) => MaybePromise<void>;\n}\n\nexport interface IRenderSelector {\n selector: (graphic: IGraphic) => IGraphicRender | null;\n}\n\nexport interface IDrawItemInterceptorContribution {\n order: number;\n beforeDrawItem?: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) => boolean;\n afterDrawItem?: (\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) => boolean;\n}\n"]}
|
package/es/modules.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IGlobal, IGraphicService } from './interface';
|
|
1
|
+
import type { IGlobal, IGraphicService, IRenderService } from './interface';
|
|
2
2
|
import type { IGraphicUtil, ILayerService, ITransformUtil } from './interface/core';
|
|
3
3
|
export declare function preLoadAllModule(): void;
|
|
4
4
|
export declare namespace preLoadAllModule {
|
|
@@ -8,4 +8,5 @@ export declare const vglobal: IGlobal;
|
|
|
8
8
|
export declare const graphicUtil: IGraphicUtil;
|
|
9
9
|
export declare const transformUtil: ITransformUtil;
|
|
10
10
|
export declare const graphicService: IGraphicService;
|
|
11
|
+
export declare const renderService: IRenderService;
|
|
11
12
|
export declare const layerService: ILayerService;
|
package/es/modules.js
CHANGED
|
@@ -24,6 +24,8 @@ import { container } from "./container";
|
|
|
24
24
|
|
|
25
25
|
import { VGlobal } from "./constants";
|
|
26
26
|
|
|
27
|
+
import { RenderService } from "./render";
|
|
28
|
+
|
|
27
29
|
export function preLoadAllModule() {
|
|
28
30
|
preLoadAllModule.__loaded || (preLoadAllModule.__loaded = !0, container.load(coreModule),
|
|
29
31
|
container.load(graphicModule), container.load(renderModule), container.load(pickModule),
|
|
@@ -48,6 +50,10 @@ export const graphicService = container.get(GraphicService);
|
|
|
48
50
|
|
|
49
51
|
application.graphicService = graphicService;
|
|
50
52
|
|
|
53
|
+
export const renderService = container.get(RenderService);
|
|
54
|
+
|
|
55
|
+
application.renderService = renderService;
|
|
56
|
+
|
|
51
57
|
export const layerService = container.get(LayerService);
|
|
52
58
|
|
|
53
59
|
application.layerService = layerService;
|
package/es/modules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,wBAAwB,MAAM,8BAA8B,CAAC;AACpE,OAAO,uBAAuB,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAC7C,OAAO,YAAY,MAAM,yBAAyB,CAAC;AACnD,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,OAAO,aAAa,MAAM,0CAA0C,CAAC;AACrE,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,wBAAwB,MAAM,8BAA8B,CAAC;AACpE,OAAO,uBAAuB,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIhD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,gBAAgB;IAC9B,IAAI,gBAAgB,CAAC,QAAQ,EAAE;QAC7B,OAAO;KACR;IACD,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7B,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE3B,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7B,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACpC,uBAAuB,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,gBAAgB,CAAC,QAAQ,GAAG,KAAK,CAAC;AAElC,gBAAgB,EAAE,CAAC;AAKnB,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAU,OAAO,CAAC,CAAC;AACvD,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,GAAG,CAAe,WAAW,CAAC,CAAC;AACpE,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,CAAiB,aAAa,CAAC,CAAC;AAC1E,WAAW,CAAC,aAAa,GAAG,aAAa,CAAC;AAC1C,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,CAAkB,cAAc,CAAC,CAAC;AAC7E,WAAW,CAAC,cAAc,GAAG,cAAc,CAAC;AAC5C,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC,GAAG,CAAiB,aAAa,CAAC,CAAC;AAC1E,WAAW,CAAC,aAAa,GAAG,aAAa,CAAC;AAa1C,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAgB,YAAY,CAAC,CAAC;AACvE,WAAW,CAAC,YAAY,GAAG,YAAY,CAAC","file":"modules.js","sourcesContent":["import coreModule from './core/core-modules';\nimport renderModule from './render/render-modules';\nimport pickModule from './picker/pick-modules';\n// import allocatorModule from './allocator/allocator-modules';\nimport graphicModule from './graphic/graphic-service/graphic-module';\nimport pluginModule from './plugins/plugin-modules';\nimport loadBuiltinContributions from './core/contributions/modules';\nimport loadRenderContributions from './render/contributions/modules';\n// import loadPickContributions from './picker/contributions/modules';\n// import loadCanvasContributions from './canvas/contributions/modules';\nimport { LayerService } from './core/constants';\n// import { IMat4Allocate, IMatrixAllocate, Mat4Allocate, MatrixAllocate } from './allocator/matrix-allocate';\n// import { GlobalPickerService } from './picker/constants';\nimport type { IGlobal, IGraphicService, IPickerService, IRenderService } from './interface';\nimport { application } from './application';\nimport type { IGraphicUtil, ILayerService, ITransformUtil } from './interface/core';\nimport { GraphicService } from './graphic/constants';\nimport { GraphicUtil, TransformUtil } from './core/constants';\nimport { container } from './container';\nimport { VGlobal } from './constants';\nimport { RenderService } from './render';\n\nexport function preLoadAllModule() {\n if (preLoadAllModule.__loaded) {\n return;\n }\n preLoadAllModule.__loaded = true;\n container.load(coreModule);\n container.load(graphicModule);\n container.load(renderModule);\n container.load(pickModule);\n // container.load(allocatorModule);\n container.load(pluginModule);\n loadBuiltinContributions(container);\n loadRenderContributions(container);\n}\n\npreLoadAllModule.__loaded = false;\n\npreLoadAllModule();\n// loadPickContributions(container);\n// loadCanvasContributions(container);\n\n// 全局变量\nexport const vglobal = container.get<IGlobal>(VGlobal);\napplication.global = vglobal;\nexport const graphicUtil = container.get<IGraphicUtil>(GraphicUtil);\napplication.graphicUtil = graphicUtil;\nexport const transformUtil = container.get<ITransformUtil>(TransformUtil);\napplication.transformUtil = transformUtil;\nexport const graphicService = container.get<IGraphicService>(GraphicService);\napplication.graphicService = graphicService;\nexport const renderService = container.get<IRenderService>(RenderService);\napplication.renderService = renderService;\n// export const matrixAllocate = container.get<IMatrixAllocate>(MatrixAllocate);\n// export const mat4Allocate = container.get<IMat4Allocate>(Mat4Allocate);\n// export const canvasAllocate = container.get<ICanvasAllocate>(CanvasAllocate);\n// export const arcAllocate = container.get<IArcAllocate>(ArcAllocate);\n// export const areaAllocate = container.get<IAreaAllocate>(AreaAllocate);\n// export const circleAllocate = container.get<ICircleAllocate>(CircleAllocate);\n// export const lineAllocate = container.get<ILineAllocate>(LineAllocate);\n// export const pathAllocate = container.get<IPathAllocate>(PathAllocate);\n// export const rectAllocate = container.get<IRectAllocate>(RectAllocate);\n// export const symbolAllocate = container.get<ISymbolAllocate>(SymbolAllocate);\n// export const textAllocate = container.get<ITextAllocate>(TextAllocate);\n// export const pickerService = container.get<IPickerService>(GlobalPickerService);\nexport const layerService = container.get<ILayerService>(LayerService);\napplication.layerService = layerService;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerStarGraphic(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/register/register-star.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,MAAM,UAAU,mBAAmB;IACjC,cAAc,CAAC,sBAAsB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC5D,CAAC","file":"register-star.js","sourcesContent":["import { createStar } from '../graphic/star';\nimport { graphicCreator } from '../graphic/graphic-creator';\n\nexport function registerStarGraphic() {\n graphicCreator.RegisterGraphicCreator('star', createStar);\n}\n"]}
|
|
@@ -195,7 +195,7 @@ let DefaultCanvasAreaRender = class extends BaseRender {
|
|
|
195
195
|
} else startP = points[0], endP = points[points.length - 1];
|
|
196
196
|
const xTotalLength = abs(endP.x - startP.x), yTotalLength = abs(endP.y - startP.y);
|
|
197
197
|
direction = null == endP.x1 ? Direction.ROW : null == endP.y1 ? Direction.COLUMN : Number.isFinite(xTotalLength + yTotalLength) ? xTotalLength > yTotalLength ? Direction.ROW : Direction.COLUMN : Direction.ROW,
|
|
198
|
-
drawAreaSegments(context
|
|
198
|
+
drawAreaSegments(context, cache, clipRange, {
|
|
199
199
|
offsetX: offsetX,
|
|
200
200
|
offsetY: offsetY,
|
|
201
201
|
offsetZ: offsetZ,
|
|
@@ -211,7 +211,7 @@ let DefaultCanvasAreaRender = class extends BaseRender {
|
|
|
211
211
|
if (!1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute); else {
|
|
212
212
|
const {stroke: stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke} = attribute;
|
|
213
213
|
isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(),
|
|
214
|
-
drawSegments(context
|
|
214
|
+
drawSegments(context, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction.ROW ? "x" : "y", {
|
|
215
215
|
offsetX: offsetX,
|
|
216
216
|
offsetY: offsetY,
|
|
217
217
|
offsetZ: offsetZ
|