@visactor/vrender-core 0.19.24-alpha.4 → 0.19.24-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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/contributions/rect-contribution-render.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6CAA2C;AAC3C,sEAA+D;AAW/D,kEAAkE;AAClE,yEAAqF;AACrF,wDAA+D;AAC/D,oDAAsE;AACtE,yFAA0F;AAE1F,MAAa,6BAA6B;IAA1C;QACE,SAAI,GAA+B,kCAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA4HpB,CAAC;IA3HC,SAAS,CACP,IAAW,EACX,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAA8C,EAC9C,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QACpD,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;QACnE,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;QACnE,IAAI,CAAC,CAAC,aAAa,IAAI,aAAa,CAAC,EAAE;YACrC,OAAO;SACR;QACD,MAAM,EACJ,YAAY,GAAG,aAAa,CAAC,YAAY,EACzC,OAAO,GAAG,aAAa,CAAC,OAAO,EAC/B,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,CAAC,EAC5B,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,CAAC,EAC5B,MAAM,GAAG,aAAa,CAAC,MAAM,EAC7B,MAAM,GAAG,aAAa,CAAC,MAAM,EAC7B,EAAE,EACF,EAAE,EACH,GAAG,IAAI,CAAC,SAAS,CAA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C,CAAC,CAAC;YAC1D,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACtB;QAED,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;CACF,CAAA;AA1GY,gCAAgC;IAD5C,IAAA,2BAAU,GAAE;GACA,gCAAgC,CA0G5C;AA1GY,4EAAgC;AA4GhC,QAAA,6BAA6B,GAAG,IAAI,6BAA6B,EAAE,CAAC;AAGpE,QAAA,oCAAoC,GAAG,uEAAoC,CAAC;AAC5E,QAAA,uCAAuC,GAAG,kEAAuC,CAAC","file":"rect-contribution-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { injectable } from '../../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IRectGraphicAttribute,\n IThemeAttribute,\n IRectRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultRectRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: Required<IRectGraphicAttribute>,\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 ) {\n const { outerBorder, innerBorder } = rect.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n cornerRadius = rectAttribute.cornerRadius,\n opacity = rectAttribute.opacity,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n scaleX = rectAttribute.scaleX,\n scaleY = rectAttribute.scaleY,\n x1,\n y1\n } = rect.attribute;\n\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - x) || 0;\n height = (height ?? y1 - y) || 0;\n\n const doStrokeOuter = !!(outerBorder && outerBorder.stroke);\n const doStrokeInner = !!(innerBorder && innerBorder.stroke);\n\n if (doOuterBorder) {\n const { distance = rectAttribute.outerBorder.distance } = outerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x - d;\n const nextY = y - d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width + dw, height + dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width + dw, height + dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, outerBorder, rectAttribute.outerBorder);\n } else if (doStrokeOuter) {\n // 存在stroke\n const lastOpacity = (rectAttribute.outerBorder as any).opacity;\n (rectAttribute.outerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n outerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.outerBorder as any\n );\n (rectAttribute.outerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n\n if (doInnerBorder) {\n const { distance = rectAttribute.innerBorder.distance } = innerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x + d;\n const nextY = y + d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width - dw, height - dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width - dw, height - dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, innerBorder, rectAttribute.innerBorder);\n } else if (doStrokeInner) {\n // 存在stroke\n const lastOpacity = (rectAttribute.innerBorder as any).opacity;\n (rectAttribute.innerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n innerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.innerBorder as any\n );\n (rectAttribute.innerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n }\n}\n\n@injectable()\nexport class SplitRectBeforeRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n group: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\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 doFillOrStroke?: { doFill: boolean; doStroke: boolean }\n ) {\n const { stroke = groupAttribute.stroke } = group.attribute as any;\n\n // 数组且存在为false的项目,那就不绘制\n if (Array.isArray(stroke) && stroke.some(s => s === false)) {\n doFillOrStroke.doStroke = false;\n }\n }\n}\n\n@injectable()\nexport class SplitRectAfterRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\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 ) {\n const {\n x1,\n y1,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y,\n stroke = groupAttribute.stroke,\n cornerRadius = groupAttribute.cornerRadius\n } = rect.attribute as any;\n\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不是数组\n if (!(Array.isArray(stroke) && stroke.some(s => s === false))) {\n return;\n }\n\n context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute);\n\n // 带不同stroke边框\n if (!(cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0)))) {\n let lastStrokeI = 0;\n let lastStroke: any;\n createRectPath(\n context,\n x,\n y,\n width,\n height,\n cornerRadius,\n new Array(4).fill(0).map((_, i) => (x1: number, y1: number, x2: number, y2: number) => {\n if (stroke[i]) {\n if (!(lastStrokeI === i - 1 && stroke[i] === lastStroke)) {\n context.setStrokeStyle(rect, { ...rect.attribute, stroke: stroke[i] }, x, y, groupAttribute);\n context.beginPath();\n context.moveTo(x1, y1);\n lastStroke = stroke[i];\n }\n lastStrokeI = i;\n context.lineTo(x2, y2);\n context.stroke();\n }\n })\n );\n return;\n }\n\n // 单独处理每条边界,目前不考虑圆角\n context.beginPath();\n context.moveTo(x, y);\n // top\n if (stroke[0]) {\n context.lineTo(x + width, y);\n } else {\n context.moveTo(x + width, y);\n }\n // right\n if (stroke[1]) {\n context.lineTo(x + width, y + height);\n } else {\n context.moveTo(x + width, y + height);\n }\n // bottom\n if (stroke[2]) {\n context.lineTo(x, y + height);\n } else {\n context.moveTo(x, y + height);\n }\n // left\n if (stroke[3]) {\n // 没有close path是,起点和终点不连续,需要调整y保证不出现缺口\n const adjustY = stroke[0] ? y - context.lineWidth / 2 : y;\n context.lineTo(x, adjustY);\n } else {\n context.moveTo(x, y);\n }\n\n context.stroke();\n }\n}\n\nexport const defaultRectRenderContribution = new DefaultRectRenderContribution();\n// export const splitRectBeforeRenderContribution = new SplitRectBeforeRenderContribution();\n// export const splitRectAfterRenderContribution = new SplitRectAfterRenderContribution();\nexport const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/contributions/rect-contribution-render.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6CAA2C;AAC3C,sEAA+D;AAW/D,kEAAkE;AAClE,yEAAqF;AACrF,wDAA+D;AAC/D,oDAAsE;AACtE,yFAA0F;AAE1F,MAAa,6BAA6B;IAA1C;QACE,SAAI,GAA+B,kCAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IA4HpB,CAAC;IA3HC,SAAS,CACP,IAAW,EACX,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAA8C,EAC9C,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QACpD,MAAM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G,KAAK,EAAE,CAAC,CAAC,CAAC;SAC9B;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SACvC;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SACvC;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SAC/B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC;SAC/B;QAED,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE;YAEb,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACtB;QAED,OAAO,CAAC,MAAM,EAAE,CAAC;IACnB,CAAC;CACF,CAAA;AA9GY,gCAAgC;IAD5C,IAAA,2BAAU,GAAE;GACA,gCAAgC,CA8G5C;AA9GY,4EAAgC;AAgHhC,QAAA,6BAA6B,GAAG,IAAI,6BAA6B,EAAE,CAAC;AAGpE,QAAA,oCAAoC,GAAG,uEAAoC,CAAC;AAC5E,QAAA,uCAAuC,GAAG,kEAAuC,CAAC","file":"rect-contribution-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { injectable } from '../../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IRect,\n IRectGraphicAttribute,\n IThemeAttribute,\n IRectRenderContribution,\n IDrawContext\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultRectRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: Required<IRectGraphicAttribute>,\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 ) {\n const { outerBorder, innerBorder } = rect.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n const {\n cornerRadius = rectAttribute.cornerRadius,\n opacity = rectAttribute.opacity,\n x: originX = rectAttribute.x,\n y: originY = rectAttribute.y,\n scaleX = rectAttribute.scaleX,\n scaleY = rectAttribute.scaleY,\n x1,\n y1\n } = rect.attribute;\n\n let { width, height } = rect.attribute;\n\n width = (width ?? x1 - x) || 0;\n height = (height ?? y1 - y) || 0;\n\n const doStrokeOuter = !!(outerBorder && outerBorder.stroke);\n const doStrokeInner = !!(innerBorder && innerBorder.stroke);\n\n if (doOuterBorder) {\n const { distance = rectAttribute.outerBorder.distance } = outerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x - d;\n const nextY = y - d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width + dw, height + dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width + dw, height + dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, outerBorder, rectAttribute.outerBorder);\n } else if (doStrokeOuter) {\n // 存在stroke\n const lastOpacity = (rectAttribute.outerBorder as any).opacity;\n (rectAttribute.outerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n outerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.outerBorder as any\n );\n (rectAttribute.outerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n\n if (doInnerBorder) {\n const { distance = rectAttribute.innerBorder.distance } = innerBorder;\n const d = getScaledStroke(context, distance as number, context.dpr);\n const nextX = x + d;\n const nextY = y + d;\n const dw = d * 2;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(nextX, nextY, width - dw, height - dw);\n } else {\n context.beginPath();\n\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, nextX, nextY, width - dw, height - dw, cornerRadius);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute);\n\n if (strokeCb) {\n strokeCb(context, innerBorder, rectAttribute.innerBorder);\n } else if (doStrokeInner) {\n // 存在stroke\n const lastOpacity = (rectAttribute.innerBorder as any).opacity;\n (rectAttribute.innerBorder as any).opacity = opacity;\n context.setStrokeStyle(\n rect,\n innerBorder,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n rectAttribute.innerBorder as any\n );\n (rectAttribute.innerBorder as any).opacity = lastOpacity;\n context.stroke();\n }\n }\n }\n}\n\n@injectable()\nexport class SplitRectBeforeRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n group: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\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 doFillOrStroke?: { doFill: boolean; doStroke: boolean }\n ) {\n const { stroke = groupAttribute.stroke } = group.attribute as any;\n\n // 数组且存在为false的项目,那就不绘制\n if (Array.isArray(stroke) && stroke.some(s => s === false)) {\n doFillOrStroke.doStroke = false;\n }\n }\n}\n\n@injectable()\nexport class SplitRectAfterRenderContribution implements IRectRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: IRect,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n groupAttribute: Required<IRectGraphicAttribute>,\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 ) {\n const {\n x1,\n y1,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y,\n stroke = groupAttribute.stroke,\n cornerRadius = groupAttribute.cornerRadius\n } = rect.attribute as any;\n\n let { width, height } = rect.attribute;\n width = (width ?? x1 - originX) || 0;\n height = (height ?? y1 - originY) || 0;\n\n // 不是数组\n if (!(Array.isArray(stroke) && stroke.some(s => s === false))) {\n return;\n }\n\n context.setStrokeStyle(rect, rect.attribute, x, y, groupAttribute);\n\n // 带不同stroke边框\n if (!(cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0)))) {\n let lastStrokeI = 0;\n let lastStroke: any;\n createRectPath(\n context,\n x,\n y,\n width,\n height,\n cornerRadius,\n new Array(4).fill(0).map((_, i) => (x1: number, y1: number, x2: number, y2: number) => {\n if (stroke[i]) {\n if (!(lastStrokeI === i - 1 && stroke[i] === lastStroke)) {\n context.setStrokeStyle(rect, { ...rect.attribute, stroke: stroke[i] }, x, y, groupAttribute);\n context.beginPath();\n context.moveTo(x1, y1);\n lastStroke = stroke[i];\n }\n lastStrokeI = i;\n context.lineTo(x2, y2);\n context.stroke();\n if (i === 3) {\n context.beginPath();\n }\n }\n })\n );\n context.stroke();\n return;\n }\n\n // 单独处理每条边界,目前不考虑圆角\n context.beginPath();\n context.moveTo(x, y);\n // top\n if (stroke[0]) {\n context.lineTo(x + width, y);\n } else {\n context.moveTo(x + width, y);\n }\n // right\n if (stroke[1]) {\n context.lineTo(x + width, y + height);\n } else {\n context.moveTo(x + width, y + height);\n }\n // bottom\n if (stroke[2]) {\n context.lineTo(x, y + height);\n } else {\n context.moveTo(x, y + height);\n }\n // left\n if (stroke[3]) {\n // 没有close path是,起点和终点不连续,需要调整y保证不出现缺口\n const adjustY = stroke[0] ? y - context.lineWidth / 2 : y;\n context.lineTo(x, adjustY);\n } else {\n context.moveTo(x, y);\n }\n\n context.stroke();\n }\n}\n\nexport const defaultRectRenderContribution = new DefaultRectRenderContribution();\n// export const splitRectBeforeRenderContribution = new SplitRectBeforeRenderContribution();\n// export const splitRectAfterRenderContribution = new SplitRectAfterRenderContribution();\nexport const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
@@ -40,7 +40,7 @@ class ShadowRootDrawItemInterceptorContribution {
40
40
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m),
41
41
  drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
42
42
  }
43
- return drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix),
43
+ return drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrix_allocate_1.matrixAllocate.allocate(1, 0, 0, 1, 0, 0)),
44
44
  context.highPerformanceRestore(), drawContribution.dirtyBounds && drawContribution.backupDirtyBounds && (drawContribution.dirtyBounds.copy(tempDirtyBounds),
45
45
  drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds)), !0;
46
46
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAA4D;AAC5D,6CAAmD;AACnD,8CAAgF;AAchF,wEAAkE;AAClE,0DAA+D;AAGlD,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AASrE,MAAM,eAAe,GAAG,IAAI,mBAAU,EAAE,CAAC;AACzC,MAAM,qBAAqB,GAAG,IAAI,mBAAU,EAAE,CAAC;AAK/C,MAAa,yCAAyC;IAAtD;QACE,UAAK,GAAW,CAAC,CAAC;IAoFpB,CAAC;IAnFC,aAAa,CACX,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,gBAAmC,EACnC,MAAiC;QAGjC,IACE,OAAO,CAAC,SAAS,CAAC,aAAa,IAAI,IAAI;YACvC,OAAO,CAAC,UAAU;YAClB,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,aAAa,GAAG,CAAC,EAC9C;YACA,OAAO,KAAK,CAAC;SACd;QACD,IACE,OAAO,CA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AAC,CAAC,EAAE;oBACnB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;gBACjB,CAAC,CAAC,CAAC;aACJ;iBAAM;gBACL,gBAAgB,CAAC,WAAW,CAAC,OAAiB,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;aAChG;SACF;aAAM;YACL,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;SACnD;QACD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,OAAO,CAAC,OAAO,EAAE,CAAC;QAElB,IAAI,OAAO,CAAC,WAAW,KAAK,eAAe,EAAE;YAC3C,8BAAY,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;SACxC;QACD,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;QAEtC,WAAW,CAAC,eAAe,GAAG,KAAK,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,OAAmB;QAC/B,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;CACF;AArKD,kEAqKC","file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds, pi2 } from '@visactor/vutils';\nimport { graphicCreator, mat3Tomat4, multiplyMat4Mat4 } from '../../../graphic';\nimport type {\n IArc,\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicAttribute,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { ARC3D_NUMBER_TYPE } from '../../../graphic/constants';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix);\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n if (!baseGraphic.stage) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n // hack逻辑,如果是饼图的话,需要依次绘制不同的边\n let isPie: boolean = false;\n let is3d: boolean = false;\n graphic.forEachChildren((c: IGraphic) => {\n isPie = c.numberType === ARC3D_NUMBER_TYPE;\n return !isPie;\n });\n graphic.forEachChildren((c: IGraphic) => {\n is3d = !!c.findFace;\n return !is3d;\n });\n if (isPie) {\n const children = graphic.getChildren() as IArc[];\n // 绘制内层\n // drawContext.hack_pieFace = 'inside';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制底部\n // drawContext.hack_pieFace = 'bottom';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制外部\n // 排序一下\n const sortedChildren = [...children];\n sortedChildren.sort((a, b) => {\n let angle1 = ((a.attribute.startAngle ?? 0) + (a.attribute.endAngle ?? 0)) / 2;\n let angle2 = ((b.attribute.startAngle ?? 0) + (b.attribute.endAngle ?? 0)) / 2;\n while (angle1 < 0) {\n angle1 += pi2;\n }\n while (angle2 < 0) {\n angle2 += pi2;\n }\n return angle2 - angle1;\n });\n sortedChildren.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n graphic.removeAllChild();\n graphic.update();\n sortedChildren.forEach(c => {\n graphic.appendChild(c);\n });\n const m = graphic.parent.globalTransMatrix;\n drawContext.hack_pieFace = 'outside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制内部\n drawContext.hack_pieFace = 'inside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制顶部\n drawContext.hack_pieFace = 'top';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n graphic.removeAllChild();\n children.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n children.forEach(c => {\n graphic.appendChild(c);\n });\n } else if (is3d) {\n // 排序这些图元\n const children = graphic.getChildren() as IGraphic[];\n const zChildren = children.map(g => {\n const face3d = g.findFace();\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2] + g.attribute.z ?? 0)[2];\n });\n const ave_z = viewdVerticesZ.reduce((a, b) => a + b, 0);\n return {\n ave_z,\n g\n };\n });\n zChildren.sort((a, b) => b.ave_z - a.ave_z);\n graphic.removeAllChild();\n zChildren.forEach(i => {\n i.g._next = null;\n i.g._prev = null;\n });\n graphic.update();\n zChildren.forEach(i => {\n graphic.add(i.g);\n });\n\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix, true);\n\n graphic.removeAllChild();\n children.forEach(g => {\n g._next = null;\n g._prev = null;\n });\n graphic.update();\n children.forEach(g => {\n graphic.add(g);\n });\n } else {\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix);\n }\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/draw-interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAA4D;AAC5D,6CAAmD;AACnD,8CAAgF;AAchF,wEAAkF;AAClF,0DAA+D;AAGlD,QAAA,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC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file":"draw-interceptor.js","sourcesContent":["import { injectable } from '../../../common/inversify-lite';\nimport { AABBBounds, pi2 } from '@visactor/vutils';\nimport { graphicCreator, mat3Tomat4, multiplyMat4Mat4 } from '../../../graphic';\nimport type {\n IArc,\n IContext2d,\n IDrawContext,\n IDrawContribution,\n IDrawItemInterceptorContribution,\n IGraphic,\n IGraphicAttribute,\n IGraphicRenderDrawParams,\n IGroup,\n ILayer,\n IRenderService\n} from '../../../interface';\nimport { mat4Allocate, matrixAllocate } from '../../../allocator/matrix-allocate';\nimport { ARC3D_NUMBER_TYPE } from '../../../graphic/constants';\n\n// 拦截器\nexport const DrawItemInterceptor = Symbol.for('DrawItemInterceptor');\n\n// @injectable()\n// export class DefaultDrawItemInterceptor implements IDrawItemInterceptor {\n// drawItem(graphic: IGraphic, renderService: IRenderService, params?: IGraphicRenderDrawParams): boolean {\n// return false;\n// }\n// }\n\nconst tempDirtyBounds = new AABBBounds();\nconst tempBackupDirtyBounds = new AABBBounds();\n/**\n * 影子节点拦截器,用于渲染影子节点\n */\n// @injectable()\nexport class ShadowRootDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx < 0\n ) {\n return false;\n }\n if (\n graphic.attribute.shadowRootIdx > 0 ||\n !graphic.attribute.shadowRootIdx ||\n (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx > 0)\n ) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 如果graphic没设置shadowRootIdx,shadowRoot设置了,那就使用shadowRoot的shadowRootIdx\n if (\n graphic.attribute.shadowRootIdx == null &&\n graphic.shadowRoot &&\n graphic.shadowRoot.attribute.shadowRootIdx > 0\n ) {\n return false;\n }\n if (graphic.attribute.shadowRootIdx < 0 || (graphic.shadowRoot && graphic.shadowRoot.attribute.shadowRootIdx < 0)) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.shadowRoot) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n // 变换dirtyBounds\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n tempDirtyBounds.copy(drawContribution.dirtyBounds);\n tempBackupDirtyBounds.copy(drawContribution.backupDirtyBounds);\n const m = graphic.globalTransMatrix.getInverse();\n drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);\n drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);\n }\n\n // 设置context的transform到上一个节点\n drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));\n\n context.highPerformanceRestore();\n\n if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {\n drawContribution.dirtyBounds.copy(tempDirtyBounds);\n drawContribution.backupDirtyBounds.copy(tempBackupDirtyBounds);\n }\n\n return true;\n }\n}\n\n// @injectable()\nexport class DebugDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (graphic.attribute._debug_bounds) {\n this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n }\n return false;\n }\n\n protected drawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (!graphic.attribute._debug_bounds) {\n return false;\n }\n\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n graphic.parent && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n graphic.glyphHost &&\n graphic.glyphHost.parent &&\n context.setTransformFromMatrix(graphic.glyphHost.parent.globalTransMatrix, true);\n\n const b = graphic.AABBBounds;\n\n if (graphic.attribute._debug_bounds !== true) {\n graphic.attribute._debug_bounds(context, graphic);\n }\n context.strokeRect(b.x1, b.y1, b.width(), b.height());\n\n context.highPerformanceRestore();\n\n return true;\n }\n}\n\n@injectable()\nexport class CommonDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n interceptors: IDrawItemInterceptorContribution[];\n constructor() {\n this.interceptors = [\n new ShadowRootDrawItemInterceptorContribution(),\n new Canvas3DDrawItemInterceptor(),\n new InteractiveDrawItemInterceptorContribution(),\n new DebugDrawItemInterceptorContribution()\n ];\n }\n afterDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].afterDrawItem &&\n this.interceptors[i].afterDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 【性能方案】判定写在外层,减少遍历判断耗时,10000条数据减少1ms\n if (\n (!graphic.in3dMode || drawContext.in3dInterceptor) &&\n !graphic.shadowRoot &&\n !(graphic.baseGraphic || graphic.attribute.globalZIndex || graphic.interactiveGraphic)\n ) {\n return false;\n }\n\n for (let i = 0; i < this.interceptors.length; i++) {\n if (\n this.interceptors[i].beforeDrawItem &&\n this.interceptors[i].beforeDrawItem(graphic, renderService, drawContext, drawContribution, params)\n ) {\n return true;\n }\n }\n return false;\n }\n}\n\n/**\n * 交互层节点拦截器,用于支持交互层图元\n */\n// @injectable()\nexport class InteractiveDrawItemInterceptorContribution implements IDrawItemInterceptorContribution {\n order: number = 1;\n processing: boolean;\n // afterDrawItem(\n // graphic: IGraphic,\n // renderService: IRenderService,\n // drawContext: IDrawContext,\n // drawContribution: IDrawContribution,\n // params?: IGraphicRenderDrawParams\n // ): boolean {\n\n // if (graphic.attribute.shadowRootIdx > 0 || !graphic.attribute.shadowRootIdx) {\n // this.drawItem(graphic, renderService, drawContext, drawContribution, params);\n // }\n // return false;\n // }\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n if (this.processing) {\n return false;\n }\n // 判断是否在交互层\n if (graphic.baseGraphic) {\n return this.beforeDrawInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n return this.beforeSetInteractive(graphic, renderService, drawContext, drawContribution, params);\n }\n\n /**\n * 用于提升interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeSetInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n let interactiveGraphic: IGraphic = graphic.interactiveGraphic;\n if (graphic.attribute.globalZIndex) {\n if (!interactiveGraphic) {\n interactiveGraphic = graphic.clone();\n graphic.interactiveGraphic = interactiveGraphic;\n interactiveGraphic.baseGraphic = graphic;\n }\n // 设置位置\n // const m = graphic.globalTransMatrix;\n interactiveGraphic.setAttributes(\n {\n globalZIndex: 0,\n zIndex: graphic.attribute.globalZIndex\n },\n false,\n { skipUpdateCallback: true }\n );\n // 添加到交互层中\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.add(interactiveGraphic);\n }\n return true;\n } else if (interactiveGraphic) {\n // 从交互层中删除\n drawContext.stage.tryInitInteractiveLayer();\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(interactiveGraphic);\n }\n graphic.interactiveGraphic = null;\n interactiveGraphic.baseGraphic = null;\n }\n return false;\n }\n\n /**\n * 用于绘制interactive\n * @param graphic\n * @param renderService\n * @param drawContext\n * @param drawContribution\n * @param params\n */\n beforeDrawInteractive(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ): boolean {\n // 默认使用原始的图元\n const baseGraphic = graphic.baseGraphic as IGraphic;\n // 如果主图元被删除了,那把交互图元这个也删除\n if (!baseGraphic.stage) {\n const interactiveLayer = drawContext.stage.getLayer('_builtin_interactive');\n if (interactiveLayer) {\n const shadowRoot = this.getShadowRoot(interactiveLayer);\n shadowRoot.removeChild(graphic);\n }\n return true;\n }\n if (baseGraphic) {\n this.processing = true;\n const { context } = drawContext;\n context.highPerformanceSave();\n // 直接transform\n context.setTransformFromMatrix(baseGraphic.parent.globalTransMatrix, true);\n // context.fillRect(0, 0, 100, 100);\n // 设置context的transform到上一个节点\n baseGraphic.isContainer\n ? drawContribution.renderGroup(baseGraphic as IGroup, drawContext, baseGraphic.parent.globalTransMatrix)\n : drawContribution.renderItem(baseGraphic, drawContext);\n\n context.highPerformanceRestore();\n this.processing = false;\n\n return true;\n }\n return false;\n }\n getShadowRoot(interactiveLayer: ILayer) {\n // 获取绑定影子节点的group\n let group = interactiveLayer.getElementById('_interactive_group') as IGroup;\n if (!group) {\n group = graphicCreator.CreateGraphic('group', {});\n group.id = '_interactive_group';\n interactiveLayer.add(group);\n }\n return group.shadowRoot ?? group.attachShadow();\n }\n}\n\n/**\n * 3d拦截器,用于渲染3d视角\n */\n// @injectable()\nexport class Canvas3DDrawItemInterceptor implements IDrawItemInterceptorContribution {\n // canvas?: ICanvas;\n order: number = 1;\n\n beforeDrawItem(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n drawContribution: IDrawContribution,\n params?: IGraphicRenderDrawParams\n ) {\n if (!graphic.in3dMode || drawContext.in3dInterceptor) {\n return false;\n }\n\n drawContext.in3dInterceptor = true;\n const { context, stage } = renderService.drawParams;\n const canvas = context.canvas;\n\n // 使用3d模式渲染\n context.save();\n this.initCanvasCtx(context);\n context.camera = stage.camera;\n\n // 将三维矩阵换成四维矩阵\n const m = context.currentMatrix;\n m.a /= context.dpr;\n m.b /= context.dpr;\n m.c /= context.dpr;\n m.d /= context.dpr;\n m.e /= context.dpr;\n m.f /= context.dpr;\n const matrix = mat4Allocate.allocate();\n mat3Tomat4(matrix, m);\n const lastModelMatrix = context.modelMatrix;\n if (lastModelMatrix) {\n if (matrix) {\n const m = mat4Allocate.allocate();\n context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n }\n } else {\n context.modelMatrix = matrix;\n }\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n\n // 设置context的transform到上一个节点\n if (graphic.isContainer) {\n // hack逻辑,如果是饼图的话,需要依次绘制不同的边\n let isPie: boolean = false;\n let is3d: boolean = false;\n graphic.forEachChildren((c: IGraphic) => {\n isPie = c.numberType === ARC3D_NUMBER_TYPE;\n return !isPie;\n });\n graphic.forEachChildren((c: IGraphic) => {\n is3d = !!c.findFace;\n return !is3d;\n });\n if (isPie) {\n const children = graphic.getChildren() as IArc[];\n // 绘制内层\n // drawContext.hack_pieFace = 'inside';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制底部\n // drawContext.hack_pieFace = 'bottom';\n // drawContribution.renderGroup(graphic as IGroup, drawContext);\n // 绘制外部\n // 排序一下\n const sortedChildren = [...children];\n sortedChildren.sort((a, b) => {\n let angle1 = ((a.attribute.startAngle ?? 0) + (a.attribute.endAngle ?? 0)) / 2;\n let angle2 = ((b.attribute.startAngle ?? 0) + (b.attribute.endAngle ?? 0)) / 2;\n while (angle1 < 0) {\n angle1 += pi2;\n }\n while (angle2 < 0) {\n angle2 += pi2;\n }\n return angle2 - angle1;\n });\n sortedChildren.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n graphic.removeAllChild();\n graphic.update();\n sortedChildren.forEach(c => {\n graphic.appendChild(c);\n });\n const m = graphic.parent.globalTransMatrix;\n drawContext.hack_pieFace = 'outside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制内部\n drawContext.hack_pieFace = 'inside';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n // 绘制顶部\n drawContext.hack_pieFace = 'top';\n drawContribution.renderGroup(graphic as IGroup, drawContext, m);\n graphic.removeAllChild();\n children.forEach(c => {\n c._next = null;\n c._prev = null;\n });\n children.forEach(c => {\n graphic.appendChild(c);\n });\n } else if (is3d) {\n // 排序这些图元\n const children = graphic.getChildren() as IGraphic[];\n const zChildren = children.map(g => {\n const face3d = g.findFace();\n const vertices = face3d.vertices;\n // 计算每个顶点的view\n const viewdVerticesZ = vertices.map(v => {\n return context.view(v[0], v[1], v[2] + g.attribute.z ?? 0)[2];\n });\n const ave_z = viewdVerticesZ.reduce((a, b) => a + b, 0);\n return {\n ave_z,\n g\n };\n });\n zChildren.sort((a, b) => b.ave_z - a.ave_z);\n graphic.removeAllChild();\n zChildren.forEach(i => {\n i.g._next = null;\n i.g._prev = null;\n });\n graphic.update();\n zChildren.forEach(i => {\n graphic.add(i.g);\n });\n\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix, true);\n\n graphic.removeAllChild();\n children.forEach(g => {\n g._next = null;\n g._prev = null;\n });\n graphic.update();\n children.forEach(g => {\n graphic.add(g);\n });\n } else {\n drawContribution.renderGroup(graphic as IGroup, drawContext, graphic.parent.globalTransMatrix);\n }\n } else {\n drawContribution.renderItem(graphic, drawContext);\n }\n context.camera = null;\n context.restore();\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n drawContext.in3dInterceptor = false;\n return true;\n }\n\n initCanvasCtx(context: IContext2d) {\n context.setTransformForCurrent();\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -16962,6 +16962,9 @@ const RICHTEXT_UPDATE_TAG_KEY = [
16962
16962
  'textBaseline',
16963
16963
  'textConfig',
16964
16964
  'layoutDirection',
16965
+ 'fill',
16966
+ 'stroke',
16967
+ 'fontSize',
16965
16968
  ...GRAPHIC_UPDATE_TAG_KEY
16966
16969
  ];
16967
16970
  class RichText extends Graphic {
@@ -17267,10 +17270,12 @@ class RichText extends Graphic {
17267
17270
  let pickIcon;
17268
17271
  frameCache.icons.forEach(icon => {
17269
17272
  var _a, _b;
17270
- if (icon.AABBBounds.containsPoint({ x: point.x - x, y: point.y - y })) {
17273
+ const bounds = icon.AABBBounds.clone();
17274
+ bounds.translate(icon._marginArray[3], icon._marginArray[0]);
17275
+ if (bounds.containsPoint({ x: point.x - x, y: point.y - y })) {
17271
17276
  pickIcon = icon;
17272
- pickIcon.globalX = ((_a = pickIcon.attribute.x) !== null && _a !== void 0 ? _a : 0) + x;
17273
- pickIcon.globalY = ((_b = pickIcon.attribute.y) !== null && _b !== void 0 ? _b : 0) + y;
17277
+ pickIcon.globalX = ((_a = pickIcon.attribute.x) !== null && _a !== void 0 ? _a : 0) + x + icon._marginArray[3];
17278
+ pickIcon.globalY = ((_b = pickIcon.attribute.y) !== null && _b !== void 0 ? _b : 0) + y + icon._marginArray[0];
17274
17279
  }
17275
17280
  });
17276
17281
  return pickIcon;
@@ -20379,35 +20384,39 @@ function createRectPath(path, x, y, width, height, rectCornerRadius, edgeCb) {
20379
20384
  ? edgeCb[0](leftTopPoint1[0], leftTopPoint1[1], rightTopPoint1[0], rightTopPoint1[1])
20380
20385
  : path.lineTo(rightTopPoint1[0], rightTopPoint1[1]);
20381
20386
  if (!arrayEqual(rightTopPoint1, rightTopPoint2)) {
20387
+ edgeCb && edgeCb[0] && path.moveTo(rightTopPoint1[0], rightTopPoint1[1]);
20382
20388
  const centerX = rightTopPoint1[0];
20383
20389
  const centerY = rightTopPoint1[1] + _cornerRadius[1];
20384
20390
  path.arc(centerX, centerY, _cornerRadius[1], -halfPi, 0, false);
20385
20391
  }
20386
20392
  edgeCb && edgeCb[1]
20387
- ? edgeCb[1](rightTopPoint1[0], rightTopPoint1[1], rightBottomPoint2[0], rightBottomPoint2[1])
20393
+ ? edgeCb[1](rightTopPoint2[0], rightTopPoint2[1], rightBottomPoint2[0], rightBottomPoint2[1])
20388
20394
  : path.lineTo(rightBottomPoint2[0], rightBottomPoint2[1]);
20389
20395
  if (!arrayEqual(rightBottomPoint1, rightBottomPoint2)) {
20390
20396
  const centerX = rightBottomPoint2[0] - _cornerRadius[2];
20391
20397
  const centerY = rightBottomPoint2[1];
20398
+ edgeCb && edgeCb[1] && path.moveTo(rightBottomPoint2[0], rightBottomPoint2[1]);
20392
20399
  path.arc(centerX, centerY, _cornerRadius[2], 0, halfPi, false);
20393
20400
  }
20394
20401
  edgeCb && edgeCb[2]
20395
- ? edgeCb[2](rightBottomPoint2[0], rightBottomPoint2[1], leftBottomPoint1[0], leftBottomPoint1[1])
20402
+ ? edgeCb[2](rightBottomPoint1[0], rightBottomPoint1[1], leftBottomPoint1[0], leftBottomPoint1[1])
20396
20403
  : path.lineTo(leftBottomPoint1[0], leftBottomPoint1[1]);
20397
20404
  if (!arrayEqual(leftBottomPoint1, leftBottomPoint2)) {
20398
20405
  const centerX = leftBottomPoint1[0];
20399
20406
  const centerY = leftBottomPoint1[1] - _cornerRadius[3];
20407
+ edgeCb && edgeCb[2] && path.moveTo(leftBottomPoint1[0], leftBottomPoint1[1]);
20400
20408
  path.arc(centerX, centerY, _cornerRadius[3], halfPi, pi, false);
20401
20409
  }
20402
20410
  edgeCb && edgeCb[3]
20403
- ? edgeCb[3](leftBottomPoint1[0], leftBottomPoint1[1], leftTopPoint2[0], leftTopPoint2[1])
20411
+ ? edgeCb[3](leftBottomPoint2[0], leftBottomPoint2[1], leftTopPoint2[0], leftTopPoint2[1])
20404
20412
  : path.lineTo(leftTopPoint2[0], leftTopPoint2[1]);
20405
20413
  if (!arrayEqual(leftTopPoint1, leftTopPoint2)) {
20406
20414
  const centerX = leftTopPoint1[0];
20407
20415
  const centerY = leftTopPoint1[1] + _cornerRadius[0];
20416
+ edgeCb && edgeCb[3] && path.moveTo(leftTopPoint2[0], leftTopPoint2[1]);
20408
20417
  path.arc(centerX, centerY, _cornerRadius[0], pi, pi + halfPi, false);
20409
20418
  }
20410
- path.closePath();
20419
+ !edgeCb && path.closePath();
20411
20420
  return path;
20412
20421
  }
20413
20422
 
@@ -20529,8 +20538,12 @@ let SplitRectAfterRenderContribution = class SplitRectAfterRenderContribution {
20529
20538
  lastStrokeI = i;
20530
20539
  context.lineTo(x2, y2);
20531
20540
  context.stroke();
20541
+ if (i === 3) {
20542
+ context.beginPath();
20543
+ }
20532
20544
  }
20533
20545
  }));
20546
+ context.stroke();
20534
20547
  return;
20535
20548
  }
20536
20549
  context.beginPath();
@@ -21905,7 +21918,8 @@ let DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
21905
21918
  if (!data) {
21906
21919
  return;
21907
21920
  }
21908
- const { doFill, doStroke } = data;
21921
+ const { doFill } = data;
21922
+ const doStroke = data.doStroke && data.sVisible;
21909
21923
  const { clipRange = areaAttribute.clipRange, closePath, points, segments } = area.attribute;
21910
21924
  let { curveType = areaAttribute.curveType } = area.attribute;
21911
21925
  if (closePath && curveType === 'linear') {
@@ -23325,7 +23339,7 @@ class ShadowRootDrawItemInterceptorContribution {
23325
23339
  drawContribution.dirtyBounds.copy(drawContribution.backupDirtyBounds).transformWithMatrix(m);
23326
23340
  drawContribution.backupDirtyBounds.copy(drawContribution.dirtyBounds);
23327
23341
  }
23328
- drawContribution.renderGroup(graphic.shadowRoot, drawContext, graphic.parent.globalTransMatrix);
23342
+ drawContribution.renderGroup(graphic.shadowRoot, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));
23329
23343
  context.highPerformanceRestore();
23330
23344
  if (drawContribution.dirtyBounds && drawContribution.backupDirtyBounds) {
23331
23345
  drawContribution.dirtyBounds.copy(tempDirtyBounds);
@@ -31,24 +31,26 @@ export function createRectPath(path, x, y, width, height, rectCornerRadius, edge
31
31
  const [leftTop, rightTop, rightBottom, leftBottom] = [ [ x, y ], [ x + width, y ], [ x + width, y + height ], [ x, y + height ] ], maxCornerRadius = Math.min(width / 2, height / 2), _cornerRadius = [ Math.min(maxCornerRadius, cornerRadius[0]), Math.min(maxCornerRadius, cornerRadius[1]), Math.min(maxCornerRadius, cornerRadius[2]), Math.min(maxCornerRadius, cornerRadius[3]) ], leftTopPoint1 = [ leftTop[0] + _cornerRadius[0], leftTop[1] ], leftTopPoint2 = [ leftTop[0], leftTop[1] + _cornerRadius[0] ], rightTopPoint1 = [ rightTop[0] - _cornerRadius[1], rightTop[1] ], rightTopPoint2 = [ rightTop[0], rightTop[1] + _cornerRadius[1] ], rightBottomPoint1 = [ rightBottom[0] - _cornerRadius[2], rightBottom[1] ], rightBottomPoint2 = [ rightBottom[0], rightBottom[1] - _cornerRadius[2] ], leftBottomPoint1 = [ leftBottom[0] + _cornerRadius[3], leftBottom[1] ], leftBottomPoint2 = [ leftBottom[0], leftBottom[1] - _cornerRadius[3] ];
32
32
  if (path.moveTo(leftTopPoint1[0], leftTopPoint1[1]), edgeCb && edgeCb[0] ? edgeCb[0](leftTopPoint1[0], leftTopPoint1[1], rightTopPoint1[0], rightTopPoint1[1]) : path.lineTo(rightTopPoint1[0], rightTopPoint1[1]),
33
33
  !arrayEqual(rightTopPoint1, rightTopPoint2)) {
34
+ edgeCb && edgeCb[0] && path.moveTo(rightTopPoint1[0], rightTopPoint1[1]);
34
35
  const centerX = rightTopPoint1[0], centerY = rightTopPoint1[1] + _cornerRadius[1];
35
36
  path.arc(centerX, centerY, _cornerRadius[1], -halfPi, 0, !1);
36
37
  }
37
- if (edgeCb && edgeCb[1] ? edgeCb[1](rightTopPoint1[0], rightTopPoint1[1], rightBottomPoint2[0], rightBottomPoint2[1]) : path.lineTo(rightBottomPoint2[0], rightBottomPoint2[1]),
38
+ if (edgeCb && edgeCb[1] ? edgeCb[1](rightTopPoint2[0], rightTopPoint2[1], rightBottomPoint2[0], rightBottomPoint2[1]) : path.lineTo(rightBottomPoint2[0], rightBottomPoint2[1]),
38
39
  !arrayEqual(rightBottomPoint1, rightBottomPoint2)) {
39
40
  const centerX = rightBottomPoint2[0] - _cornerRadius[2], centerY = rightBottomPoint2[1];
41
+ edgeCb && edgeCb[1] && path.moveTo(rightBottomPoint2[0], rightBottomPoint2[1]),
40
42
  path.arc(centerX, centerY, _cornerRadius[2], 0, halfPi, !1);
41
43
  }
42
- if (edgeCb && edgeCb[2] ? edgeCb[2](rightBottomPoint2[0], rightBottomPoint2[1], leftBottomPoint1[0], leftBottomPoint1[1]) : path.lineTo(leftBottomPoint1[0], leftBottomPoint1[1]),
44
+ if (edgeCb && edgeCb[2] ? edgeCb[2](rightBottomPoint1[0], rightBottomPoint1[1], leftBottomPoint1[0], leftBottomPoint1[1]) : path.lineTo(leftBottomPoint1[0], leftBottomPoint1[1]),
43
45
  !arrayEqual(leftBottomPoint1, leftBottomPoint2)) {
44
46
  const centerX = leftBottomPoint1[0], centerY = leftBottomPoint1[1] - _cornerRadius[3];
45
- path.arc(centerX, centerY, _cornerRadius[3], halfPi, pi, !1);
47
+ edgeCb && edgeCb[2] && path.moveTo(leftBottomPoint1[0], leftBottomPoint1[1]), path.arc(centerX, centerY, _cornerRadius[3], halfPi, pi, !1);
46
48
  }
47
- if (edgeCb && edgeCb[3] ? edgeCb[3](leftBottomPoint1[0], leftBottomPoint1[1], leftTopPoint2[0], leftTopPoint2[1]) : path.lineTo(leftTopPoint2[0], leftTopPoint2[1]),
49
+ if (edgeCb && edgeCb[3] ? edgeCb[3](leftBottomPoint2[0], leftBottomPoint2[1], leftTopPoint2[0], leftTopPoint2[1]) : path.lineTo(leftTopPoint2[0], leftTopPoint2[1]),
48
50
  !arrayEqual(leftTopPoint1, leftTopPoint2)) {
49
51
  const centerX = leftTopPoint1[0], centerY = leftTopPoint1[1] + _cornerRadius[0];
50
- path.arc(centerX, centerY, _cornerRadius[0], pi, pi + halfPi, !1);
52
+ edgeCb && edgeCb[3] && path.moveTo(leftTopPoint2[0], leftTopPoint2[1]), path.arc(centerX, centerY, _cornerRadius[0], pi, pi + halfPi, !1);
51
53
  }
52
- return path.closePath(), path;
54
+ return !edgeCb && path.closePath(), path;
53
55
  }
54
56
  //# sourceMappingURL=rect.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/shape/rect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGjE,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,CAAC;AAGtB,MAAM,UAAU,cAAc,CAC5B,IAAgC,EAChC,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc,EACd,gBAAmC,EACnC,MAAkB;IAElB,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,CAAC,IAAI,KAAK,CAAC;QACX,KAAK,GAAG,CAAC,KAAK,CAAC;KAChB;IACD,IAAI,MAAM,GAAG,CAAC,EAAE;QACd,CAAC,IAAI,MAAM,CAAC;QACZ,MAAM,GAAG,CAAC,MAAM,CAAC;KAClB;IAED,IAAI,YAAkB,CAAC;IACvB,IAAI,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;QACpC,gBAAg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AAI,CAAC,SAAS,EAAE,CAAC;IACjB,OAAO,IAAI,CAAC;AACd,CAAC","file":"rect.js","sourcesContent":["import type { vec2, vec4 } from '@visactor/vutils';\nimport { isNumber, arrayEqual, pi, abs } from '@visactor/vutils';\nimport type { IContext2d, ICustomPath2D } from '../../interface';\n\nconst halfPi = pi / 2;\n\ntype IEdgeCb = (x1: number, y1: number, x2: number, y2: number) => void;\nexport function createRectPath(\n path: ICustomPath2D | IContext2d,\n x: number,\n y: number,\n width: number,\n height: number,\n rectCornerRadius: number | number[],\n edgeCb?: IEdgeCb[]\n) {\n if (width < 0) {\n x += width;\n width = -width;\n }\n if (height < 0) {\n y += height;\n height = -height;\n }\n // 匹配cornerRadius\n let cornerRadius: vec4;\n if (isNumber(rectCornerRadius, true)) {\n rectCornerRadius = abs(rectCornerRadius);\n cornerRadius = [\n <number>rectCornerRadius,\n <number>rectCornerRadius,\n <number>rectCornerRadius,\n <number>rectCornerRadius\n ];\n } else if (Array.isArray(rectCornerRadius)) {\n const cornerRadiusArr: number[] = rectCornerRadius as number[];\n let cr0;\n let cr1;\n let cr2;\n let cr3;\n switch (cornerRadiusArr.length) {\n case 0:\n cornerRadius = [0, 0, 0, 0];\n break;\n case 1:\n cr0 = abs(cornerRadiusArr[0]);\n cornerRadius = [cr0, cr0, cr0, cr0];\n break;\n case 2:\n case 3:\n cr0 = abs(cornerRadiusArr[0]);\n cr1 = abs(cornerRadiusArr[1]);\n cornerRadius = [cr0, cr1, cr0, cr1];\n break;\n default:\n cornerRadius = cornerRadiusArr as [number, number, number, number];\n cornerRadius[0] = abs(cornerRadius[0]);\n cornerRadius[1] = abs(cornerRadius[1]);\n cornerRadius[2] = abs(cornerRadius[2]);\n cornerRadius[3] = abs(cornerRadius[3]);\n break;\n }\n } else {\n cornerRadius = [0, 0, 0, 0];\n }\n\n // 当宽度小于0 或者 cornerRadius 极小时,不绘制 cornerRadius\n if (width < 0 || cornerRadius[0] + cornerRadius[1] + cornerRadius[2] + cornerRadius[3] < 1e-12) {\n return path.rect(x, y, width, height);\n }\n\n const [leftTop, rightTop, rightBottom, leftBottom]: [vec2, vec2, vec2, vec2] = [\n [x, y],\n [x + width, y],\n [x + width, y + height],\n [x, y + height]\n ];\n //\n // *(leftTopPoint1)******************(rightTopPoint1)\n // (leftTopPoint2) (rightTopPoint2)\n // * *\n // * *\n // (leftBottomPoint2) (rightBottomPoint2)\n // *(leftBottomPoint1)***************(rightBottomPoint1)\n //\n const maxCornerRadius = Math.min(width / 2, height / 2);\n const _cornerRadius: vec4 = [\n Math.min(maxCornerRadius, cornerRadius[0]),\n Math.min(maxCornerRadius, cornerRadius[1]),\n Math.min(maxCornerRadius, cornerRadius[2]),\n Math.min(maxCornerRadius, cornerRadius[3])\n ];\n const leftTopPoint1: vec2 = [leftTop[0] + _cornerRadius[0], leftTop[1]];\n const leftTopPoint2: vec2 = [leftTop[0], leftTop[1] + _cornerRadius[0]];\n const rightTopPoint1: vec2 = [rightTop[0] - _cornerRadius[1], rightTop[1]];\n const rightTopPoint2: vec2 = [rightTop[0], rightTop[1] + _cornerRadius[1]];\n const rightBottomPoint1: vec2 = [rightBottom[0] - _cornerRadius[2], rightBottom[1]];\n const rightBottomPoint2: vec2 = [rightBottom[0], rightBottom[1] - _cornerRadius[2]];\n const leftBottomPoint1: vec2 = [leftBottom[0] + _cornerRadius[3], leftBottom[1]];\n const leftBottomPoint2: vec2 = [leftBottom[0], leftBottom[1] - _cornerRadius[3]];\n\n path.moveTo(leftTopPoint1[0], leftTopPoint1[1]);\n\n // 上边\n edgeCb && edgeCb[0]\n ? edgeCb[0](leftTopPoint1[0], leftTopPoint1[1], rightTopPoint1[0], rightTopPoint1[1])\n : path.lineTo(rightTopPoint1[0], rightTopPoint1[1]);\n if (!arrayEqual(rightTopPoint1, rightTopPoint2)) {\n const centerX = rightTopPoint1[0];\n const centerY = rightTopPoint1[1] + _cornerRadius[1];\n path.arc(\n centerX,\n centerY,\n _cornerRadius[1],\n -halfPi,\n 0,\n // Math.atan2(rightTopPoint1[1] - centerY, rightTopPoint1[0] - centerX),\n // Math.atan2(rightTopPoint2[1] - centerY, rightTopPoint2[0] - centerX),\n false\n );\n // path.arcTo(rightTop[0], rightTop[1], rightTopPoint2[0], rightTopPoint2[1], _cornerRadius[1]);\n }\n\n // 右边\n edgeCb && edgeCb[1]\n ? edgeCb[1](rightTopPoint1[0], rightTopPoint1[1], rightBottomPoint2[0], rightBottomPoint2[1])\n : path.lineTo(rightBottomPoint2[0], rightBottomPoint2[1]);\n if (!arrayEqual(rightBottomPoint1, rightBottomPoint2)) {\n const centerX = rightBottomPoint2[0] - _cornerRadius[2];\n const centerY = rightBottomPoint2[1];\n path.arc(\n centerX,\n centerY,\n _cornerRadius[2],\n 0,\n halfPi,\n // Math.atan2(rightBottomPoint2[1] - centerY, rightBottomPoint2[0] - centerX),\n // Math.atan2(rightBottomPoint1[1] - centerY, rightBottomPoint1[0] - centerX),\n false\n );\n // path.arcTo(rightBottom[0], rightBottom[1], rightBottomPoint1[0], rightBottomPoint1[1], _cornerRadius[2]);\n }\n\n edgeCb && edgeCb[2]\n ? edgeCb[2](rightBottomPoint2[0], rightBottomPoint2[1], leftBottomPoint1[0], leftBottomPoint1[1])\n : path.lineTo(leftBottomPoint1[0], leftBottomPoint1[1]);\n if (!arrayEqual(leftBottomPoint1, leftBottomPoint2)) {\n const centerX = leftBottomPoint1[0];\n const centerY = leftBottomPoint1[1] - _cornerRadius[3];\n path.arc(\n centerX,\n centerY,\n _cornerRadius[3],\n halfPi,\n pi,\n // Math.atan2(leftBottomPoint1[1] - centerY, leftBottomPoint1[0] - centerX),\n // Math.atan2(leftBottomPoint2[1] - centerY, leftBottomPoint2[0] - centerX),\n false\n );\n // path.arcTo(leftBottom[0], leftBottom[1], leftBottomPoint2[0], leftBottomPoint2[1], _cornerRadius[3]);\n }\n\n edgeCb && edgeCb[3]\n ? edgeCb[3](leftBottomPoint1[0], leftBottomPoint1[1], leftTopPoint2[0], leftTopPoint2[1])\n : path.lineTo(leftTopPoint2[0], leftTopPoint2[1]);\n if (!arrayEqual(leftTopPoint1, leftTopPoint2)) {\n const centerX = leftTopPoint1[0];\n const centerY = leftTopPoint1[1] + _cornerRadius[0];\n path.arc(\n centerX,\n centerY,\n _cornerRadius[0],\n pi,\n pi + halfPi,\n // Math.atan2(leftTopPoint2[1] - centerY, leftTopPoint2[0] - centerX),\n // Math.atan2(leftTopPoint1[1] - centerY, leftTopPoint1[0] - centerX) + Math.PI * 2,\n false\n );\n // path.arcTo(leftTop[0], leftTop[1], leftTopPoint1[0], leftTopPoint1[1], _cornerRadius[0]);\n }\n path.closePath();\n return path;\n}\n"]}
1
+ {"version":3,"sources":["../src/common/shape/rect.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGjE,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,CAAC;AAGtB,MAAM,UAAU,cAAc,CAC5B,IAAgC,EAChC,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc,EACd,gBAAmC,EACnC,MAAkB;IAElB,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,CAAC,IAAI,KAAK,CAAC;QACX,KAAK,GAAG,CAAC,KAAK,CAAC;KAChB;IACD,IAAI,MAAM,GAAG,CAAC,EAAE;QACd,CAAC,IAAI,MAAM,CAAC;QACZ,MAAM,GAAG,CAAC,MAAM,CAAC;KAClB;IAED,IAAI,YAAkB,CAAC;IACvB,IAAI,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;QACpC,gBAAgB,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAC;QACzC,YAAY,GAAG;YACL,gBAAgB;YAChB,gBAAgB;YAChB,gBAAgB;YAChB,gBAAgB;SACzB,CAAC;KACH;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE;QAC1C,MAAM,eAAe,GAAa,gBAA4B,CA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AAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QACpD,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,GAAG,CACN,OAAO,EACP,OAAO,EACP,aAAa,CAAC,CAAC,CAAC,EAChB,EAAE,EACF,EAAE,GAAG,MAAM,EAGX,KAAK,CACN,CAAC;KAEH;IACD,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC","file":"rect.js","sourcesContent":["import type { vec2, vec4 } from '@visactor/vutils';\nimport { isNumber, arrayEqual, pi, abs } from '@visactor/vutils';\nimport type { IContext2d, ICustomPath2D } from '../../interface';\n\nconst halfPi = pi / 2;\n\ntype IEdgeCb = (x1: number, y1: number, x2: number, y2: number) => void;\nexport function createRectPath(\n path: ICustomPath2D | IContext2d,\n x: number,\n y: number,\n width: number,\n height: number,\n rectCornerRadius: number | number[],\n edgeCb?: IEdgeCb[]\n) {\n if (width < 0) {\n x += width;\n width = -width;\n }\n if (height < 0) {\n y += height;\n height = -height;\n }\n // 匹配cornerRadius\n let cornerRadius: vec4;\n if (isNumber(rectCornerRadius, true)) {\n rectCornerRadius = abs(rectCornerRadius);\n cornerRadius = [\n <number>rectCornerRadius,\n <number>rectCornerRadius,\n <number>rectCornerRadius,\n <number>rectCornerRadius\n ];\n } else if (Array.isArray(rectCornerRadius)) {\n const cornerRadiusArr: number[] = rectCornerRadius as number[];\n let cr0;\n let cr1;\n let cr2;\n let cr3;\n switch (cornerRadiusArr.length) {\n case 0:\n cornerRadius = [0, 0, 0, 0];\n break;\n case 1:\n cr0 = abs(cornerRadiusArr[0]);\n cornerRadius = [cr0, cr0, cr0, cr0];\n break;\n case 2:\n case 3:\n cr0 = abs(cornerRadiusArr[0]);\n cr1 = abs(cornerRadiusArr[1]);\n cornerRadius = [cr0, cr1, cr0, cr1];\n break;\n default:\n cornerRadius = cornerRadiusArr as [number, number, number, number];\n cornerRadius[0] = abs(cornerRadius[0]);\n cornerRadius[1] = abs(cornerRadius[1]);\n cornerRadius[2] = abs(cornerRadius[2]);\n cornerRadius[3] = abs(cornerRadius[3]);\n break;\n }\n } else {\n cornerRadius = [0, 0, 0, 0];\n }\n\n // 当宽度小于0 或者 cornerRadius 极小时,不绘制 cornerRadius\n if (width < 0 || cornerRadius[0] + cornerRadius[1] + cornerRadius[2] + cornerRadius[3] < 1e-12) {\n return path.rect(x, y, width, height);\n }\n\n const [leftTop, rightTop, rightBottom, leftBottom]: [vec2, vec2, vec2, vec2] = [\n [x, y],\n [x + width, y],\n [x + width, y + height],\n [x, y + height]\n ];\n //\n // *(leftTopPoint1)******************(rightTopPoint1)\n // (leftTopPoint2) (rightTopPoint2)\n // * *\n // * *\n // (leftBottomPoint2) (rightBottomPoint2)\n // *(leftBottomPoint1)***************(rightBottomPoint1)\n //\n const maxCornerRadius = Math.min(width / 2, height / 2);\n const _cornerRadius: vec4 = [\n Math.min(maxCornerRadius, cornerRadius[0]),\n Math.min(maxCornerRadius, cornerRadius[1]),\n Math.min(maxCornerRadius, cornerRadius[2]),\n Math.min(maxCornerRadius, cornerRadius[3])\n ];\n const leftTopPoint1: vec2 = [leftTop[0] + _cornerRadius[0], leftTop[1]];\n const leftTopPoint2: vec2 = [leftTop[0], leftTop[1] + _cornerRadius[0]];\n const rightTopPoint1: vec2 = [rightTop[0] - _cornerRadius[1], rightTop[1]];\n const rightTopPoint2: vec2 = [rightTop[0], rightTop[1] + _cornerRadius[1]];\n const rightBottomPoint1: vec2 = [rightBottom[0] - _cornerRadius[2], rightBottom[1]];\n const rightBottomPoint2: vec2 = [rightBottom[0], rightBottom[1] - _cornerRadius[2]];\n const leftBottomPoint1: vec2 = [leftBottom[0] + _cornerRadius[3], leftBottom[1]];\n const leftBottomPoint2: vec2 = [leftBottom[0], leftBottom[1] - _cornerRadius[3]];\n\n path.moveTo(leftTopPoint1[0], leftTopPoint1[1]);\n\n // 上边\n edgeCb && edgeCb[0]\n ? edgeCb[0](leftTopPoint1[0], leftTopPoint1[1], rightTopPoint1[0], rightTopPoint1[1])\n : path.lineTo(rightTopPoint1[0], rightTopPoint1[1]);\n if (!arrayEqual(rightTopPoint1, rightTopPoint2)) {\n // arc from rightTopPoint1 to rightTopPoint2\n edgeCb && edgeCb[0] && path.moveTo(rightTopPoint1[0], rightTopPoint1[1]);\n const centerX = rightTopPoint1[0];\n const centerY = rightTopPoint1[1] + _cornerRadius[1];\n path.arc(\n centerX,\n centerY,\n _cornerRadius[1],\n -halfPi,\n 0,\n // Math.atan2(rightTopPoint1[1] - centerY, rightTopPoint1[0] - centerX),\n // Math.atan2(rightTopPoint2[1] - centerY, rightTopPoint2[0] - centerX),\n false\n );\n // path.arcTo(rightTop[0], rightTop[1], rightTopPoint2[0], rightTopPoint2[1], _cornerRadius[1]);\n }\n\n // 右边\n edgeCb && edgeCb[1]\n ? edgeCb[1](rightTopPoint2[0], rightTopPoint2[1], rightBottomPoint2[0], rightBottomPoint2[1])\n : path.lineTo(rightBottomPoint2[0], rightBottomPoint2[1]);\n if (!arrayEqual(rightBottomPoint1, rightBottomPoint2)) {\n // arc from rightBottomPoint2 to rightTopPoint1\n const centerX = rightBottomPoint2[0] - _cornerRadius[2];\n const centerY = rightBottomPoint2[1];\n edgeCb && edgeCb[1] && path.moveTo(rightBottomPoint2[0], rightBottomPoint2[1]);\n path.arc(\n centerX,\n centerY,\n _cornerRadius[2],\n 0,\n halfPi,\n // Math.atan2(rightBottomPoint2[1] - centerY, rightBottomPoint2[0] - centerX),\n // Math.atan2(rightBottomPoint1[1] - centerY, rightBottomPoint1[0] - centerX),\n false\n );\n // path.arcTo(rightBottom[0], rightBottom[1], rightBottomPoint1[0], rightBottomPoint1[1], _cornerRadius[2]);\n }\n\n edgeCb && edgeCb[2]\n ? edgeCb[2](rightBottomPoint1[0], rightBottomPoint1[1], leftBottomPoint1[0], leftBottomPoint1[1])\n : path.lineTo(leftBottomPoint1[0], leftBottomPoint1[1]);\n if (!arrayEqual(leftBottomPoint1, leftBottomPoint2)) {\n // arc from leftBottomPoint1 to leftBottomPoint2\n const centerX = leftBottomPoint1[0];\n const centerY = leftBottomPoint1[1] - _cornerRadius[3];\n edgeCb && edgeCb[2] && path.moveTo(leftBottomPoint1[0], leftBottomPoint1[1]);\n path.arc(\n centerX,\n centerY,\n _cornerRadius[3],\n halfPi,\n pi,\n // Math.atan2(leftBottomPoint1[1] - centerY, leftBottomPoint1[0] - centerX),\n // Math.atan2(leftBottomPoint2[1] - centerY, leftBottomPoint2[0] - centerX),\n false\n );\n // path.arcTo(leftBottom[0], leftBottom[1], leftBottomPoint2[0], leftBottomPoint2[1], _cornerRadius[3]);\n }\n\n edgeCb && edgeCb[3]\n ? edgeCb[3](leftBottomPoint2[0], leftBottomPoint2[1], leftTopPoint2[0], leftTopPoint2[1])\n : path.lineTo(leftTopPoint2[0], leftTopPoint2[1]);\n if (!arrayEqual(leftTopPoint1, leftTopPoint2)) {\n const centerX = leftTopPoint1[0];\n const centerY = leftTopPoint1[1] + _cornerRadius[0];\n edgeCb && edgeCb[3] && path.moveTo(leftTopPoint2[0], leftTopPoint2[1]);\n path.arc(\n centerX,\n centerY,\n _cornerRadius[0],\n pi,\n pi + halfPi,\n // Math.atan2(leftTopPoint2[1] - centerY, leftTopPoint2[0] - centerX),\n // Math.atan2(leftTopPoint1[1] - centerY, leftTopPoint1[0] - centerX) + Math.PI * 2,\n false\n );\n // path.arcTo(leftTop[0], leftTop[1], leftTopPoint1[0], leftTopPoint1[1], _cornerRadius[0]);\n }\n !edgeCb && path.closePath();\n return path;\n}\n"]}
@@ -20,7 +20,7 @@ import { parsePadding } from "../common/utils";
20
20
 
21
21
  import { RICHTEXT_NUMBER_TYPE } from "./constants";
22
22
 
23
- const RICHTEXT_UPDATE_TAG_KEY = [ "width", "height", "ellipsis", "wordBreak", "verticalDirection", "maxHeight", "maxWidth", "textAlign", "textBaseline", "textConfig", "layoutDirection", ...GRAPHIC_UPDATE_TAG_KEY ];
23
+ const RICHTEXT_UPDATE_TAG_KEY = [ "width", "height", "ellipsis", "wordBreak", "verticalDirection", "maxHeight", "maxWidth", "textAlign", "textBaseline", "textConfig", "layoutDirection", "fill", "stroke", "fontSize", ...GRAPHIC_UPDATE_TAG_KEY ];
24
24
 
25
25
  export class RichText extends Graphic {
26
26
  constructor(params) {
@@ -205,11 +205,12 @@ export class RichText extends Graphic {
205
205
  let pickIcon;
206
206
  return frameCache.icons.forEach((icon => {
207
207
  var _a, _b;
208
- icon.AABBBounds.containsPoint({
208
+ const bounds = icon.AABBBounds.clone();
209
+ bounds.translate(icon._marginArray[3], icon._marginArray[0]), bounds.containsPoint({
209
210
  x: point.x - x,
210
211
  y: point.y - y
211
- }) && (pickIcon = icon, pickIcon.globalX = (null !== (_a = pickIcon.attribute.x) && void 0 !== _a ? _a : 0) + x,
212
- pickIcon.globalY = (null !== (_b = pickIcon.attribute.y) && void 0 !== _b ? _b : 0) + y);
212
+ }) && (pickIcon = icon, pickIcon.globalX = (null !== (_a = pickIcon.attribute.x) && void 0 !== _a ? _a : 0) + x + icon._marginArray[3],
213
+ pickIcon.globalY = (null !== (_b = pickIcon.attribute.y) && void 0 !== _b ? _b : 0) + y + icon._marginArray[0]);
213
214
  })), pickIcon;
214
215
  }
215
216
  getNoWorkAnimateAttr() {