@visactor/vrender-core 0.21.5-vstory.1 → 0.21.6-alpha.1
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/Ticker/default-ticker.d.ts +0 -2
- package/cjs/animate/Ticker/default-ticker.js +1 -7
- package/cjs/animate/Ticker/default-ticker.js.map +1 -1
- package/cjs/animate/animate.js +1 -1
- package/cjs/animate/animate.js.map +1 -1
- package/cjs/animate/easing.d.ts +0 -4
- package/cjs/animate/easing.js +1 -12
- package/cjs/animate/easing.js.map +1 -1
- package/cjs/animate/index.d.ts +0 -1
- package/cjs/animate/index.js +1 -1
- package/cjs/animate/index.js.map +1 -1
- package/cjs/color-string/store.js +2 -1
- package/cjs/common/3d-interceptor.js +1 -2
- package/cjs/common/bezier-utils.d.ts +0 -3
- package/cjs/common/bezier-utils.js +2 -17
- package/cjs/common/bezier-utils.js.map +1 -1
- package/cjs/common/custom-path2d.d.ts +0 -4
- package/cjs/common/custom-path2d.js +11 -43
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/render-area.js +1 -0
- package/cjs/common/render-command-list.js +1 -2
- package/cjs/common/segment/curve/arc.d.ts +1 -4
- package/cjs/common/segment/curve/arc.js +1 -10
- package/cjs/common/segment/curve/arc.js.map +1 -1
- package/cjs/common/segment/curve/base.d.ts +1 -4
- package/cjs/common/segment/curve/base.js.map +1 -1
- package/cjs/common/segment/curve/cubic-bezier.d.ts +1 -5
- package/cjs/common/segment/curve/cubic-bezier.js +3 -24
- package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
- package/cjs/common/segment/curve/curve-context.js +4 -5
- package/cjs/common/segment/curve/curve-context.js.map +1 -1
- package/cjs/common/segment/curve/ellipse.d.ts +1 -4
- package/cjs/common/segment/curve/ellipse.js +0 -9
- package/cjs/common/segment/curve/ellipse.js.map +1 -1
- package/cjs/common/segment/curve/line.d.ts +1 -4
- package/cjs/common/segment/curve/line.js +0 -18
- package/cjs/common/segment/curve/line.js.map +1 -1
- package/cjs/common/segment/curve/move.d.ts +1 -4
- package/cjs/common/segment/curve/move.js +0 -9
- package/cjs/common/segment/curve/move.js.map +1 -1
- package/cjs/common/segment/curve/path.d.ts +1 -2
- package/cjs/common/segment/curve/path.js +2 -5
- package/cjs/common/segment/curve/path.js.map +1 -1
- package/cjs/common/segment/curve/quadratic-bezier.d.ts +2 -6
- package/cjs/common/segment/curve/quadratic-bezier.js +5 -23
- package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/graphic/builtin-symbol/rect.d.ts +1 -2
- package/cjs/graphic/builtin-symbol/rect.js +0 -28
- package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
- package/cjs/graphic/builtin-symbol/utils.d.ts +1 -2
- package/cjs/graphic/builtin-symbol/utils.js +0 -5
- package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
- package/cjs/graphic/config.js +1 -6
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/graphic.js +1 -2
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/richtext/wrapper.d.ts +0 -1
- package/cjs/graphic/richtext/wrapper.js +1 -1
- package/cjs/graphic/richtext/wrapper.js.map +1 -1
- package/cjs/graphic/richtext.js +1 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/index.d.ts +0 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +39 -5
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/graphic/path.d.ts +0 -1
- package/cjs/interface/graphic/path.js.map +1 -1
- package/cjs/interface/graphic/symbol.d.ts +0 -2
- package/cjs/interface/graphic/symbol.js.map +1 -1
- package/cjs/interface/graphic.d.ts +2 -6
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/path.d.ts +0 -5
- package/cjs/interface/path.js.map +1 -1
- package/cjs/interface/picker.d.ts +0 -13
- package/cjs/interface/picker.js.map +1 -1
- package/cjs/picker/constants.d.ts +0 -2
- package/cjs/picker/constants.js +2 -3
- package/cjs/picker/constants.js.map +1 -1
- package/cjs/picker/pick-interceptor.d.ts +2 -7
- package/cjs/picker/pick-interceptor.js +2 -19
- package/cjs/picker/pick-interceptor.js.map +1 -1
- package/cjs/picker/pick-modules.js +4 -7
- package/cjs/picker/pick-modules.js.map +1 -1
- package/cjs/picker/picker-service.d.ts +2 -4
- package/cjs/picker/picker-service.js +12 -13
- package/cjs/picker/picker-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.d.ts +5 -6
- package/cjs/plugins/builtin-plugin/edit-module.js +28 -84
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +1 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +30 -49
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +217 -280
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
- package/cjs/render/contributions/render/base-render.d.ts +0 -1
- package/cjs/render/contributions/render/base-render.js +2 -20
- package/cjs/render/contributions/render/base-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +2 -29
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +2 -6
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +3 -48
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -8
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +2 -30
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +14 -12
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/path-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +12 -15
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/utils.d.ts +2 -1
- package/cjs/render/contributions/render/utils.js +20 -4
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/dist/index.es.js +7575 -8255
- package/es/animate/Ticker/default-ticker.d.ts +0 -2
- package/es/animate/Ticker/default-ticker.js +1 -7
- package/es/animate/Ticker/default-ticker.js.map +1 -1
- package/es/animate/animate.js +1 -1
- package/es/animate/animate.js.map +1 -1
- package/es/animate/easing.d.ts +0 -4
- package/es/animate/easing.js +1 -12
- package/es/animate/easing.js.map +1 -1
- package/es/animate/index.d.ts +0 -1
- package/es/animate/index.js +0 -2
- package/es/animate/index.js.map +1 -1
- package/es/color-string/store.js +2 -1
- package/es/common/3d-interceptor.js +1 -2
- package/es/common/bezier-utils.d.ts +0 -3
- package/es/common/bezier-utils.js +0 -14
- package/es/common/bezier-utils.js.map +1 -1
- package/es/common/custom-path2d.d.ts +0 -4
- package/es/common/custom-path2d.js +12 -44
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/render-area.js +2 -1
- package/es/common/render-command-list.js +1 -2
- package/es/common/segment/curve/arc.d.ts +1 -4
- package/es/common/segment/curve/arc.js +1 -10
- package/es/common/segment/curve/arc.js.map +1 -1
- package/es/common/segment/curve/base.d.ts +1 -4
- package/es/common/segment/curve/base.js.map +1 -1
- package/es/common/segment/curve/cubic-bezier.d.ts +1 -5
- package/es/common/segment/curve/cubic-bezier.js +1 -22
- package/es/common/segment/curve/cubic-bezier.js.map +1 -1
- package/es/common/segment/curve/curve-context.js +3 -6
- package/es/common/segment/curve/curve-context.js.map +1 -1
- package/es/common/segment/curve/ellipse.d.ts +1 -4
- package/es/common/segment/curve/ellipse.js +0 -9
- package/es/common/segment/curve/ellipse.js.map +1 -1
- package/es/common/segment/curve/line.d.ts +1 -4
- package/es/common/segment/curve/line.js +0 -18
- package/es/common/segment/curve/line.js.map +1 -1
- package/es/common/segment/curve/move.d.ts +1 -4
- package/es/common/segment/curve/move.js +0 -9
- package/es/common/segment/curve/move.js.map +1 -1
- package/es/common/segment/curve/path.d.ts +1 -2
- package/es/common/segment/curve/path.js +2 -5
- package/es/common/segment/curve/path.js.map +1 -1
- package/es/common/segment/curve/quadratic-bezier.d.ts +2 -6
- package/es/common/segment/curve/quadratic-bezier.js +5 -28
- package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
- package/es/common/store.js +1 -1
- package/es/graphic/builtin-symbol/rect.d.ts +1 -2
- package/es/graphic/builtin-symbol/rect.js +0 -28
- package/es/graphic/builtin-symbol/rect.js.map +1 -1
- package/es/graphic/builtin-symbol/utils.d.ts +1 -2
- package/es/graphic/builtin-symbol/utils.js +0 -5
- package/es/graphic/builtin-symbol/utils.js.map +1 -1
- package/es/graphic/config.js +1 -6
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/graphic.js +1 -2
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/richtext/wrapper.d.ts +0 -1
- package/es/graphic/richtext/wrapper.js +1 -1
- package/es/graphic/richtext/wrapper.js.map +1 -1
- package/es/graphic/richtext.js +1 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/index.d.ts +0 -1
- package/es/index.js +0 -2
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +39 -5
- package/es/interface/animate.js.map +1 -1
- package/es/interface/graphic/path.d.ts +0 -1
- package/es/interface/graphic/path.js.map +1 -1
- package/es/interface/graphic/symbol.d.ts +0 -2
- package/es/interface/graphic/symbol.js.map +1 -1
- package/es/interface/graphic.d.ts +2 -6
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/path.d.ts +0 -5
- package/es/interface/path.js.map +1 -1
- package/es/interface/picker.d.ts +0 -13
- package/es/interface/picker.js.map +1 -1
- package/es/picker/constants.d.ts +0 -2
- package/es/picker/constants.js +0 -4
- package/es/picker/constants.js.map +1 -1
- package/es/picker/pick-interceptor.d.ts +2 -7
- package/es/picker/pick-interceptor.js +1 -19
- package/es/picker/pick-interceptor.js.map +1 -1
- package/es/picker/pick-modules.js +3 -5
- package/es/picker/pick-modules.js.map +1 -1
- package/es/picker/picker-service.d.ts +2 -4
- package/es/picker/picker-service.js +13 -13
- package/es/picker/picker-service.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.d.ts +5 -6
- package/es/plugins/builtin-plugin/edit-module.js +25 -79
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.js +1 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +30 -49
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +214 -283
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/render/contributions/render/arc3d-render.js.map +1 -1
- package/es/render/contributions/render/base-render.d.ts +0 -1
- package/es/render/contributions/render/base-render.js +2 -21
- package/es/render/contributions/render/base-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js +2 -29
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.d.ts +2 -6
- package/es/render/contributions/render/contributions/image-contribution-render.js +2 -52
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -8
- package/es/render/contributions/render/contributions/symbol-contribution-render.js +0 -26
- package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/es/render/contributions/render/image-render.js +13 -12
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/path-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +13 -16
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/utils.d.ts +2 -1
- package/es/render/contributions/render/utils.js +18 -0
- package/es/render/contributions/render/utils.js.map +1 -1
- package/package.json +3 -3
- package/cjs/animate/easing-func.d.ts +0 -1
- package/cjs/animate/easing-func.js +0 -16
- package/cjs/animate/easing-func.js.map +0 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
- package/es/animate/easing-func.d.ts +0 -1
- package/es/animate/easing-func.js +0 -10
- package/es/animate/easing-func.js.map +0 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +0 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +0 -3
- package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +0 -1
|
@@ -4,25 +4,6 @@ import { BaseRenderContributionTime } from "../../../../common/enums";
|
|
|
4
4
|
|
|
5
5
|
import { pi2 } from "@visactor/vutils";
|
|
6
6
|
|
|
7
|
-
function formatRatio(ratio) {
|
|
8
|
-
return ratio <= .5 ? 4 * ratio - 1 : -4 * ratio + 3;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function drawWave(ctx, ratio, boundsWidth, boundsHeight, textureOptions, offsetX, offsetY) {
|
|
12
|
-
const {fill: fill = "orange", percent: percent = .6, frequency: frequency = 4, opacity: opacity, phi: phi = 0} = textureOptions;
|
|
13
|
-
let {amplitude: amplitude = 10} = textureOptions;
|
|
14
|
-
amplitude *= formatRatio(ratio);
|
|
15
|
-
const height = boundsHeight * (1 - percent), width = boundsWidth, step = Math.max(Math.round(width / 70), 2);
|
|
16
|
-
ctx.beginPath(), ctx.moveTo(0 + offsetX, boundsHeight + offsetY), ctx.lineTo(0 + offsetX, height + offsetY);
|
|
17
|
-
const delta = width / frequency * ratio, c = width / Math.PI / (2 * frequency);
|
|
18
|
-
for (let i = 0; i < width; i += step) {
|
|
19
|
-
const y = amplitude * Math.sin((i + delta + phi) / c + phi);
|
|
20
|
-
ctx.lineTo(i + offsetX, height + y + offsetY);
|
|
21
|
-
}
|
|
22
|
-
ctx.lineTo(width + offsetX, boundsHeight + offsetY), ctx.closePath(), ctx.fillStyle = fill,
|
|
23
|
-
isFinite(opacity) && (ctx.globalAlpha = opacity), ctx.fill();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
7
|
export class DefaultBaseTextureRenderContribution {
|
|
27
8
|
constructor() {
|
|
28
9
|
this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 10;
|
|
@@ -101,7 +82,6 @@ export class DefaultBaseTextureRenderContribution {
|
|
|
101
82
|
texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
|
|
102
83
|
}
|
|
103
84
|
drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
|
|
104
|
-
const {textureRatio: textureRatio = graphicAttribute.textureRatio, textureOptions: textureOptions = null} = graphic.attribute;
|
|
105
85
|
let pattern = this.textureMap.get(texture);
|
|
106
86
|
if (!pattern) switch (texture) {
|
|
107
87
|
case "circle":
|
|
@@ -135,15 +115,8 @@ export class DefaultBaseTextureRenderContribution {
|
|
|
135
115
|
case "grid":
|
|
136
116
|
pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
|
|
137
117
|
}
|
|
138
|
-
|
|
139
|
-
context.fillStyle = pattern, context.fill(), context.highPerformanceRestore();
|
|
140
|
-
context.save(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
|
|
141
|
-
context.clip();
|
|
142
|
-
const b = graphic.AABBBounds;
|
|
143
|
-
drawWave(context, textureRatio, b.width(), b.height(), Object.assign(Object.assign({}, textureOptions || {}), {
|
|
144
|
-
fill: textureColor
|
|
145
|
-
}), x + b.x1 - x, y + b.y1 - y), context.restore();
|
|
146
|
-
}
|
|
118
|
+
pattern && (context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
|
|
119
|
+
context.fillStyle = pattern, context.fill(), context.highPerformanceRestore());
|
|
147
120
|
}
|
|
148
121
|
}
|
|
149
122
|
|
package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/contributions/base-texture-contribution-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAUtE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,IAAI,GAAG,EAAE;QAChB,OAAO,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;KACtB;IACD,OAAO,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,QAAQ,CACf,GAAe,EACf,KAAa,EACb,WAAmB,EACnB,YAAoB,EACpB,cAOC,EACD,OAAe,EACf,OAAe;IAEf,MAAM,EAAE,IAAI,GAAG,QAAQ,EAAE,OAAO,GAAG,GAAG,EAAE,SAAS,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,cAAc,CAAC;IAC3F,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,GAAG,cAAc,CAAC;IACxC,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,YAAY,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,WAAW,CAAC;IAE1B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,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AK,EAAE,EACT,CAAC,CAAC,MAAM,EAAE,kCACL,CAAC,cAAc,IAAI,EAAE,CAAC,KAAE,IAAI,EAAE,YAAY,KAC/C,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EACZ,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CACb,CAAC;YACF,OAAO,CAAC,OAAO,EAAE,CAAC;SACnB;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,oCAAoC,EAAE,CAAC","file":"base-texture-contribution-render.js","sourcesContent":["import { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IBaseRenderContribution,\n IContext2d,\n IDrawContext,\n IGraphic,\n IGraphicAttribute,\n IStage,\n IThemeAttribute\n} from '../../../../interface';\nimport { pi2 } from '@visactor/vutils';\n\nfunction formatRatio(ratio: number) {\n if (ratio <= 0.5) {\n return ratio * 4 - 1;\n }\n return -4 * ratio + 3;\n}\n\nfunction drawWave(\n ctx: IContext2d,\n ratio: number,\n boundsWidth: number,\n boundsHeight: number,\n textureOptions: {\n fill: string;\n percent: number;\n frequency: number;\n amplitude: number;\n opacity?: number;\n phi?: number;\n },\n offsetX: number,\n offsetY: number\n) {\n const { fill = 'orange', percent = 0.6, frequency = 4, opacity, phi = 0 } = textureOptions;\n let { amplitude = 10 } = textureOptions;\n amplitude = amplitude * formatRatio(ratio);\n\n const height = boundsHeight * (1 - percent);\n const width = boundsWidth;\n\n const step = Math.max(Math.round(width / 70), 2);\n ctx.beginPath();\n ctx.moveTo(0 + offsetX, boundsHeight + offsetY);\n ctx.lineTo(0 + offsetX, height + offsetY);\n const delta = (width / frequency) * ratio;\n const c = width / Math.PI / (frequency * 2);\n\n for (let i = 0; i < width; i += step) {\n const y = amplitude * Math.sin((i + delta + phi) / c + phi);\n ctx.lineTo(i + offsetX, height + y + offsetY);\n }\n\n ctx.lineTo(width + offsetX, boundsHeight + offsetY);\n ctx.closePath();\n\n ctx.fillStyle = fill;\n if (isFinite(opacity)) {\n ctx.globalAlpha = opacity;\n }\n ctx.fill();\n}\n\nexport class DefaultBaseTextureRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n textureMap?: Map<string, CanvasPattern>;\n order: number = 10;\n\n createCommonPattern(\n size: number,\n padding: number,\n color: string,\n targetContext: IContext2d,\n cb: (r: number, targetContext: IContext2d) => void\n ) {\n const r = (size - padding * 2) / 2;\n const dpr = targetContext.dpr;\n const canvas = canvasAllocate.allocate({ width: size, height: size, dpr });\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return null;\n }\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, size, size);\n //setup up design for pattern\n cb(r, ctx);\n const pattern = targetContext.createPattern(canvas.nativeCanvas, 'repeat');\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n\n canvasAllocate.free(canvas);\n return pattern;\n }\n\n createCirclePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.fillStyle = color;\n ctx.arc(r, r, r, 0, pi2);\n ctx.fill();\n });\n }\n\n createDiamondPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = size / 2;\n const y = x;\n ctx.fillStyle = color;\n ctx.moveTo(x, y - r);\n ctx.lineTo(r + x, y);\n ctx.lineTo(x, y + r);\n ctx.lineTo(x - r, y);\n ctx.closePath();\n ctx.fill();\n });\n }\n\n createRectPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, r * 2);\n });\n }\n\n createVerticalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = 0;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, size);\n });\n }\n\n createHorizontalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = 0;\n const y = padding;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, size, r * 2);\n });\n }\n\n createBiasLRLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(0, 0);\n ctx.lineTo(size, size);\n const dx = size / 2;\n const dy = -dx;\n ctx.moveTo(dx, dy);\n ctx.lineTo(dx + size, dy + size);\n ctx.moveTo(-dx, -dy);\n ctx.lineTo(-dx + size, -dy + size);\n ctx.stroke();\n });\n }\n\n createBiasRLLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(size, 0);\n ctx.lineTo(0, size);\n const dx = size / 2;\n const dy = dx;\n ctx.moveTo(size + dx, dy);\n ctx.lineTo(dx, dy + size);\n ctx.moveTo(size - dx, -dy);\n ctx.lineTo(-dx, -dy + size);\n ctx.stroke();\n });\n }\n\n createGridPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r, r);\n ctx.fillRect(x + r, y + r, r, r);\n });\n }\n\n initTextureMap(ctx: IContext2d, stage: IStage) {\n this.textureMap = new Map();\n // ResourceLoader.GetImage(rect1, {\n // imageLoadFail: () => {\n // return;\n // },\n // imageLoadSuccess: (url, img) => {\n // const pattern = ctx.createPattern(img, 'repeat');\n // this.textureMap.set('rect1', pattern);\n // stage && stage.renderNextFrame();\n // }\n // });\n }\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this.textureMap) {\n this.initTextureMap(context, graphic.stage);\n }\n const {\n texture = graphicAttribute.texture,\n textureColor = graphicAttribute.textureColor,\n textureSize = graphicAttribute.textureSize,\n texturePadding = graphicAttribute.texturePadding\n } = graphic.attribute;\n if (!texture) {\n return;\n }\n this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);\n }\n\n protected drawTexture(\n texture: string,\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n graphicAttribute: Required<IGraphicAttribute>,\n textureColor: string,\n textureSize: number,\n texturePadding: number\n ) {\n const { textureRatio = graphicAttribute.textureRatio, textureOptions = null } = graphic.attribute;\n let pattern: CanvasPattern = this.textureMap.get(texture);\n\n if (!pattern) {\n switch (texture) {\n case 'circle':\n pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'diamond':\n pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'rect':\n pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'vertical-line':\n pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'horizontal-line':\n pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-lr':\n pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-rl':\n pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'grid':\n pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);\n break;\n }\n }\n\n if (pattern) {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.fillStyle = pattern;\n context.fill();\n context.highPerformanceRestore();\n } else if (texture === 'wave') {\n context.save();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.clip();\n const b = graphic.AABBBounds;\n drawWave(\n context,\n textureRatio,\n b.width(),\n b.height(),\n { ...(textureOptions || {}), fill: textureColor },\n x + b.x1 - x,\n y + b.y1 - y\n );\n context.restore();\n }\n }\n}\n\nexport const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/contributions/base-texture-contribution-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAUtE,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC,MAAM,OAAO,oCAAoC;IAAjD;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QAEzB,UAAK,GAAW,EAAE,CAAC;IAsNrB,CAAC;IApNC,mBAAmB,CACjB,IAAY,EACZ,OAAe,EACf,KAAa,EACb,aAAyB,EACzB,EAAkD;QAElD,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC;QAC9B,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAA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E,OAAO,CAAC,CAAC;oBAC3F,MAAM;gBACR,KAAK,MAAM;oBACT,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;oBACrF,MAAM;aACT;SACF;QAED,IAAI,OAAO,EAAE;YACX,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAC9B,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;YAC3E,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC;YAC5B,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,oCAAoC,EAAE,CAAC","file":"base-texture-contribution-render.js","sourcesContent":["import { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IBaseRenderContribution,\n IContext2d,\n IDrawContext,\n IGraphic,\n IGraphicAttribute,\n IStage,\n IThemeAttribute\n} from '../../../../interface';\nimport { pi2 } from '@visactor/vutils';\n\nexport class DefaultBaseTextureRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n textureMap?: Map<string, CanvasPattern>;\n order: number = 10;\n\n createCommonPattern(\n size: number,\n padding: number,\n color: string,\n targetContext: IContext2d,\n cb: (r: number, targetContext: IContext2d) => void\n ) {\n const r = (size - padding * 2) / 2;\n const dpr = targetContext.dpr;\n const canvas = canvasAllocate.allocate({ width: size, height: size, dpr });\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return null;\n }\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, size, size);\n //setup up design for pattern\n cb(r, ctx);\n const pattern = targetContext.createPattern(canvas.nativeCanvas, 'repeat');\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n\n canvasAllocate.free(canvas);\n return pattern;\n }\n\n createCirclePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.fillStyle = color;\n ctx.arc(r, r, r, 0, pi2);\n ctx.fill();\n });\n }\n\n createDiamondPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = size / 2;\n const y = x;\n ctx.fillStyle = color;\n ctx.moveTo(x, y - r);\n ctx.lineTo(r + x, y);\n ctx.lineTo(x, y + r);\n ctx.lineTo(x - r, y);\n ctx.closePath();\n ctx.fill();\n });\n }\n\n createRectPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, r * 2);\n });\n }\n\n createVerticalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = 0;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, size);\n });\n }\n\n createHorizontalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = 0;\n const y = padding;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, size, r * 2);\n });\n }\n\n createBiasLRLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(0, 0);\n ctx.lineTo(size, size);\n const dx = size / 2;\n const dy = -dx;\n ctx.moveTo(dx, dy);\n ctx.lineTo(dx + size, dy + size);\n ctx.moveTo(-dx, -dy);\n ctx.lineTo(-dx + size, -dy + size);\n ctx.stroke();\n });\n }\n\n createBiasRLLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(size, 0);\n ctx.lineTo(0, size);\n const dx = size / 2;\n const dy = dx;\n ctx.moveTo(size + dx, dy);\n ctx.lineTo(dx, dy + size);\n ctx.moveTo(size - dx, -dy);\n ctx.lineTo(-dx, -dy + size);\n ctx.stroke();\n });\n }\n\n createGridPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r, r);\n ctx.fillRect(x + r, y + r, r, r);\n });\n }\n\n initTextureMap(ctx: IContext2d, stage: IStage) {\n this.textureMap = new Map();\n // ResourceLoader.GetImage(rect1, {\n // imageLoadFail: () => {\n // return;\n // },\n // imageLoadSuccess: (url, img) => {\n // const pattern = ctx.createPattern(img, 'repeat');\n // this.textureMap.set('rect1', pattern);\n // stage && stage.renderNextFrame();\n // }\n // });\n }\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this.textureMap) {\n this.initTextureMap(context, graphic.stage);\n }\n const {\n texture = graphicAttribute.texture,\n textureColor = graphicAttribute.textureColor,\n textureSize = graphicAttribute.textureSize,\n texturePadding = graphicAttribute.texturePadding\n } = graphic.attribute;\n if (!texture) {\n return;\n }\n this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);\n }\n\n protected drawTexture(\n texture: string,\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n graphicAttribute: Required<IGraphicAttribute>,\n textureColor: string,\n textureSize: number,\n texturePadding: number\n ) {\n let pattern: CanvasPattern = this.textureMap.get(texture);\n\n if (!pattern) {\n switch (texture) {\n case 'circle':\n pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'diamond':\n pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'rect':\n pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'vertical-line':\n pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'horizontal-line':\n pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-lr':\n pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-rl':\n pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'grid':\n pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);\n break;\n }\n }\n\n if (pattern) {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.fillStyle = pattern;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n}\n\nexport const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();\n"]}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type { IGraphicAttribute, IContext2d,
|
|
1
|
+
import type { IGraphicAttribute, IContext2d, IThemeAttribute, IImageRenderContribution, IDrawContext, IMarkAttribute } from '../../../../interface';
|
|
2
2
|
import { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';
|
|
3
3
|
import { BaseRenderContributionTime } from '../../../../common/enums';
|
|
4
4
|
import { DefaultRectRenderContribution } from './rect-contribution-render';
|
|
5
|
-
export declare class DefaultImageBackgroundRenderContribution extends DefaultBaseBackgroundRenderContribution implements IImageRenderContribution {
|
|
6
|
-
time: BaseRenderContributionTime;
|
|
7
|
-
drawShape(graphic: IImage, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, graphicAttribute: Required<IGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
8
|
-
}
|
|
9
5
|
export declare class DefaultImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {
|
|
10
6
|
time: BaseRenderContributionTime;
|
|
11
7
|
useStyle: boolean;
|
|
@@ -13,4 +9,4 @@ export declare class DefaultImageRenderContribution extends DefaultRectRenderCon
|
|
|
13
9
|
drawShape(rect: any, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, rectAttribute: any, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
14
10
|
}
|
|
15
11
|
export declare const defaultImageRenderContribution: DefaultImageRenderContribution;
|
|
16
|
-
export declare const defaultImageBackgroundRenderContribution:
|
|
12
|
+
export declare const defaultImageBackgroundRenderContribution: DefaultBaseBackgroundRenderContribution;
|
|
@@ -1,59 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { DefaultBaseBackgroundRenderContribution } from "./base-contribution-render";
|
|
1
|
+
import { defaultBaseBackgroundRenderContribution } from "./base-contribution-render";
|
|
4
2
|
|
|
5
3
|
import { BaseRenderContributionTime } from "../../../../common/enums";
|
|
6
4
|
|
|
7
|
-
import { isNumber, isObject } from "@visactor/vutils";
|
|
8
|
-
|
|
9
|
-
import { parsePadding } from "../../../../common/utils";
|
|
10
|
-
|
|
11
|
-
import { createRectPath } from "../../../../common/shape/rect";
|
|
12
|
-
|
|
13
5
|
import { DefaultRectRenderContribution } from "./rect-contribution-render";
|
|
14
6
|
|
|
15
|
-
export class DefaultImageBackgroundRenderContribution extends DefaultBaseBackgroundRenderContribution {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(...arguments), this.time = BaseRenderContributionTime.beforeFillStroke;
|
|
18
|
-
}
|
|
19
|
-
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
|
|
20
|
-
const {background: background, backgroundMode: backgroundMode = graphicAttribute.backgroundMode, backgroundFit: backgroundFit = graphicAttribute.backgroundFit, width: width, height: height} = graphic.attribute;
|
|
21
|
-
if (background) if (graphic.backgroundImg) {
|
|
22
|
-
const res = graphic.resources.get(background);
|
|
23
|
-
if ("success" !== res.state || !res.data) return;
|
|
24
|
-
if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
|
|
25
|
-
const groupAttribute = getTheme(graphic.parent).group, {scrollX: scrollX = groupAttribute.scrollX, scrollY: scrollY = groupAttribute.scrollY} = graphic.parent.attribute;
|
|
26
|
-
context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
|
|
27
|
-
}
|
|
28
|
-
const b = graphic.AABBBounds;
|
|
29
|
-
this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(),
|
|
30
|
-
graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
|
|
31
|
-
} else if (isObject(background)) {
|
|
32
|
-
const {stroke: stroke, fill: fill, lineWidth: lineWidth = 1, cornerRadius: cornerRadius = 0, expandX: expandX = 0, expandY: expandY = 0} = background;
|
|
33
|
-
if (!stroke && !fill) return;
|
|
34
|
-
context.beginPath();
|
|
35
|
-
const {x: x, y: y, width: width, height: height} = getActualPosition(graphic);
|
|
36
|
-
cornerRadius ? createRectPath(context, x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY, cornerRadius) : context.rect(x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY),
|
|
37
|
-
context.globalAlpha = 1, fill && (context.fillStyle = fill, context.fill()), stroke && lineWidth > 0 && (context.lineWidth = lineWidth,
|
|
38
|
-
context.strokeStyle = stroke, context.stroke());
|
|
39
|
-
} else context.beginPath(), context.rect(x, y, width || 0, height || 0), context.fillStyle = background,
|
|
40
|
-
context.globalAlpha = 1, context.fill();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getActualPosition(graphic) {
|
|
45
|
-
const boundsPadding = parsePadding(graphic.attribute.boundsPadding), bounds = graphic.AABBBounds;
|
|
46
|
-
let x = bounds.x1, y = bounds.y1, width = bounds.width(), height = bounds.height();
|
|
47
|
-
return isNumber(boundsPadding) ? (x += boundsPadding, y += boundsPadding, width -= 2 * boundsPadding,
|
|
48
|
-
height -= 2 * boundsPadding) : (x += boundsPadding[3], y += boundsPadding[0], width -= boundsPadding[1] + boundsPadding[3],
|
|
49
|
-
height -= boundsPadding[0] + boundsPadding[2]), {
|
|
50
|
-
x: x,
|
|
51
|
-
y: y,
|
|
52
|
-
width: width,
|
|
53
|
-
height: height
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
7
|
export class DefaultImageRenderContribution extends DefaultRectRenderContribution {
|
|
58
8
|
constructor() {
|
|
59
9
|
super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0,
|
|
@@ -66,5 +16,5 @@ export class DefaultImageRenderContribution extends DefaultRectRenderContributio
|
|
|
66
16
|
|
|
67
17
|
export const defaultImageRenderContribution = new DefaultImageRenderContribution;
|
|
68
18
|
|
|
69
|
-
export const defaultImageBackgroundRenderContribution =
|
|
19
|
+
export const defaultImageBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
|
|
70
20
|
//# sourceMappingURL=image-contribution-render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/contributions/image-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAE3E,MAAM,OAAO,wCACX,SAAQ,uCAAuC;IADjD;;QAIE,SAAI,GAA+B,0BAA0B,CAAC,gBAAgB,CAAC;IA2FjF,CAAC;IAzFC,SAAS,CACP,OAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH;QAEnH,MAAM,EACJ,UAAU,EACV,cAAc,GAAG,gBAAgB,CAAC,cAAc,EAChD,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAC9C,KAAK,EACL,MAAM,EACP,GAAG,OAAO,CAAC,SAAS,CAAC;QACtB,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC1B,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE;gBACxB,MAAM,EACJ,MAAM,EACN,IAAI,EACJ,SAAS,GAAG,CAAC,EACb,YAAY,GAAG,CAAC,EAChB,OAAO,GAAG,CAAC,EACX,OAAO,GAAG,CAAC,EACZ,G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,IAAI,8BAA8B,EAAE,CAAC;AACnF,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,wCAAwC,EAAE,CAAC","file":"image-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IImage,\n IThemeAttribute,\n IImageRenderContribution,\n IDrawContext,\n IBackgroundConfig,\n IGraphic,\n IMarkAttribute\n} from '../../../../interface';\nimport { getTheme } from '../../../../graphic/theme';\nimport { DefaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { isNumber, isObject } from '@visactor/vutils';\nimport { parsePadding } from '../../../../common/utils';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { DefaultRectRenderContribution } from './rect-contribution-render';\n\nexport class DefaultImageBackgroundRenderContribution\n extends DefaultBaseBackgroundRenderContribution\n implements IImageRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n drawShape(\n graphic: IImage,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n ) {\n const {\n background,\n backgroundMode = graphicAttribute.backgroundMode,\n backgroundFit = graphicAttribute.backgroundFit,\n width,\n height\n } = graphic.attribute;\n if (!background) {\n return;\n }\n\n if (!graphic.backgroundImg) {\n if (isObject(background)) {\n const {\n stroke,\n fill,\n lineWidth = 1,\n cornerRadius = 0,\n expandX = 0,\n expandY = 0\n } = background as IBackgroundConfig;\n\n if (!stroke && !fill) {\n return;\n }\n\n context.beginPath();\n const { x, y, width, height } = getActualPosition(graphic);\n if (cornerRadius) {\n createRectPath(context, x - expandX, y - expandY, width + expandX * 2, height + expandY * 2, cornerRadius);\n } else {\n context.rect(x - expandX, y - expandY, width + expandX * 2, height + expandY * 2);\n }\n\n context.globalAlpha = 1;\n if (fill) {\n context.fillStyle = fill as string;\n context.fill();\n }\n\n if (stroke && lineWidth > 0) {\n context.lineWidth = lineWidth;\n context.strokeStyle = stroke as string;\n context.stroke();\n }\n } else {\n context.beginPath();\n // const b = graphic.AABBBounds;\n // image的背景不包括Bounds了\n context.rect(x, y, width || 0, height || 0);\n context.fillStyle = background as string;\n context.globalAlpha = 1;\n context.fill();\n }\n } else {\n const res = graphic.resources.get(background as any);\n if (res.state !== 'success' || !res.data) {\n return;\n }\n context.save();\n if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n const groupAttribute = getTheme(graphic.parent).group;\n const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n context.translate(scrollX, scrollY);\n }\n // context.clip();\n const b = graphic.AABBBounds;\n this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit);\n context.restore();\n if (!graphic.transMatrix.onlyTranslate()) {\n context.setTransformForCurrent();\n }\n }\n }\n}\n\nfunction getActualPosition(graphic: IGraphic) {\n const boundsPadding = parsePadding(graphic.attribute.boundsPadding);\n const bounds = graphic.AABBBounds;\n let x = bounds.x1;\n let y = bounds.y1;\n let width = bounds.width();\n let height = bounds.height();\n\n if (isNumber(boundsPadding)) {\n x += boundsPadding;\n y += boundsPadding;\n width -= boundsPadding * 2;\n height -= boundsPadding * 2;\n } else {\n x += boundsPadding[3];\n y += boundsPadding[0];\n width -= boundsPadding[1] + boundsPadding[3];\n height -= boundsPadding[0] + boundsPadding[2];\n }\n\n return {\n x,\n y,\n width,\n height\n };\n}\n\nexport class DefaultImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\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 return super.drawShape(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n}\n\nexport const defaultImageRenderContribution = new DefaultImageRenderContribution();\nexport const defaultImageBackgroundRenderContribution = new DefaultImageBackgroundRenderContribution();\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/contributions/image-contribution-render.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,uCAAuC,EAExC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAItE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AA+H3E,MAAM,OAAO,8BAA+B,SAAQ,6BAA6B;IAAjF;;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAsCpB,CAAC;IArCC,SAAS,CACP,IAAS,EACT,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,aAAkB,EAClB,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,OAAO,KAAK,CAAC,SAAS,CACpB,IAAI,EACJ,OAAO,EACP,CAAC,EACD,CAAC,EACD,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,WAAW,EACX,MAAM,EACN,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,8BAA8B,EAAE,CAAC;AACnF,MAAM,CAAC,MAAM,wCAAwC,GAAG,uCAAuC,CAAC","file":"image-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IImage,\n IThemeAttribute,\n IImageRenderContribution,\n IDrawContext,\n IBackgroundConfig,\n IGraphic,\n IMarkAttribute\n} from '../../../../interface';\nimport { getTheme } from '../../../../graphic/theme';\nimport {\n defaultBaseBackgroundRenderContribution,\n DefaultBaseBackgroundRenderContribution\n} from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { isNumber, isObject } from '@visactor/vutils';\nimport { parsePadding } from '../../../../common/utils';\nimport { createRectPath } from '../../../../common/shape/rect';\nimport { DefaultRectRenderContribution } from './rect-contribution-render';\n\n// export class DefaultImageBackgroundRenderContribution\n// extends DefaultBaseBackgroundRenderContribution\n// implements IImageRenderContribution\n// {\n// time: BaseRenderContributionTime = BaseRenderContributionTime.beforeFillStroke;\n\n// drawShape(\n// graphic: IImage,\n// context: IContext2d,\n// x: number,\n// y: number,\n// doFill: boolean,\n// doStroke: boolean,\n// fVisible: boolean,\n// sVisible: boolean,\n// graphicAttribute: Required<IGraphicAttribute>,\n// drawContext: IDrawContext,\n// fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n// strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean\n// ) {\n// const {\n// background,\n// backgroundMode = graphicAttribute.backgroundMode,\n// backgroundFit = graphicAttribute.backgroundFit,\n// width,\n// height\n// } = graphic.attribute;\n// if (!background) {\n// return;\n// }\n\n// if (!graphic.backgroundImg) {\n// if (isObject(background)) {\n// const {\n// stroke,\n// fill,\n// lineWidth = 1,\n// cornerRadius = 0,\n// expandX = 0,\n// expandY = 0\n// } = background as IBackgroundConfig;\n\n// if (!stroke && !fill) {\n// return;\n// }\n\n// context.beginPath();\n// const { x, y, width, height } = getActualPosition(graphic);\n// if (cornerRadius) {\n// createRectPath(context, x - expandX, y - expandY, width + expandX * 2, height + expandY * 2, cornerRadius);\n// } else {\n// context.rect(x - expandX, y - expandY, width + expandX * 2, height + expandY * 2);\n// }\n\n// context.globalAlpha = 1;\n// if (fill) {\n// context.fillStyle = fill as string;\n// context.fill();\n// }\n\n// if (stroke && lineWidth > 0) {\n// context.lineWidth = lineWidth;\n// context.strokeStyle = stroke as string;\n// context.stroke();\n// }\n// } else {\n// context.beginPath();\n// // const b = graphic.AABBBounds;\n// // image的背景不包括Bounds了\n// context.rect(x, y, width || 0, height || 0);\n// context.fillStyle = background as string;\n// context.globalAlpha = 1;\n// context.fill();\n// }\n// } else {\n// const res = graphic.resources.get(background as any);\n// if (res.state !== 'success' || !res.data) {\n// return;\n// }\n// context.save();\n// if (graphic.parent && !graphic.transMatrix.onlyTranslate()) {\n// const groupAttribute = getTheme(graphic.parent).group;\n// const { scrollX = groupAttribute.scrollX, scrollY = groupAttribute.scrollY } = graphic.parent.attribute;\n// context.setTransformFromMatrix(graphic.parent.globalTransMatrix, true);\n// context.translate(scrollX, scrollY);\n// }\n// // context.clip();\n// const b = graphic.AABBBounds;\n// this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit);\n// context.restore();\n// if (!graphic.transMatrix.onlyTranslate()) {\n// context.setTransformForCurrent();\n// }\n// }\n// }\n// }\n\n// function getActualPosition(graphic: IGraphic) {\n// const boundsPadding = parsePadding(graphic.attribute.boundsPadding);\n// const bounds = graphic.AABBBounds;\n// let x = bounds.x1;\n// let y = bounds.y1;\n// let width = bounds.width();\n// let height = bounds.height();\n\n// if (isNumber(boundsPadding)) {\n// x += boundsPadding;\n// y += boundsPadding;\n// width -= boundsPadding * 2;\n// height -= boundsPadding * 2;\n// } else {\n// x += boundsPadding[3];\n// y += boundsPadding[0];\n// width -= boundsPadding[1] + boundsPadding[3];\n// height -= boundsPadding[0] + boundsPadding[2];\n// }\n\n// return {\n// x,\n// y,\n// width,\n// height\n// };\n// }\n\nexport class DefaultImageRenderContribution extends DefaultRectRenderContribution implements IImageRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n rect: any,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n rectAttribute: any,\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 return super.drawShape(\n rect,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n rectAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n}\n\nexport const defaultImageRenderContribution = new DefaultImageRenderContribution();\nexport const defaultImageBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, ISymbolGraphicAttribute, IThemeAttribute, ISymbolRenderContribution, IDrawContext
|
|
1
|
+
import type { IGraphicAttribute, IContext2d, IMarkAttribute, ISymbol, ISymbolGraphicAttribute, IThemeAttribute, ISymbolRenderContribution, IDrawContext } from '../../../../interface';
|
|
2
2
|
import { BaseRenderContributionTime } from '../../../../common/enums';
|
|
3
3
|
export declare class DefaultSymbolRenderContribution implements ISymbolRenderContribution {
|
|
4
4
|
time: BaseRenderContributionTime;
|
|
@@ -6,13 +6,6 @@ export declare class DefaultSymbolRenderContribution implements ISymbolRenderCon
|
|
|
6
6
|
order: number;
|
|
7
7
|
drawShape(symbol: ISymbol, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, symbolAttribute: Required<ISymbolGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
|
|
8
8
|
}
|
|
9
|
-
export declare class DefaultSymbolClipRangeStrokeRenderContribution implements IBaseRenderContribution<ISymbol, ISymbolGraphicAttribute> {
|
|
10
|
-
time: BaseRenderContributionTime;
|
|
11
|
-
useStyle: boolean;
|
|
12
|
-
order: number;
|
|
13
|
-
drawShape(graphic: ISymbol, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, graphicAttribute: Required<ISymbolGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, options?: any): void;
|
|
14
|
-
}
|
|
15
9
|
export declare const defaultSymbolRenderContribution: DefaultSymbolRenderContribution;
|
|
16
|
-
export declare const defaultSymbolClipRangeStrokeRenderContribution: DefaultSymbolClipRangeStrokeRenderContribution;
|
|
17
10
|
export declare const defaultSymbolTextureRenderContribution: import("./base-texture-contribution-render").DefaultBaseTextureRenderContribution;
|
|
18
11
|
export declare const defaultSymbolBackgroundRenderContribution: import("./base-contribution-render").DefaultBaseBackgroundRenderContribution;
|
|
@@ -29,34 +29,8 @@ export class DefaultSymbolRenderContribution {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export class DefaultSymbolClipRangeStrokeRenderContribution {
|
|
33
|
-
constructor() {
|
|
34
|
-
this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
35
|
-
}
|
|
36
|
-
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
|
|
37
|
-
const {clipRange: clipRange = graphicAttribute.clipRange, x: originX = graphicAttribute.x, y: originY = graphicAttribute.y, z: z = graphicAttribute.z, size: size = graphicAttribute.size, scaleX: scaleX = graphicAttribute.scaleX, scaleY: scaleY = graphicAttribute.scaleY} = graphic.attribute, parsedPath = graphic.getParsedPath();
|
|
38
|
-
if (!(parsedPath && clipRange < 1 && clipRange > 0)) return;
|
|
39
|
-
context.beginPath(), parsedPath.drawWithClipRange && parsedPath.drawWithClipRange(context, size, x, y, clipRange, z, ((p, a) => {
|
|
40
|
-
var _a, _b, _c, _d;
|
|
41
|
-
if (graphic._parsedPath.svgCache) {
|
|
42
|
-
const obj = Object.assign({}, a);
|
|
43
|
-
obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : graphic.attribute.fill,
|
|
44
|
-
obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : graphic.attribute.opacity,
|
|
45
|
-
obj.fillOpacity = graphic.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : graphic.attribute.stroke,
|
|
46
|
-
obj.lineWidth = null !== (_d = a.lineWidth) && void 0 !== _d ? _d : graphic.attribute.lineWidth,
|
|
47
|
-
a = obj;
|
|
48
|
-
}
|
|
49
|
-
a.stroke && (strokeCb ? strokeCb(context, graphic.attribute, graphicAttribute) : sVisible && (context.setStrokeStyle(graphic, a, (originX - x) / scaleX, (originY - y) / scaleY, graphicAttribute),
|
|
50
|
-
context.stroke()));
|
|
51
|
-
})), doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, graphic.attribute, graphicAttribute) : sVisible && (context.setStrokeStyle(graphic, graphic.attribute, (originX - x) / scaleX, (originY - y) / scaleY, graphicAttribute),
|
|
52
|
-
context.stroke()));
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
32
|
export const defaultSymbolRenderContribution = new DefaultSymbolRenderContribution;
|
|
57
33
|
|
|
58
|
-
export const defaultSymbolClipRangeStrokeRenderContribution = new DefaultSymbolClipRangeStrokeRenderContribution;
|
|
59
|
-
|
|
60
34
|
export const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;
|
|
61
35
|
|
|
62
36
|
export const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/contributions/symbol-contribution-render.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,+BAA+B;IAA5C;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QACzB,UAAK,GAAW,CAAC,CAAC;IAkFpB,CAAC;IAjFC,SAAS,CACP,MAAe,EACf,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,eAAkD,EAClD,WAAyB,EACzB,MAIY,EACZ,QAIY;QAEZ,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;QAE1C,IAAI,CAAC,UAAU,EAAE;YACf,OAAO;SACR;QAED,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;QACtD,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAAC;QACnE,MAAM,aAAa,GAAG,WAAW,IAAI,WAAW,CAAC,OAAO,KAAK,KAAK,CAA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AO,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,gBAAgB,CAAC,CAAC;oBACrG,OAAO,CAAC,MAAM,EAAE,CAAC;iBAClB;aACF;QACH,CAAC,CAAC;QAEF,OAAO,CAAC,SAAS,EAAE,CAAC;QACpB,UAAU,CAAC,iBAAiB,IAAI,UAAU,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;QAE1G,IAAI,QAAQ,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;YACjC,IAAI,QAAQ,EAAE;gBACZ,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;aACxD;iBAAM,IAAI,QAAQ,EAAE;gBACnB,OAAO,CAAC,cAAc,CACpB,OAAO,EACP,OAAO,CAAC,SAAS,EACjB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,CAAC,OAAO,GAAG,CAAC,CAAC,GAAG,MAAM,EACtB,gBAAgB,CACjB,CAAC;gBACF,OAAO,CAAC,MAAM,EAAE,CAAC;aAClB;SACF;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,EAAE,CAAC;AACrF,MAAM,CAAC,MAAM,8CAA8C,GAAG,IAAI,8CAA8C,EAAE,CAAC;AACnH,MAAM,CAAC,MAAM,sCAAsC,GAAG,oCAAoC,CAAC;AAC3F,MAAM,CAAC,MAAM,yCAAyC,GAAG,uCAAuC,CAAC","file":"symbol-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IBorderStyle,\n IBaseRenderContribution,\n ICustomPath2D\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultSymbolRenderContribution implements ISymbolRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\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 parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { outerBorder, innerBorder } = symbol.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n\n const {\n size = symbolAttribute.size,\n opacity = symbolAttribute.opacity,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY,\n keepStrokeScale = symbolAttribute.keepStrokeScale\n } = symbol.attribute;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = symbolAttribute[key].distance } = borderStyle;\n const d = keepStrokeScale ? (distance as number) : getScaledStroke(context, distance as number, context.dpr);\n const sign = key === 'outerBorder' ? 1 : -1;\n\n context.beginPath();\n if (parsedPath.drawOffset(context, size, x, y, sign * d) === false) {\n context.closePath();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, symbolAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (symbolAttribute[key] as any).opacity;\n (symbolAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n symbol,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute[key] as any\n );\n (symbolAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\nexport class DefaultSymbolClipRangeStrokeRenderContribution\n implements IBaseRenderContribution<ISymbol, ISymbolGraphicAttribute>\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n\n drawShape(\n graphic: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<ISymbolGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n const {\n clipRange = graphicAttribute.clipRange,\n x: originX = graphicAttribute.x,\n y: originY = graphicAttribute.y,\n z = graphicAttribute.z,\n size = graphicAttribute.size,\n scaleX = graphicAttribute.scaleX,\n scaleY = graphicAttribute.scaleY\n } = graphic.attribute;\n const parsedPath = graphic.getParsedPath();\n // todo: 考虑使用path\n if (!(parsedPath && clipRange < 1 && clipRange > 0)) {\n return;\n }\n\n const callback = (p: ICustomPath2D, a: any) => {\n // 如果是svg的话,合并一下fill和stroke\n if (graphic._parsedPath.svgCache) {\n const obj = Object.assign({}, a);\n obj.fill = a.fill ?? graphic.attribute.fill;\n obj.opacity = a.opacity ?? graphic.attribute.opacity;\n obj.fillOpacity = graphic.attribute.fillOpacity;\n obj.stroke = a.stroke ?? graphic.attribute.stroke;\n obj.lineWidth = a.lineWidth ?? graphic.attribute.lineWidth;\n a = obj;\n }\n\n if (a.stroke) {\n if (strokeCb) {\n strokeCb(context, graphic.attribute, graphicAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(graphic, a, (originX - x) / scaleX, (originY - y) / scaleY, graphicAttribute);\n context.stroke();\n }\n }\n };\n\n context.beginPath();\n parsedPath.drawWithClipRange && parsedPath.drawWithClipRange(context, size, x, y, clipRange, z, callback);\n\n if (doStroke && !parsedPath.isSvg) {\n if (strokeCb) {\n strokeCb(context, graphic.attribute, graphicAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(\n graphic,\n graphic.attribute,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n graphicAttribute\n );\n context.stroke();\n }\n }\n }\n}\n\nexport const defaultSymbolRenderContribution = new DefaultSymbolRenderContribution();\nexport const defaultSymbolClipRangeStrokeRenderContribution = new DefaultSymbolClipRangeStrokeRenderContribution();\nexport const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/contributions/symbol-contribution-render.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,uCAAuC,EAAE,MAAM,4BAA4B,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,oCAAoC,CAAC;AAE1F,MAAM,OAAO,+BAA+B;IAA5C;QACE,SAAI,GAA+B,0BAA0B,CAAC,eAAe,CAAC;QAC9E,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C;CACF;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,+BAA+B,EAAE,CAAC;AACrF,MAAM,CAAC,MAAM,sCAAsC,GAAG,oCAAoC,CAAC;AAC3F,MAAM,CAAC,MAAM,yCAAyC,GAAG,uCAAuC,CAAC","file":"symbol-contribution-render.js","sourcesContent":["import type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n ISymbol,\n ISymbolGraphicAttribute,\n IThemeAttribute,\n ISymbolRenderContribution,\n IDrawContext,\n IBorderStyle\n} from '../../../../interface';\nimport { getScaledStroke } from '../../../../common/canvas-utils';\nimport { defaultBaseBackgroundRenderContribution } from './base-contribution-render';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport { defaultBaseTextureRenderContribution } from './base-texture-contribution-render';\n\nexport class DefaultSymbolRenderContribution implements ISymbolRenderContribution {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n order: number = 0;\n drawShape(\n symbol: ISymbol,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n symbolAttribute: Required<ISymbolGraphicAttribute>,\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 parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const { outerBorder, innerBorder } = symbol.attribute;\n const doOuterBorder = outerBorder && outerBorder.visible !== false;\n const doInnerBorder = innerBorder && innerBorder.visible !== false;\n if (!(doOuterBorder || doInnerBorder)) {\n return;\n }\n\n const {\n size = symbolAttribute.size,\n opacity = symbolAttribute.opacity,\n x: originX = symbolAttribute.x,\n y: originY = symbolAttribute.y,\n scaleX = symbolAttribute.scaleX,\n scaleY = symbolAttribute.scaleY,\n keepStrokeScale = symbolAttribute.keepStrokeScale\n } = symbol.attribute;\n\n const renderBorder = (borderStyle: Partial<IBorderStyle>, key: 'outerBorder' | 'innerBorder') => {\n const doStroke = !!(borderStyle && borderStyle.stroke);\n\n const { distance = symbolAttribute[key].distance } = borderStyle;\n const d = keepStrokeScale ? (distance as number) : getScaledStroke(context, distance as number, context.dpr);\n const sign = key === 'outerBorder' ? 1 : -1;\n\n context.beginPath();\n if (parsedPath.drawOffset(context, size, x, y, sign * d) === false) {\n context.closePath();\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute);\n\n if (strokeCb) {\n strokeCb(context, borderStyle, symbolAttribute[key]);\n } else if (doStroke) {\n // 存在stroke\n const lastOpacity = (symbolAttribute[key] as any).opacity;\n (symbolAttribute[key] as any).opacity = opacity;\n context.setStrokeStyle(\n symbol,\n borderStyle,\n (originX - x) / scaleX,\n (originY - y) / scaleY,\n symbolAttribute[key] as any\n );\n (symbolAttribute[key] as any).opacity = lastOpacity;\n context.stroke();\n }\n };\n\n doOuterBorder && renderBorder(outerBorder, 'outerBorder');\n doInnerBorder && renderBorder(innerBorder, 'innerBorder');\n }\n}\n\nexport const defaultSymbolRenderContribution = new DefaultSymbolRenderContribution();\nexport const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;\nexport const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;\n"]}
|
|
@@ -42,17 +42,15 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
42
42
|
const imageAttribute = getTheme(image).image, {width: width = imageAttribute.width, height: height = imageAttribute.height, repeatX: repeatX = imageAttribute.repeatX, repeatY: repeatY = imageAttribute.repeatY, x: originX = imageAttribute.x, y: originY = imageAttribute.y, cornerRadius: cornerRadius = imageAttribute.cornerRadius, fillStrokeOrder: fillStrokeOrder = imageAttribute.fillStrokeOrder, image: url} = image.attribute, data = this.valid(image, imageAttribute, fillCb);
|
|
43
43
|
if (!data) return;
|
|
44
44
|
const {fVisible: fVisible, sVisible: sVisible, doFill: doFill, doStroke: doStroke} = data;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if (!url || !image.resources) return;
|
|
46
|
+
const res = image.resources.get(url);
|
|
47
|
+
if ("success" !== res.state) return;
|
|
48
|
+
let needRestore = !1;
|
|
49
|
+
0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every((num => 0 === num)) || (context.beginPath(),
|
|
50
|
+
createRectPath(context, x, y, width, height, cornerRadius), needRestore = !0), context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);
|
|
47
51
|
const _runFill = () => {
|
|
48
52
|
if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute); else if (fVisible) {
|
|
49
|
-
|
|
50
|
-
const res = image.resources.get(url);
|
|
51
|
-
if ("success" !== res.state) return;
|
|
52
|
-
let needRestore = !1;
|
|
53
|
-
0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every((num => 0 === num)) || (context.beginPath(),
|
|
54
|
-
createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(),
|
|
55
|
-
needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
53
|
+
context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
|
|
56
54
|
let repeat = 0;
|
|
57
55
|
if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2),
|
|
58
56
|
repeat) {
|
|
@@ -60,13 +58,16 @@ let DefaultCanvasImageRender = class extends BaseRender {
|
|
|
60
58
|
context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height),
|
|
61
59
|
context.translate(-x, -y, !0);
|
|
62
60
|
} else context.drawImage(res.data, x, y, width, height);
|
|
63
|
-
needRestore && context.restore();
|
|
64
61
|
}
|
|
65
62
|
}, _runStroke = () => {
|
|
66
63
|
doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute),
|
|
67
|
-
context.
|
|
64
|
+
context.stroke()));
|
|
68
65
|
};
|
|
69
|
-
fillStrokeOrder ? (_runStroke(),
|
|
66
|
+
fillStrokeOrder ? (_runStroke(), needRestore && (context.save(), context.clip()),
|
|
67
|
+
this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
|
|
68
|
+
_runFill(), needRestore && context.restore()) : (needRestore && (context.save(),
|
|
69
|
+
context.clip()), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb),
|
|
70
|
+
_runFill(), needRestore && context.restore(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
|
|
70
71
|
}
|
|
71
72
|
draw(image, renderService, drawContext) {
|
|
72
73
|
const {image: url} = image.attribute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAclD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wCAAwC,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAC3G,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AA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GANtB,wBAAwB,CA2JpC;SA3JY,wBAAwB","file":"image-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IImage,\n IThemeAttribute,\n IGraphicRender,\n IImageRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { ImageRenderContribution } from './contributions/constants';\nimport { fillVisible, runFill } from './utils';\nimport { IMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { isArray, isString } from '@visactor/vutils';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { BaseRender } from './base-render';\nimport { defaultImageBackgroundRenderContribution, defaultImageRenderContribution } from './contributions';\nimport { ResourceLoader } from '../../../resource-loader/loader';\n\nconst repeatStr = ['', 'repeat-x', 'repeat-y', 'repeat'];\n\n@injectable()\nexport class DefaultCanvasImageRender extends BaseRender<IImage> implements IGraphicRender {\n type: 'image';\n numberType: number = IMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IImage,\n context: 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 ) {\n // const imageAttribute = graphicService.themeService.getCurrentTheme().imageAttribute;\n const imageAttribute = getTheme(image).image;\n const {\n width = imageAttribute.width,\n height = imageAttribute.height,\n repeatX = imageAttribute.repeatX,\n repeatY = imageAttribute.repeatY,\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n cornerRadius = imageAttribute.cornerRadius,\n fillStrokeOrder = imageAttribute.fillStrokeOrder,\n image: url\n } = image.attribute;\n\n const data = this.valid(image, imageAttribute, fillCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);\n\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n\n // context.beginPath();\n // context.image(x, y, width, height);\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n if (res.state !== 'success') {\n return;\n }\n\n // deal with cornerRadius\n let needRestore = false;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n } else {\n context.beginPath();\n createRectPath(context, x, y, width, height, cornerRadius);\n context.save();\n context.clip();\n needRestore = true;\n }\n\n context.setCommonStyle(image, image.attribute, x, y, imageAttribute);\n let repeat = 0;\n if (repeatX === 'repeat') {\n repeat |= 0b0001;\n }\n if (repeatY === 'repeat') {\n repeat |= 0b0010;\n }\n if (repeat) {\n const pattern = context.createPattern(res.data, repeatStr[repeat]);\n context.fillStyle = pattern;\n context.translate(x, y, true);\n context.fillRect(0, 0, width, height);\n context.translate(-x, -y, true);\n } else {\n context.drawImage(res.data, x, y, width, height);\n }\n\n if (needRestore) {\n context.restore();\n }\n }\n }\n };\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, image.attribute, imageAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);\n context.strokeRect(x, y, width, height);\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n }\n\n draw(image: IImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { image: url } = image.attribute;\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n // if (res.state !== 'success') {\n // return;\n // }\n if (res.state === 'loading' && isString(url)) {\n ResourceLoader.improveImageLoading(url);\n return;\n } else if (res.state !== 'success') {\n return;\n }\n\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/image-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAclD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wCAAwC,EAAE,8BAA8B,EAAE,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,cAAc,EAA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AU,CAAC;QAC7C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QACD,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAlKY,wBAAwB;IADpC,UAAU,EAAE;IAMR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,uBAAuB,CAAC,CAAA;;GANtB,wBAAwB,CAkKpC;SAlKY,wBAAwB","file":"image-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { getTheme } from '../../../graphic/theme';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IImage,\n IThemeAttribute,\n IGraphicRender,\n IImageRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { ImageRenderContribution } from './contributions/constants';\nimport { fillVisible, runFill } from './utils';\nimport { IMAGE_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { isArray, isString } from '@visactor/vutils';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { BaseRender } from './base-render';\nimport { defaultImageBackgroundRenderContribution, defaultImageRenderContribution } from './contributions';\nimport { ResourceLoader } from '../../../resource-loader/loader';\n\nconst repeatStr = ['', 'repeat-x', 'repeat-y', 'repeat'];\n\n@injectable()\nexport class DefaultCanvasImageRender extends BaseRender<IImage> implements IGraphicRender {\n type: 'image';\n numberType: number = IMAGE_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(ImageRenderContribution)\n protected readonly imageRenderContribitions: IContributionProvider<IImageRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution];\n this.init(imageRenderContribitions);\n }\n\n drawShape(\n image: IImage,\n context: 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 ) {\n // const imageAttribute = graphicService.themeService.getCurrentTheme().imageAttribute;\n const imageAttribute = getTheme(image).image;\n const {\n width = imageAttribute.width,\n height = imageAttribute.height,\n repeatX = imageAttribute.repeatX,\n repeatY = imageAttribute.repeatY,\n x: originX = imageAttribute.x,\n y: originY = imageAttribute.y,\n cornerRadius = imageAttribute.cornerRadius,\n fillStrokeOrder = imageAttribute.fillStrokeOrder,\n image: url\n } = image.attribute;\n\n const data = this.valid(image, imageAttribute, fillCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n if (res.state !== 'success') {\n return;\n }\n\n // deal with cornerRadius\n let needRestore = false;\n if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n } else {\n context.beginPath();\n createRectPath(context, x, y, width, height, cornerRadius);\n needRestore = true;\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(image, image.attribute, imageAttribute);\n // context.beginPath();\n // context.image(x, y, width, height);\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, image.attribute, imageAttribute);\n } else if (fVisible) {\n context.setCommonStyle(image, image.attribute, x, y, imageAttribute);\n let repeat = 0;\n if (repeatX === 'repeat') {\n repeat |= 0b0001;\n }\n if (repeatY === 'repeat') {\n repeat |= 0b0010;\n }\n if (repeat) {\n const pattern = context.createPattern(res.data, repeatStr[repeat]);\n context.fillStyle = pattern;\n context.translate(x, y, true);\n context.fillRect(0, 0, width, height);\n context.translate(-x, -y, true);\n } else {\n context.drawImage(res.data, x, y, width, height);\n }\n }\n }\n };\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, image.attribute, imageAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n if (needRestore) {\n context.save();\n context.clip();\n }\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n _runFill();\n if (needRestore) {\n context.restore();\n }\n _runStroke();\n } else {\n _runStroke();\n if (needRestore) {\n context.save();\n context.clip();\n }\n this.beforeRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n _runFill();\n if (needRestore) {\n context.restore();\n }\n }\n\n this.afterRenderStep(image, context, x, y, doFill, false, fVisible, false, imageAttribute, drawContext, fillCb);\n }\n\n draw(image: IImage, renderService: IRenderService, drawContext: IDrawContext) {\n const { image: url } = image.attribute;\n if (!url || !image.resources) {\n return;\n }\n const res = image.resources.get(url);\n // if (res.state !== 'success') {\n // return;\n // }\n if (res.state === 'loading' && isString(url)) {\n ResourceLoader.improveImageLoading(url);\n return;\n } else if (res.state !== 'success') {\n return;\n }\n\n const { context } = renderService.drawParams;\n if (!context) {\n return;\n }\n const imageAttribute = getTheme(image).image;\n this._draw(image, imageAttribute, false, drawContext);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/path-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,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AAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,IAAI,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,aAAa,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF,CAAA;AA9HY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;IAC5B,WAAA,KAAK,CAAC,sBAAsB,CAAC,CAAA;;GAPrB,uBAAuB,CA8HnC;SA9HY,uBAAuB","file":"path-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { renderCommandList } from '../../../common/render-command-list';\nimport type {\n IPath,\n ICustomPath2D,\n IContext2d,\n IThemeAttribute,\n IGraphicAttribute,\n IMarkAttribute,\n IPathRenderContribution,\n IGraphicRender,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService,\n IPathGraphicAttribute\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { PATH_NUMBER_TYPE } from '../../../graphic/constants';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { PathRenderContribution } from './contributions/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { BaseRender } from './base-render';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport {\n defaultPathBackgroundRenderContribution,\n defaultPathTextureRenderContribution\n} from './contributions/path-contribution-render';\n\n@injectable()\nexport class DefaultCanvasPathRender extends BaseRender<IPath> implements IGraphicRender {\n type: 'path';\n numberType: number = PATH_NUMBER_TYPE;\n tempTheme: Required<IPathGraphicAttribute>;\n\n constructor(\n @inject(ContributionProvider)\n @named(PathRenderContribution)\n protected readonly pathRenderContribitions: IContributionProvider<IPathRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultPathBackgroundRenderContribution, defaultPathTextureRenderContribution];\n this.init(pathRenderContribitions);\n }\n\n drawShape(\n path: IPath,\n context: 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 ) {\n // const pathAttribute = graphicService.themeService.getCurrentTheme().pathAttribute;\n const pathAttribute = this.tempTheme ?? getTheme(path, params?.theme).path;\n const {\n x: originX = pathAttribute.x,\n y: originY = pathAttribute.y,\n fillStrokeOrder = pathAttribute.fillStrokeOrder\n } = path.attribute;\n\n const z = this.z ?? 0;\n\n const data = this.valid(path, pathAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n context.beginPath();\n if (path.pathShape) {\n renderCommandList((path.pathShape as ICustomPath2D).commandList, context, x, y, 1, 1, z);\n } else {\n const path2D = path.attribute.path ?? pathAttribute.path;\n renderCommandList((path2D as ICustomPath2D).commandList, context, x, y, 1, 1, z);\n }\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute);\n\n this.beforeRenderStep(\n path,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n pathAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, path.attribute, pathAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute);\n context.stroke();\n }\n }\n };\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, path.attribute, pathAttribute);\n } else if (fVisible) {\n context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute);\n context.fill();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(\n path,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n pathAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(path: IPath, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const pathAttribute = getTheme(path, params?.theme).path;\n this.tempTheme = pathAttribute;\n this._draw(path, pathAttribute, false, drawContext, params);\n this.tempTheme = null;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/polygon-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAcjE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render/polygon-render.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAcjE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE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C5B,WAAA,KAAK,CAAC,yBAAyB,CAAC,CAAA;;GANxB,0BAA0B,CAiItC;SAjIY,0BAA0B","file":"polygon-render.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { inject, injectable, named } from '../../../common/inversify-lite';\nimport { getTheme } from '../../../graphic/theme';\nimport { POLYGON_NUMBER_TYPE } from '../../../graphic/constants';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IMarkAttribute,\n IPolygon,\n IThemeAttribute,\n IGraphicRender,\n IPolygonRenderContribution,\n IContributionProvider,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '../../../interface';\nimport { drawPolygon, drawRoundedPolygon } from '../../../common/polygon';\nimport { drawPathProxy, fillVisible, runFill, runStroke, strokeVisible } from './utils';\nimport { PolygonRenderContribution } from './contributions/constants';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { BaseRender } from './base-render';\nimport {\n defaultPolygonBackgroundRenderContribution,\n defaultPolygonTextureRenderContribution\n} from './contributions/polygon-contribution-render';\n\n@injectable()\nexport class DefaultCanvasPolygonRender extends BaseRender<IPolygon> implements IGraphicRender {\n type: 'polygon';\n numberType: number = POLYGON_NUMBER_TYPE;\n\n constructor(\n @inject(ContributionProvider)\n @named(PolygonRenderContribution)\n protected readonly polygonRenderContribitions: IContributionProvider<IPolygonRenderContribution>\n ) {\n super();\n this.builtinContributions = [defaultPolygonBackgroundRenderContribution, defaultPolygonTextureRenderContribution];\n this.init(polygonRenderContribitions);\n }\n\n drawShape(\n polygon: IPolygon,\n context: 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 ) {\n // const polygonAttribute = graphicService.themeService.getCurrentTheme().polygonAttribute;\n const polygonAttribute = getTheme(polygon, params?.theme).polygon;\n const {\n points = polygonAttribute.points,\n cornerRadius = polygonAttribute.cornerRadius,\n x: originX = polygonAttribute.x,\n y: originY = polygonAttribute.y,\n closePath = polygonAttribute.closePath,\n fillStrokeOrder = polygonAttribute.fillStrokeOrder\n } = polygon.attribute;\n\n const data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);\n if (!data) {\n return;\n }\n const { fVisible, sVisible, doFill, doStroke } = data;\n\n context.beginPath();\n\n if ((cornerRadius as number) <= 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n drawPolygon(context.camera ? context : context.nativeContext, points, x, y);\n } else {\n // FIXME: type\n drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath);\n }\n // polygon 默认闭合\n closePath && context.closePath();\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute);\n\n this.beforeRenderStep(\n polygon,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n polygonAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n\n const _runFill = () => {\n if (doFill) {\n if (fillCb) {\n fillCb(context, polygon.attribute, polygonAttribute);\n } else if (fVisible) {\n // 存在fill\n context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute);\n context.fill();\n }\n }\n };\n const _runStroke = () => {\n if (doStroke) {\n if (strokeCb) {\n strokeCb(context, polygon.attribute, polygonAttribute);\n } else if (sVisible) {\n // 存在stroke\n context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this.afterRenderStep(\n polygon,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n polygonAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n\n draw(polygon: IPolygon, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const polygonAttribute = getTheme(polygon, params?.theme).polygon;\n this._draw(polygon, polygonAttribute, false, drawContext, params);\n }\n}\n"]}
|