@visactor/vrender-kits 0.9.0 → 0.9.1-circular.0
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/render/contributions/rough/rough-arc.js +5 -4
- package/cjs/render/contributions/rough/rough-arc.js.map +1 -1
- package/cjs/render/contributions/rough/rough-area.js +3 -3
- package/cjs/render/contributions/rough/rough-area.js.map +1 -1
- package/cjs/render/contributions/rough/rough-circle.js +3 -3
- package/cjs/render/contributions/rough/rough-circle.js.map +1 -1
- package/cjs/render/contributions/rough/rough-line.js +3 -3
- package/cjs/render/contributions/rough/rough-line.js.map +1 -1
- package/cjs/render/contributions/rough/rough-path.js +4 -5
- package/cjs/render/contributions/rough/rough-path.js.map +1 -1
- package/cjs/render/contributions/rough/rough-rect.js +1 -1
- package/cjs/render/contributions/rough/rough-rect.js.map +1 -1
- package/cjs/render/contributions/rough/rough-symbol.js +1 -1
- package/cjs/render/contributions/rough/rough-symbol.js.map +1 -1
- package/dist/vrender-kits.js.js +1 -1
- package/dist/vrender-kits.js.min.js +1 -1
- package/es/render/contributions/rough/rough-arc.js +5 -4
- package/es/render/contributions/rough/rough-arc.js.map +1 -1
- package/es/render/contributions/rough/rough-area.js +3 -3
- package/es/render/contributions/rough/rough-area.js.map +1 -1
- package/es/render/contributions/rough/rough-circle.js +3 -3
- package/es/render/contributions/rough/rough-circle.js.map +1 -1
- package/es/render/contributions/rough/rough-line.js +3 -3
- package/es/render/contributions/rough/rough-line.js.map +1 -1
- package/es/render/contributions/rough/rough-path.js +4 -5
- package/es/render/contributions/rough/rough-path.js.map +1 -1
- package/es/render/contributions/rough/rough-rect.js +1 -1
- package/es/render/contributions/rough/rough-rect.js.map +1 -1
- package/es/render/contributions/rough/rough-symbol.js +1 -1
- package/es/render/contributions/rough/rough-symbol.js.map +1 -1
- package/package.json +2 -2
|
@@ -37,10 +37,10 @@ let RoughCanvasArcRender = class {
|
|
|
37
37
|
const {dx: dx = arcAttribute.dx, dy: dy = arcAttribute.dy} = arc.attribute;
|
|
38
38
|
x += dx, y += dy, context.setTransformForCurrent();
|
|
39
39
|
} else x = 0, y = 0, context.transformFromMatrix(arc.transMatrix, !0);
|
|
40
|
-
const customPath = new vrender_1.CustomPath2D, {fill: fill =
|
|
40
|
+
const customPath = new vrender_1.CustomPath2D, {fill: fill = arcAttribute.fill, stroke: stroke = arcAttribute.stroke, lineWidth: lineWidth = arcAttribute.lineWidth, outerRadius: outerRadius = arcAttribute.outerRadius, innerRadius: innerRadius = arcAttribute.innerRadius, maxRandomnessOffset: maxRandomnessOffset = config_1.defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = config_1.defaultRouthThemeSpec.roughness, bowing: bowing = config_1.defaultRouthThemeSpec.bowing, curveFitting: curveFitting = config_1.defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = config_1.defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = config_1.defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = config_1.defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = config_1.defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = config_1.defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = config_1.defaultRouthThemeSpec.hachureGap, simplification: simplification = config_1.defaultRouthThemeSpec.simplification, dashOffset: dashOffset = config_1.defaultRouthThemeSpec.dashOffset, dashGap: dashGap = config_1.defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = config_1.defaultRouthThemeSpec.zigzagOffset, seed: seed = config_1.defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = config_1.defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = config_1.defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = config_1.defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = config_1.defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = config_1.defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = config_1.defaultRouthThemeSpec.fixedDecimalPlaceDigits} = arc.attribute;
|
|
41
41
|
(0, vrender_1.drawArcPath)(arc, customPath, x, y, outerRadius, innerRadius), rc.path(customPath.toString(), {
|
|
42
|
-
fill: fill
|
|
43
|
-
stroke: stroke
|
|
42
|
+
fill: fill || void 0,
|
|
43
|
+
stroke: stroke || void 0,
|
|
44
44
|
strokeWidth: lineWidth,
|
|
45
45
|
maxRandomnessOffset: maxRandomnessOffset,
|
|
46
46
|
roughness: roughness,
|
|
@@ -72,4 +72,5 @@ let RoughCanvasArcRender = class {
|
|
|
72
72
|
|
|
73
73
|
RoughCanvasArcRender = __decorate([ (0, inversify_1.injectable)(), __param(0, (0,
|
|
74
74
|
inversify_1.inject)(vrender_1.DefaultCanvasArcRender)), __metadata("design:paramtypes", [ Object ]) ], RoughCanvasArcRender),
|
|
75
|
-
exports.RoughCanvasArcRender = RoughCanvasArcRender;
|
|
75
|
+
exports.RoughCanvasArcRender = RoughCanvasArcRender;
|
|
76
|
+
//# sourceMappingURL=rough-arc.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/rough/rough-arc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAa/C,+CAAiH;AACjH,sDAA4B;AAC5B,qCAAiD;AAG1C,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAK/B,YAEkB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAJhD,UAAK,GAAY,OAAO,CAAC;QAMvB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,yBAAe,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,GAAS,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QACzG,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE;YACZ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tB,mBAAmB;YACnB,SAAS;YACT,MAAM;YACN,YAAY;YACZ,cAAc;YACd,cAAc;YACd,SAAS;YACT,UAAU;YACV,YAAY;YACZ,UAAU;YACV,cAAc;YACd,UAAU;YACV,OAAO;YACP,YAAY;YACZ,IAAI;YACJ,YAAY;YACZ,kBAAkB;YAClB,kBAAkB;YAClB,sBAAsB;YACtB,gBAAgB;YAChB,uBAAuB;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;IAED,SAAS,CACP,OAAiB,EACjB,GAAe,EACf,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAEZ,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;SACjG;IACH,CAAC;CACF,CAAA;AA7HY,oBAAoB;IADhC,IAAA,sBAAU,GAAE;IAOR,WAAA,IAAA,kBAAM,EAAC,gCAAsB,CAAC,CAAA;;GANtB,oBAAoB,CA6HhC;AA7HY,oDAAoB","file":"rough-arc.js","sourcesContent":["import { inject, injectable } from 'inversify';\nimport type {\n IGraphicRender,\n IRenderService,\n IArc,\n IGraphicAttribute,\n IContext2d,\n IGraphic,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IGraphicRenderDrawParams\n} from '@visactor/vrender';\nimport { ARC_NUMBER_TYPE, DefaultCanvasArcRender, getTheme, CustomPath2D, drawArcPath } from '@visactor/vrender';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\n\n@injectable()\nexport class RoughCanvasArcRender implements IGraphicRender {\n type: 'arc';\n numberType: number;\n style: 'rough' = 'rough';\n\n constructor(\n @inject(DefaultCanvasArcRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n this.type = 'arc';\n this.numberType = ARC_NUMBER_TYPE;\n }\n\n draw(arc: IArc, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n // 获取到原生canvas\n const canvas = context.canvas.nativeCanvas;\n const rc = rough.canvas(canvas);\n\n context.highPerformanceSave();\n\n // const arcAttribute = graphicService.themeService.getCurrentTheme().arcAttribute;\n const arcAttribute = getTheme(arc).arc;\n let { x = arcAttribute.x, y = arcAttribute.y } = arc.attribute;\n if (!arc.transMatrix.onlyTranslate()) {\n // 性能较差\n x = 0;\n y = 0;\n context.transformFromMatrix(arc.transMatrix, true);\n } else {\n const { dx = arcAttribute.dx, dy = arcAttribute.dy } = arc.attribute;\n x += dx;\n y += dy;\n // 当前context有rotate/scale,重置matrix\n context.setTransformForCurrent();\n }\n\n const customPath = new CustomPath2D();\n\n const {\n fill = arcAttribute.fill,\n stroke = arcAttribute.stroke,\n lineWidth = arcAttribute.lineWidth,\n outerRadius = arcAttribute.outerRadius,\n innerRadius = arcAttribute.innerRadius,\n maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset,\n roughness = defaultRouthThemeSpec.roughness,\n bowing = defaultRouthThemeSpec.bowing,\n curveFitting = defaultRouthThemeSpec.curveFitting,\n curveTightness = defaultRouthThemeSpec.curveTightness,\n curveStepCount = defaultRouthThemeSpec.curveStepCount,\n fillStyle = defaultRouthThemeSpec.fillStyle,\n fillWeight = defaultRouthThemeSpec.fillWeight,\n hachureAngle = defaultRouthThemeSpec.hachureAngle,\n hachureGap = defaultRouthThemeSpec.hachureGap,\n simplification = defaultRouthThemeSpec.simplification,\n dashOffset = defaultRouthThemeSpec.dashOffset,\n dashGap = defaultRouthThemeSpec.dashGap,\n zigzagOffset = defaultRouthThemeSpec.zigzagOffset,\n seed = defaultRouthThemeSpec.seed,\n fillLineDash = defaultRouthThemeSpec.fillLineDash,\n fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset,\n disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke,\n disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill,\n preserveVertices = defaultRouthThemeSpec.preserveVertices,\n fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits\n } = arc.attribute as any;\n\n drawArcPath(arc, customPath, x, y, outerRadius, innerRadius);\n\n rc.path(customPath.toString(), {\n fill: fill ? (fill as string) : undefined,\n stroke: stroke ? (stroke as string) : undefined,\n strokeWidth: lineWidth,\n maxRandomnessOffset,\n roughness,\n bowing,\n curveFitting,\n curveTightness,\n curveStepCount,\n fillStyle,\n fillWeight,\n hachureAngle,\n hachureGap,\n simplification,\n dashOffset,\n dashGap,\n zigzagOffset,\n seed,\n fillLineDash,\n fillLineDashOffset,\n disableMultiStroke,\n disableMultiStrokeFill,\n preserveVertices,\n fixedDecimalPlaceDigits\n });\n\n context.highPerformanceRestore();\n }\n\n drawShape(\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ): void {\n if (this.canvasRenderer.drawShape) {\n return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);\n }\n }\n}\n"]}
|
|
@@ -29,11 +29,11 @@ let RoughCanvasAreaRender = class extends vrender_1.DefaultCanvasAreaRender {
|
|
|
29
29
|
offsetY: offsetY
|
|
30
30
|
});
|
|
31
31
|
const {maxRandomnessOffset: maxRandomnessOffset = config_1.defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = config_1.defaultRouthThemeSpec.roughness, bowing: bowing = config_1.defaultRouthThemeSpec.bowing, curveFitting: curveFitting = config_1.defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = config_1.defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = config_1.defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = config_1.defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = config_1.defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = config_1.defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = config_1.defaultRouthThemeSpec.hachureGap, simplification: simplification = config_1.defaultRouthThemeSpec.simplification, dashOffset: dashOffset = config_1.defaultRouthThemeSpec.dashOffset, dashGap: dashGap = config_1.defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = config_1.defaultRouthThemeSpec.zigzagOffset, seed: seed = config_1.defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = config_1.defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = config_1.defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = config_1.defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = config_1.defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = config_1.defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = config_1.defaultRouthThemeSpec.fixedDecimalPlaceDigits} = attribute;
|
|
32
|
-
let {
|
|
32
|
+
let {fill: fillColor, stroke: strokeColor, lineWidth: lineWidth} = attribute;
|
|
33
33
|
return Array.isArray(defaultAttribute) ? defaultAttribute.forEach((item => {
|
|
34
|
-
fillColor = null != fillColor ? fillColor : item.
|
|
34
|
+
fillColor = null != fillColor ? fillColor : item.fill, strokeColor = null != strokeColor ? strokeColor : item.stroke,
|
|
35
35
|
lineWidth = null != lineWidth ? lineWidth : item.lineWidth;
|
|
36
|
-
})) : (fillColor = null != fillColor ? fillColor : defaultAttribute.
|
|
36
|
+
})) : (fillColor = null != fillColor ? fillColor : defaultAttribute.fill, strokeColor = null != strokeColor ? strokeColor : defaultAttribute.stroke,
|
|
37
37
|
lineWidth = null != lineWidth ? lineWidth : defaultAttribute.lineWidth), rc.path(customPath.toString(), {
|
|
38
38
|
fill: fill ? fillColor : void 0,
|
|
39
39
|
strokeWidth: lineWidth,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/rough/rough-area.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA+C;AAW/C,+CAA0G;AAC1G,sDAA4B;AAC5B,qCAAiD;AAG1C,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,iCAAuB;IAA3D;;QAGL,UAAK,GAAY,OAAO,CAAC;IAmI3B,CAAC;IAlHW,eAAe,CACvB,OAAmB,EACnB,KAAqB,EACrB,IAAa,EACb,WAAmB,EACnB,SAAyC,EACzC,gBAAoF,EACpF,SAAiB,EACjB,OAAe,EACf,OAAe,EACf,OAAe,EACf,IAAW,EACX,MAIY;QAEZ,IAAI,MAAM,EAAE;YACV,OAAO,KAAK,CAAC,eAAe,CAC1B,OAAO,EACP,KAAK,EACL,IAAI,EACJ,WAAW,EACX,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,OAAO,EACP,OAAO,EACP,OAAO,EACP,IAAI,EACJ,MAAM,CACP,CAAC;SACH;QACD,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;QAC3C,MAAM,EAAE,GAAG,iBAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEpC,MAAM,UAAU,GAAG,IAAI,sBAAY,EAAE,CAAC;QAEtC,IAAA,0BAAgB,EAAC,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE;YAC7C,OAAO;YACP,OAAO;SACR,CAAC,CAAC;QAEH,MAAM,EACJ,mBAAmB,GAAG,8BAAqB,CAAC,mBAAmB,EAC/D,SAAS,GAAG,8BAAqB,CA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YAAY;YACZ,UAAU;YACV,cAAc;YACd,UAAU;YACV,OAAO;YACP,YAAY;YACZ,IAAI;YACJ,YAAY;YACZ,kBAAkB;YAClB,kBAAkB;YAClB,sBAAsB;YACtB,gBAAgB;YAChB,uBAAuB;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,sBAAsB,EAAE,CAAC;QAEjC,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAtIY,qBAAqB;IADjC,IAAA,sBAAU,GAAE;GACA,qBAAqB,CAsIjC;AAtIY,sDAAqB","file":"rough-area.js","sourcesContent":["import { inject, injectable } from 'inversify';\nimport type {\n IGraphicRender,\n IAreaCacheItem,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IGraphicAttribute,\n IArea,\n IAreaGraphicAttribute\n} from '@visactor/vrender';\nimport { drawAreaSegments, DefaultCanvasAreaRender, CustomPath2D, drawSegments } from '@visactor/vrender';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\n\n@injectable()\nexport class RoughCanvasAreaRender extends DefaultCanvasAreaRender implements IGraphicRender {\n declare type: 'area';\n declare numberType: number;\n style: 'rough' = 'rough';\n\n /**\n * 绘制segment\n * @param context\n * @param cache\n * @param fill\n * @param stroke\n * @param attribute\n * @param defaultAttribute\n * @param clipRange\n * @param offsetX\n * @param offsetY\n * @param fillCb\n * @param strokeCb\n * @returns 返回true代表跳过后续绘制\n */\n protected drawSegmentItem(\n context: IContext2d,\n cache: IAreaCacheItem,\n fill: boolean,\n fillOpacity: number,\n attribute: Partial<IAreaGraphicAttribute>,\n defaultAttribute: Required<IAreaGraphicAttribute> | Partial<IAreaGraphicAttribute>[],\n clipRange: number,\n offsetX: number,\n offsetY: number,\n offsetZ: number,\n area: IArea,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute | IThemeAttribute[]\n ) => boolean\n ): boolean {\n if (fillCb) {\n return super.drawSegmentItem(\n context,\n cache,\n fill,\n fillOpacity,\n attribute,\n defaultAttribute,\n clipRange,\n offsetX,\n offsetY,\n offsetZ,\n area,\n fillCb\n );\n }\n context.highPerformanceSave();\n // 获取到原生canvas\n const canvas = context.canvas.nativeCanvas;\n const rc = rough.canvas(canvas, {});\n\n const customPath = new CustomPath2D();\n\n drawAreaSegments(customPath, cache, clipRange, {\n offsetX,\n offsetY\n });\n\n const {\n maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset,\n roughness = defaultRouthThemeSpec.roughness,\n bowing = defaultRouthThemeSpec.bowing,\n curveFitting = defaultRouthThemeSpec.curveFitting,\n curveTightness = defaultRouthThemeSpec.curveTightness,\n curveStepCount = defaultRouthThemeSpec.curveStepCount,\n fillStyle = defaultRouthThemeSpec.fillStyle,\n fillWeight = defaultRouthThemeSpec.fillWeight,\n hachureAngle = defaultRouthThemeSpec.hachureAngle,\n hachureGap = defaultRouthThemeSpec.hachureGap,\n simplification = defaultRouthThemeSpec.simplification,\n dashOffset = defaultRouthThemeSpec.dashOffset,\n dashGap = defaultRouthThemeSpec.dashGap,\n zigzagOffset = defaultRouthThemeSpec.zigzagOffset,\n seed = defaultRouthThemeSpec.seed,\n fillLineDash = defaultRouthThemeSpec.fillLineDash,\n fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset,\n disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke,\n disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill,\n preserveVertices = defaultRouthThemeSpec.preserveVertices,\n fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits\n } = attribute as any;\n\n let { fill: fillColor, stroke: strokeColor, lineWidth } = attribute;\n\n if (Array.isArray(defaultAttribute)) {\n defaultAttribute.forEach(item => {\n fillColor = fillColor ?? item.fill;\n strokeColor = strokeColor ?? item.stroke;\n lineWidth = lineWidth ?? item.lineWidth;\n });\n } else {\n fillColor = fillColor ?? defaultAttribute.fill;\n strokeColor = strokeColor ?? defaultAttribute.stroke;\n lineWidth = lineWidth ?? defaultAttribute.lineWidth;\n }\n\n rc.path(customPath.toString(), {\n fill: fill ? (fillColor as string) : undefined,\n strokeWidth: lineWidth,\n maxRandomnessOffset,\n roughness,\n bowing,\n curveFitting,\n curveTightness,\n curveStepCount,\n fillStyle,\n fillWeight,\n hachureAngle,\n hachureGap,\n simplification,\n dashOffset,\n dashGap,\n zigzagOffset,\n seed,\n fillLineDash,\n fillLineDashOffset,\n disableMultiStroke,\n disableMultiStrokeFill,\n preserveVertices,\n fixedDecimalPlaceDigits\n });\n\n context.highPerformanceRestore();\n\n return false;\n }\n}\n"]}
|
|
@@ -35,10 +35,10 @@ let RoughCanvasCircleRender = class {
|
|
|
35
35
|
let {x: x = circleAttribute.x, y: y = circleAttribute.y} = circle.attribute;
|
|
36
36
|
circle.transMatrix.onlyTranslate() ? context.onlyTranslate() || context.clearMatrix() : (x = 0,
|
|
37
37
|
y = 0, context.transformFromMatrix(circle.transMatrix, !0));
|
|
38
|
-
const {
|
|
38
|
+
const {radius: radius = circleAttribute.radius, fill: fill = circleAttribute.fill, stroke: stroke = circleAttribute.stroke, lineWidth: lineWidth = circleAttribute.lineWidth} = circle.attribute;
|
|
39
39
|
rc.circle(x, y, radius, {
|
|
40
|
-
fill: fill
|
|
41
|
-
stroke: stroke
|
|
40
|
+
fill: fill || void 0,
|
|
41
|
+
stroke: stroke || void 0,
|
|
42
42
|
strokeWidth: lineWidth,
|
|
43
43
|
fillStyle: "zigzag",
|
|
44
44
|
roughness: .5
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/rough/rough-circle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAa/C,+CAA4F;AAC5F,sDAA4B;AAGrB,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAKlC,YAEkB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAJhD,UAAK,GAAY,OAAO,CAAC;QA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C,WAAW,EAAE,SAAS;YACtB,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,GAAG;SACf,CAAC,CAAC;IACL,CAAC;IACD,SAAS,CACP,OAAiB,EACjB,GAAe,EACf,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAEZ,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;SACjG;IACH,CAAC;CACF,CAAA;AAxEY,uBAAuB;IADnC,IAAA,sBAAU,GAAE;IAOR,WAAA,IAAA,kBAAM,EAAC,mCAAyB,CAAC,CAAA;;GANzB,uBAAuB,CAwEnC;AAxEY,0DAAuB","file":"rough-circle.js","sourcesContent":["import { inject, injectable } from 'inversify';\nimport type {\n IGraphicRender,\n IRenderService,\n IGraphic,\n ICircle,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IGraphicAttribute,\n IDrawContext,\n IGraphicRenderDrawParams\n} from '@visactor/vrender';\nimport { CIRCLE_NUMBER_TYPE, DefaultCanvasCircleRender, getTheme } from '@visactor/vrender';\nimport rough from 'roughjs';\n\n@injectable()\nexport class RoughCanvasCircleRender implements IGraphicRender {\n declare type: 'circle';\n declare numberType: number;\n style: 'rough' = 'rough';\n\n constructor(\n @inject(DefaultCanvasCircleRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n this.type = 'circle';\n this.numberType = CIRCLE_NUMBER_TYPE;\n }\n\n draw(circle: ICircle, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n // 获取到原生canvas\n const canvas = context.canvas.nativeCanvas;\n const rc = rough.canvas(canvas, {});\n\n // const circleAttribute = graphicService.themeService.getCurrentTheme().circleAttribute;\n const circleAttribute = getTheme(circle).circle;\n let { x = circleAttribute.x, y = circleAttribute.y } = circle.attribute;\n if (!circle.transMatrix.onlyTranslate()) {\n // 性能较差\n x = 0;\n y = 0;\n context.transformFromMatrix(circle.transMatrix, true);\n } else if (!context.onlyTranslate()) {\n // 当前context有rotate/scale,重置matrix\n context.clearMatrix();\n }\n\n const {\n radius = circleAttribute.radius,\n fill = circleAttribute.fill,\n stroke = circleAttribute.stroke,\n lineWidth = circleAttribute.lineWidth\n } = circle.attribute;\n rc.circle(x, y, radius, {\n fill: fill ? (fill as string) : undefined,\n stroke: stroke ? (stroke as string) : undefined,\n strokeWidth: lineWidth,\n fillStyle: 'zigzag',\n roughness: 0.5\n });\n }\n drawShape(\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ): void {\n if (this.canvasRenderer.drawShape) {\n return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);\n }\n }\n}\n"]}
|
|
@@ -29,11 +29,11 @@ let RoughCanvasLineRender = class extends vrender_1.DefaultCanvasLineRender {
|
|
|
29
29
|
offsetY: offsetY
|
|
30
30
|
});
|
|
31
31
|
const {maxRandomnessOffset: maxRandomnessOffset = config_1.defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = config_1.defaultRouthThemeSpec.roughness, bowing: bowing = config_1.defaultRouthThemeSpec.bowing, curveFitting: curveFitting = config_1.defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = config_1.defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = config_1.defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = config_1.defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = config_1.defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = config_1.defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = config_1.defaultRouthThemeSpec.hachureGap, simplification: simplification = config_1.defaultRouthThemeSpec.simplification, dashOffset: dashOffset = config_1.defaultRouthThemeSpec.dashOffset, dashGap: dashGap = config_1.defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = config_1.defaultRouthThemeSpec.zigzagOffset, seed: seed = config_1.defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = config_1.defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = config_1.defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = config_1.defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = config_1.defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = config_1.defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = config_1.defaultRouthThemeSpec.fixedDecimalPlaceDigits} = attribute;
|
|
32
|
-
let {
|
|
32
|
+
let {fill: fillColor, stroke: strokeColor, lineWidth: lineWidth} = attribute;
|
|
33
33
|
return Array.isArray(defaultAttribute) ? defaultAttribute.forEach((item => {
|
|
34
|
-
fillColor = null != fillColor ? fillColor : item.
|
|
34
|
+
fillColor = null != fillColor ? fillColor : item.fill, strokeColor = null != strokeColor ? strokeColor : item.stroke,
|
|
35
35
|
lineWidth = null != lineWidth ? lineWidth : item.lineWidth;
|
|
36
|
-
})) : (fillColor = null != fillColor ? fillColor : defaultAttribute.
|
|
36
|
+
})) : (fillColor = null != fillColor ? fillColor : defaultAttribute.fill, strokeColor = null != strokeColor ? strokeColor : defaultAttribute.stroke,
|
|
37
37
|
lineWidth = null != lineWidth ? lineWidth : defaultAttribute.lineWidth), rc.path(customPath.toString(), {
|
|
38
38
|
fill: fill ? fillColor : void 0,
|
|
39
39
|
stroke: stroke ? strokeColor : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/rough/rough-line.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA+C;AAY/C,+
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/rough/rough-line.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA+C;AAY/C,+CAO2B;AAC3B,sDAA4B;AAC5B,qCAAiD;AAG1C,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,iCAAuB;IAA3D;;QAGL,UAAK,GAAY,OAAO,CAAC;IA6I3B,CAAC;IA5HW,eAAe,CACvB,OAAmB,EACnB,KAAiB,EACjB,IAAa,EACb,MAAe,EACf,WAAmB,EACnB,aAAqB,EACrB,SAAyC,EACzC,gBAAoF,EACpF,SAAiB,EACjB,oBAA+C,EAC/C,OAAe,EACf,OAAe,EACf,IAAW,EACX,MAIY,EACZ,QAIY;QAEZ,IAAI,MAAM,IAAI,QAAQ,EAAE;YACtB,OAAO,KAAK,CAAC,eAAe,CAC1B,OAAO,EACP,KAAK,EACL,IAAI,EACJ,MAAM,EACN,WAAW,EACX,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,oBAAoB,EACpB,OAAO,EACP,OAAO,EACP,IAAI,EACJ,MAAM,EACN,QAAQ,CACT,CAAC;SACH;QACD,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAE9B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;QAC3C,MAAM,EAAE,GAAG,iBAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEpC,MAAM,UAAU,GAAG,IAAI,sBAAY,EAAE,CAAC;QAEtC,IAAA,sBAAY,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,EAAE,SAAS,E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C,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,IAAI,CAAC,MAAM,CAAC;gBACzC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,CAAC,SAAS,CAAC;YAC1C,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,gBAAgB,CAAC,IAAI,CAAC;YAC/C,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,gBAAgB,CAAC,MAAM,CAAC;YACrD,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,gBAAgB,CAAC,SAAS,CAAC;SACrD;QAED,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE;YAC7B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAE,SAAoB,CAAC,CAAC,CAAC,SAAS;YAC9C,MAAM,EAAE,MAAM,CAAC,CAAC,CAAE,WAAsB,CAAC,CAAC,CAAC,SAAS;YACpD,WAAW,EAAE,SAAS;YACtB,mBAAmB;YACnB,SAAS;YACT,MAAM;YACN,YAAY;YACZ,cAAc;YACd,cAAc;YACd,SAAS;YACT,UAAU;YACV,YAAY;YACZ,UAAU;YACV,cAAc;YACd,UAAU;YACV,OAAO;YACP,YAAY;YACZ,IAAI;YACJ,YAAY;YACZ,kBAAkB;YAClB,kBAAkB;YAClB,sBAAsB;YACtB,gBAAgB;YAChB,uBAAuB;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,sBAAsB,EAAE,CAAC;QAEjC,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AAhJY,qBAAqB;IADjC,IAAA,sBAAU,GAAE;GACA,qBAAqB,CAgJjC;AAhJY,sDAAqB","file":"rough-line.js","sourcesContent":["import { inject, injectable } from 'inversify';\nimport type {\n IGraphicRender,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IGraphicAttribute,\n ISegPath2D,\n ILine,\n ILineGraphicAttribute,\n IClipRangeByDimensionType\n} from '@visactor/vrender';\nimport {\n IRenderService,\n IGraphic,\n DefaultCanvasLineRender,\n getTheme,\n CustomPath2D,\n drawSegments\n} from '@visactor/vrender';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\n\n@injectable()\nexport class RoughCanvasLineRender extends DefaultCanvasLineRender implements IGraphicRender {\n declare type: 'line';\n declare numberType: number;\n style: 'rough' = 'rough';\n\n /**\n * 绘制segment\n * @param context\n * @param cache\n * @param fill\n * @param stroke\n * @param attribute\n * @param defaultAttribute\n * @param clipRange\n * @param offsetX\n * @param offsetY\n * @param fillCb\n * @param strokeCb\n * @returns 返回true代表跳过后续绘制\n */\n protected drawSegmentItem(\n context: IContext2d,\n cache: ISegPath2D,\n fill: boolean,\n stroke: boolean,\n fillOpacity: number,\n strokeOpacity: number,\n attribute: Partial<ILineGraphicAttribute>,\n defaultAttribute: Required<ILineGraphicAttribute> | Partial<ILineGraphicAttribute>[],\n clipRange: number,\n clipRangeByDimension: IClipRangeByDimensionType,\n offsetX: number,\n offsetY: number,\n line: ILine,\n fillCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute | IThemeAttribute[]\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute | IThemeAttribute[]\n ) => boolean\n ): boolean {\n if (fillCb || strokeCb) {\n return super.drawSegmentItem(\n context,\n cache,\n fill,\n stroke,\n fillOpacity,\n strokeOpacity,\n attribute,\n defaultAttribute,\n clipRange,\n clipRangeByDimension,\n offsetX,\n offsetY,\n line,\n fillCb,\n strokeCb\n );\n }\n context.highPerformanceSave();\n // 获取到原生canvas\n const canvas = context.canvas.nativeCanvas;\n const rc = rough.canvas(canvas, {});\n\n const customPath = new CustomPath2D();\n\n drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {\n offsetX,\n offsetY\n });\n const {\n maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset,\n roughness = defaultRouthThemeSpec.roughness,\n bowing = defaultRouthThemeSpec.bowing,\n curveFitting = defaultRouthThemeSpec.curveFitting,\n curveTightness = defaultRouthThemeSpec.curveTightness,\n curveStepCount = defaultRouthThemeSpec.curveStepCount,\n fillStyle = defaultRouthThemeSpec.fillStyle,\n fillWeight = defaultRouthThemeSpec.fillWeight,\n hachureAngle = defaultRouthThemeSpec.hachureAngle,\n hachureGap = defaultRouthThemeSpec.hachureGap,\n simplification = defaultRouthThemeSpec.simplification,\n dashOffset = defaultRouthThemeSpec.dashOffset,\n dashGap = defaultRouthThemeSpec.dashGap,\n zigzagOffset = defaultRouthThemeSpec.zigzagOffset,\n seed = defaultRouthThemeSpec.seed,\n fillLineDash = defaultRouthThemeSpec.fillLineDash,\n fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset,\n disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke,\n disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill,\n preserveVertices = defaultRouthThemeSpec.preserveVertices,\n fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits\n } = attribute as any;\n\n let { fill: fillColor, stroke: strokeColor, lineWidth } = attribute;\n\n if (Array.isArray(defaultAttribute)) {\n defaultAttribute.forEach(item => {\n fillColor = fillColor ?? item.fill;\n strokeColor = strokeColor ?? item.stroke;\n lineWidth = lineWidth ?? item.lineWidth;\n });\n } else {\n fillColor = fillColor ?? defaultAttribute.fill;\n strokeColor = strokeColor ?? defaultAttribute.stroke;\n lineWidth = lineWidth ?? defaultAttribute.lineWidth;\n }\n\n rc.path(customPath.toString(), {\n fill: fill ? (fillColor as string) : undefined,\n stroke: stroke ? (strokeColor as string) : undefined,\n strokeWidth: lineWidth,\n maxRandomnessOffset,\n roughness,\n bowing,\n curveFitting,\n curveTightness,\n curveStepCount,\n fillStyle,\n fillWeight,\n hachureAngle,\n hachureGap,\n simplification,\n dashOffset,\n dashGap,\n zigzagOffset,\n seed,\n fillLineDash,\n fillLineDashOffset,\n disableMultiStroke,\n disableMultiStrokeFill,\n preserveVertices,\n fixedDecimalPlaceDigits\n });\n\n context.highPerformanceRestore();\n\n return false;\n }\n}\n"]}
|
|
@@ -34,10 +34,10 @@ let RoughCanvasPathRender = class {
|
|
|
34
34
|
context.highPerformanceSave();
|
|
35
35
|
const pathAttribute = (0, vrender_1.getTheme)(path).path;
|
|
36
36
|
context.transformFromMatrix(path.transMatrix, !0);
|
|
37
|
-
const {fill: fill =
|
|
37
|
+
const {fill: fill = pathAttribute.fill, stroke: stroke = pathAttribute.stroke, lineWidth: lineWidth = pathAttribute.lineWidth, path: p = pathAttribute.path, maxRandomnessOffset: maxRandomnessOffset = config_1.defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = config_1.defaultRouthThemeSpec.roughness, bowing: bowing = config_1.defaultRouthThemeSpec.bowing, curveFitting: curveFitting = config_1.defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = config_1.defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = config_1.defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = config_1.defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = config_1.defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = config_1.defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = config_1.defaultRouthThemeSpec.hachureGap, simplification: simplification = config_1.defaultRouthThemeSpec.simplification, dashOffset: dashOffset = config_1.defaultRouthThemeSpec.dashOffset, dashGap: dashGap = config_1.defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = config_1.defaultRouthThemeSpec.zigzagOffset, seed: seed = config_1.defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = config_1.defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = config_1.defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = config_1.defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = config_1.defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = config_1.defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = config_1.defaultRouthThemeSpec.fixedDecimalPlaceDigits} = path.attribute;
|
|
38
38
|
"string" == typeof p && rc.path(p, {
|
|
39
|
-
fill: fill
|
|
40
|
-
stroke: stroke
|
|
39
|
+
fill: fill || void 0,
|
|
40
|
+
stroke: stroke || void 0,
|
|
41
41
|
strokeWidth: lineWidth,
|
|
42
42
|
maxRandomnessOffset: maxRandomnessOffset,
|
|
43
43
|
roughness: roughness,
|
|
@@ -69,5 +69,4 @@ let RoughCanvasPathRender = class {
|
|
|
69
69
|
|
|
70
70
|
RoughCanvasPathRender = __decorate([ (0, inversify_1.injectable)(), __param(0, (0,
|
|
71
71
|
inversify_1.inject)(vrender_1.DefaultCanvasPathRender)), __metadata("design:paramtypes", [ Object ]) ], RoughCanvasPathRender),
|
|
72
|
-
exports.RoughCanvasPathRender = RoughCanvasPathRender;
|
|
73
|
-
//# sourceMappingURL=rough-path.js.map
|
|
72
|
+
exports.RoughCanvasPathRender = RoughCanvasPathRender;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/rough/rough-path.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAa/C,+CAAwF;AACxF,sDAA4B;AAC5B,qCAAiD;AAG1C,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAKhC,YAEkB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAJhD,UAAK,GAAY,OAAO,CAAC;QAMvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,0BAAgB,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,IAAW,EAAE,aAA6B,EAAE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E;YACzB,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE;gBACT,IAAI,EAAE,IAAI,CAAC,CAAC,CAAE,IAAe,CAAC,CAAC,CAAC,SAAS;gBACzC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAE,MAAiB,CAAC,CAAC,CAAC,SAAS;gBAC/C,WAAW,EAAE,SAAS;gBACtB,mBAAmB;gBACnB,SAAS;gBACT,MAAM;gBACN,YAAY;gBACZ,cAAc;gBACd,cAAc;gBACd,SAAS;gBACT,UAAU;gBACV,YAAY;gBACZ,UAAU;gBACV,cAAc;gBACd,UAAU;gBACV,OAAO;gBACP,YAAY;gBACZ,IAAI;gBACJ,YAAY;gBACZ,kBAAkB;gBAClB,kBAAkB;gBAClB,sBAAsB;gBACtB,gBAAgB;gBAChB,uBAAuB;aACxB,CAAC,CAAC;SACJ;QAED,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;IACD,SAAS,CACP,OAAiB,EACjB,GAAe,EACf,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAEZ,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;SACjG;IACH,CAAC;CACF,CAAA;AA5GY,qBAAqB;IADjC,IAAA,sBAAU,GAAE;IAOR,WAAA,IAAA,kBAAM,EAAC,iCAAuB,CAAC,CAAA;;GANvB,qBAAqB,CA4GjC;AA5GY,sDAAqB","file":"rough-path.js","sourcesContent":["import { inject, injectable } from 'inversify';\nimport type {\n IGraphicRender,\n IRenderService,\n IGraphic,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IGraphicAttribute,\n IPath,\n IDrawContext,\n IGraphicRenderDrawParams\n} from '@visactor/vrender';\nimport { PATH_NUMBER_TYPE, DefaultCanvasPathRender, getTheme } from '@visactor/vrender';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\n\n@injectable()\nexport class RoughCanvasPathRender implements IGraphicRender {\n type: 'path';\n numberType: number;\n style: 'rough' = 'rough';\n\n constructor(\n @inject(DefaultCanvasPathRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n this.type = 'path';\n this.numberType = PATH_NUMBER_TYPE;\n }\n\n draw(path: IPath, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n // 获取到原生canvas\n const canvas = context.canvas.nativeCanvas;\n const rc = rough.canvas(canvas, {});\n\n context.highPerformanceSave();\n\n const pathAttribute = getTheme(path).path;\n context.transformFromMatrix(path.transMatrix, true);\n\n const {\n fill = pathAttribute.fill,\n stroke = pathAttribute.stroke,\n lineWidth = pathAttribute.lineWidth,\n path: p = pathAttribute.path,\n maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset,\n roughness = defaultRouthThemeSpec.roughness,\n bowing = defaultRouthThemeSpec.bowing,\n curveFitting = defaultRouthThemeSpec.curveFitting,\n curveTightness = defaultRouthThemeSpec.curveTightness,\n curveStepCount = defaultRouthThemeSpec.curveStepCount,\n fillStyle = defaultRouthThemeSpec.fillStyle,\n fillWeight = defaultRouthThemeSpec.fillWeight,\n hachureAngle = defaultRouthThemeSpec.hachureAngle,\n hachureGap = defaultRouthThemeSpec.hachureGap,\n simplification = defaultRouthThemeSpec.simplification,\n dashOffset = defaultRouthThemeSpec.dashOffset,\n dashGap = defaultRouthThemeSpec.dashGap,\n zigzagOffset = defaultRouthThemeSpec.zigzagOffset,\n seed = defaultRouthThemeSpec.seed,\n fillLineDash = defaultRouthThemeSpec.fillLineDash,\n fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset,\n disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke,\n disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill,\n preserveVertices = defaultRouthThemeSpec.preserveVertices,\n fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits\n } = path.attribute as any;\n if (typeof p === 'string') {\n rc.path(p, {\n fill: fill ? (fill as string) : undefined,\n stroke: stroke ? (stroke as string) : undefined,\n strokeWidth: lineWidth,\n maxRandomnessOffset,\n roughness,\n bowing,\n curveFitting,\n curveTightness,\n curveStepCount,\n fillStyle,\n fillWeight,\n hachureAngle,\n hachureGap,\n simplification,\n dashOffset,\n dashGap,\n zigzagOffset,\n seed,\n fillLineDash,\n fillLineDashOffset,\n disableMultiStroke,\n disableMultiStrokeFill,\n preserveVertices,\n fixedDecimalPlaceDigits\n });\n }\n\n context.highPerformanceRestore();\n }\n drawShape(\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ): void {\n if (this.canvasRenderer.drawShape) {\n return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);\n }\n }\n}\n"]}
|
|
@@ -38,7 +38,7 @@ let RoughCanvasRectRender = class {
|
|
|
38
38
|
const {dx: dx = rectAttribute.dx, dy: dy = rectAttribute.dy} = rect.attribute;
|
|
39
39
|
x += dx, y += dy, context.setTransformForCurrent();
|
|
40
40
|
} else x = 0, y = 0, context.transformFromMatrix(rect.transMatrix, !0);
|
|
41
|
-
const {fill: fill =
|
|
41
|
+
const {fill: fill = rectAttribute.fill, stroke: stroke = rectAttribute.stroke, fillColor: fillColor = rectAttribute.fill, strokeColor: strokeColor = rectAttribute.stroke, width: width = rectAttribute.width, height: height = rectAttribute.height, lineWidth: lineWidth = rectAttribute.lineWidth, maxRandomnessOffset: maxRandomnessOffset = config_1.defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = config_1.defaultRouthThemeSpec.roughness, bowing: bowing = config_1.defaultRouthThemeSpec.bowing, curveFitting: curveFitting = config_1.defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = config_1.defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = config_1.defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = config_1.defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = config_1.defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = config_1.defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = config_1.defaultRouthThemeSpec.hachureGap, simplification: simplification = config_1.defaultRouthThemeSpec.simplification, dashOffset: dashOffset = config_1.defaultRouthThemeSpec.dashOffset, dashGap: dashGap = config_1.defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = config_1.defaultRouthThemeSpec.zigzagOffset, seed: seed = config_1.defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = config_1.defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = config_1.defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = config_1.defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = config_1.defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = config_1.defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = config_1.defaultRouthThemeSpec.fixedDecimalPlaceDigits} = rect.attribute;
|
|
42
42
|
rc.rectangle(x, y, width, height, {
|
|
43
43
|
fill: fill ? fillColor : void 0,
|
|
44
44
|
stroke: stroke ? strokeColor : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/rough/rough-rect.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yCAA+C;A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,CAAC,uBAAuB,EACxE,GAAG,IAAI,CAAC,SAAgB,CAAC;QAC1B,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE;YAChC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAE,SAAoB,CAAC,CAAC,CAAC,SAAS;YAC9C,MAAM,EAAE,MAAM,CAAC,CAAC,CAAE,WAAsB,CAAC,CAAC,CAAC,SAAS;YACpD,WAAW,EAAE,SAAS;YACtB,mBAAmB;YACnB,SAAS;YACT,MAAM;YACN,YAAY;YACZ,cAAc;YACd,cAAc;YACd,SAAS;YACT,UAAU;YACV,YAAY;YACZ,UAAU;YACV,cAAc;YACd,UAAU;YACV,OAAO;YACP,YAAY;YACZ,IAAI;YACJ,YAAY;YACZ,kBAAkB;YAClB,kBAAkB;YAClB,sBAAsB;YACtB,gBAAgB;YAChB,uBAAuB;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;IAED,SAAS,CACP,OAAiB,EACjB,GAAe,EACf,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAEZ,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;SACjG;IACH,CAAC;CACF,CAAA;AA1HY,qBAAqB;IADjC,IAAA,sBAAU,GAAE;IAOR,WAAA,IAAA,kBAAM,EAAC,iCAAuB,CAAC,CAAA;;GANvB,qBAAqB,CA0HjC;AA1HY,sDAAqB","file":"rough-rect.js","sourcesContent":["import { inject, injectable } from 'inversify';\nimport type {\n IGraphicRender,\n IRenderService,\n IRect,\n IGraphicAttribute,\n IContext2d,\n IGraphic,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IGraphicRenderDrawParams\n} from '@visactor/vrender';\nimport { RECT_NUMBER_TYPE, DefaultCanvasRectRender, getTheme } from '@visactor/vrender';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\n\n@injectable()\nexport class RoughCanvasRectRender implements IGraphicRender {\n type: 'rect';\n numberType: number;\n style: 'rough' = 'rough';\n\n constructor(\n @inject(DefaultCanvasRectRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n this.type = 'rect';\n this.numberType = RECT_NUMBER_TYPE;\n }\n\n draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n // 获取到原生canvas\n const canvas = context.canvas.nativeCanvas;\n const rc = rough.canvas(canvas);\n\n context.highPerformanceSave();\n\n // const rectAttribute = graphicService.themeService.getCurrentTheme().rectAttribute;\n const rectAttribute = getTheme(rect).rect;\n let { x = rectAttribute.x, y = rectAttribute.y } = rect.attribute;\n if (!rect.transMatrix.onlyTranslate()) {\n // 性能较差\n x = 0;\n y = 0;\n context.transformFromMatrix(rect.transMatrix, true);\n } else {\n const { dx = rectAttribute.dx, dy = rectAttribute.dy } = rect.attribute;\n x += dx;\n y += dy;\n // 当前context有rotate/scale,重置matrix\n context.setTransformForCurrent();\n }\n\n const {\n fill = rectAttribute.fill,\n stroke = rectAttribute.stroke,\n fillColor = rectAttribute.fill,\n strokeColor = rectAttribute.stroke,\n width = rectAttribute.width,\n height = rectAttribute.height,\n lineWidth = rectAttribute.lineWidth,\n maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset,\n roughness = defaultRouthThemeSpec.roughness,\n bowing = defaultRouthThemeSpec.bowing,\n curveFitting = defaultRouthThemeSpec.curveFitting,\n curveTightness = defaultRouthThemeSpec.curveTightness,\n curveStepCount = defaultRouthThemeSpec.curveStepCount,\n fillStyle = defaultRouthThemeSpec.fillStyle,\n fillWeight = defaultRouthThemeSpec.fillWeight,\n hachureAngle = defaultRouthThemeSpec.hachureAngle,\n hachureGap = defaultRouthThemeSpec.hachureGap,\n simplification = defaultRouthThemeSpec.simplification,\n dashOffset = defaultRouthThemeSpec.dashOffset,\n dashGap = defaultRouthThemeSpec.dashGap,\n zigzagOffset = defaultRouthThemeSpec.zigzagOffset,\n seed = defaultRouthThemeSpec.seed,\n fillLineDash = defaultRouthThemeSpec.fillLineDash,\n fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset,\n disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke,\n disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill,\n preserveVertices = defaultRouthThemeSpec.preserveVertices,\n fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits\n } = rect.attribute as any;\n rc.rectangle(x, y, width, height, {\n fill: fill ? (fillColor as string) : undefined,\n stroke: stroke ? (strokeColor as string) : undefined,\n strokeWidth: lineWidth,\n maxRandomnessOffset,\n roughness,\n bowing,\n curveFitting,\n curveTightness,\n curveStepCount,\n fillStyle,\n fillWeight,\n hachureAngle,\n hachureGap,\n simplification,\n dashOffset,\n dashGap,\n zigzagOffset,\n seed,\n fillLineDash,\n fillLineDashOffset,\n disableMultiStroke,\n disableMultiStrokeFill,\n preserveVertices,\n fixedDecimalPlaceDigits\n });\n\n context.highPerformanceRestore();\n }\n\n drawShape(\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ): void {\n if (this.canvasRenderer.drawShape) {\n return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);\n }\n }\n}\n"]}
|
|
@@ -40,7 +40,7 @@ let RoughCanvasSymbolRender = class {
|
|
|
40
40
|
} else x = 0, y = 0, context.transformFromMatrix(symbol.transMatrix, !0);
|
|
41
41
|
const parsedPath = symbol.getParsedPath();
|
|
42
42
|
if (!parsedPath) return;
|
|
43
|
-
const {fill: fill =
|
|
43
|
+
const {fill: fill = symbolAttribute.fill, stroke: stroke = symbolAttribute.stroke, fillColor: fillColor = symbolAttribute.fill, strokeColor: strokeColor = symbolAttribute.stroke, size: size = symbolAttribute.size, lineWidth: lineWidth = symbolAttribute.lineWidth, maxRandomnessOffset: maxRandomnessOffset = config_1.defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = config_1.defaultRouthThemeSpec.roughness, bowing: bowing = config_1.defaultRouthThemeSpec.bowing, curveFitting: curveFitting = config_1.defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = config_1.defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = config_1.defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = config_1.defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = config_1.defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = config_1.defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = config_1.defaultRouthThemeSpec.hachureGap, simplification: simplification = config_1.defaultRouthThemeSpec.simplification, dashOffset: dashOffset = config_1.defaultRouthThemeSpec.dashOffset, dashGap: dashGap = config_1.defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = config_1.defaultRouthThemeSpec.zigzagOffset, seed: seed = config_1.defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = config_1.defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = config_1.defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = config_1.defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = config_1.defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = config_1.defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = config_1.defaultRouthThemeSpec.fixedDecimalPlaceDigits} = symbol.attribute, customPath = new vrender_1.CustomPath2D;
|
|
44
44
|
parsedPath.draw(customPath, size, x, y) && customPath.closePath(), rc.path(customPath.toString(), {
|
|
45
45
|
fill: fill ? fillColor : void 0,
|
|
46
46
|
stroke: stroke ? strokeColor : void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/rough/rough-symbol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yCAA+C;AAa/C,+CAA0G;AAC1G,sDAA4B;AAC5B,qCAAiD;AAG1C,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAKlC,YAEkB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAJhD,UAAK,GAAY,OAAO,CAAC;QAMvB,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,4BAAkB,CAAC;IACvC,CAAC;IAED,IAAI,CAAC,MAAe,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC/G,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;QAC3C,MAAM,EAAE,GAAG,iBAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEhC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAG9B,MAAM,eAAe,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QAChD,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,EAAE,E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AClB,sBAAsB;YACtB,gBAAgB;YAChB,uBAAuB;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,sBAAsB,EAAE,CAAC;IACnC,CAAC;IAED,SAAS,CACP,OAAiB,EACjB,GAAe,EACf,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY;QAEZ,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YACjC,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;SACjG;IACH,CAAC;CACF,CAAA;AArIY,uBAAuB;IADnC,IAAA,sBAAU,GAAE;IAOR,WAAA,IAAA,kBAAM,EAAC,mCAAyB,CAAC,CAAA;;GANzB,uBAAuB,CAqInC;AArIY,0DAAuB","file":"rough-symbol.js","sourcesContent":["import { inject, injectable } from 'inversify';\nimport type {\n IGraphicRender,\n IRenderService,\n ISymbol,\n IGraphicAttribute,\n IContext2d,\n IGraphic,\n IMarkAttribute,\n IThemeAttribute,\n IDrawContext,\n IGraphicRenderDrawParams\n} from '@visactor/vrender';\nimport { SYMBOL_NUMBER_TYPE, DefaultCanvasSymbolRender, getTheme, CustomPath2D } from '@visactor/vrender';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\n\n@injectable()\nexport class RoughCanvasSymbolRender implements IGraphicRender {\n type: 'symbol';\n numberType: number;\n style: 'rough' = 'rough';\n\n constructor(\n @inject(DefaultCanvasSymbolRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n this.type = 'symbol';\n this.numberType = SYMBOL_NUMBER_TYPE;\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n // 获取到原生canvas\n const canvas = context.canvas.nativeCanvas;\n const rc = rough.canvas(canvas);\n\n context.highPerformanceSave();\n\n // const rectAttribute = graphicService.themeService.getCurrentTheme().rectAttribute;\n const symbolAttribute = getTheme(symbol).symbol;\n let { x = symbolAttribute.x, y = symbolAttribute.y } = symbol.attribute;\n if (!symbol.transMatrix.onlyTranslate()) {\n // 性能较差\n x = 0;\n y = 0;\n context.transformFromMatrix(symbol.transMatrix, true);\n } else {\n const { dx = symbolAttribute.dx, dy = symbolAttribute.dy } = symbol.attribute;\n x += dx;\n y += dy;\n // 当前context有rotate/scale,重置matrix\n context.setTransformForCurrent();\n }\n\n const parsedPath = symbol.getParsedPath();\n // todo: 考虑使用path\n if (!parsedPath) {\n return;\n }\n\n const {\n fill = symbolAttribute.fill,\n stroke = symbolAttribute.stroke,\n fillColor = symbolAttribute.fill,\n strokeColor = symbolAttribute.stroke,\n size = symbolAttribute.size,\n lineWidth = symbolAttribute.lineWidth,\n maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset,\n roughness = defaultRouthThemeSpec.roughness,\n bowing = defaultRouthThemeSpec.bowing,\n curveFitting = defaultRouthThemeSpec.curveFitting,\n curveTightness = defaultRouthThemeSpec.curveTightness,\n curveStepCount = defaultRouthThemeSpec.curveStepCount,\n fillStyle = defaultRouthThemeSpec.fillStyle,\n fillWeight = defaultRouthThemeSpec.fillWeight,\n hachureAngle = defaultRouthThemeSpec.hachureAngle,\n hachureGap = defaultRouthThemeSpec.hachureGap,\n simplification = defaultRouthThemeSpec.simplification,\n dashOffset = defaultRouthThemeSpec.dashOffset,\n dashGap = defaultRouthThemeSpec.dashGap,\n zigzagOffset = defaultRouthThemeSpec.zigzagOffset,\n seed = defaultRouthThemeSpec.seed,\n fillLineDash = defaultRouthThemeSpec.fillLineDash,\n fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset,\n disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke,\n disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill,\n preserveVertices = defaultRouthThemeSpec.preserveVertices,\n fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits\n } = symbol.attribute as any;\n\n const customPath = new CustomPath2D();\n if (parsedPath.draw(customPath, size, x, y)) {\n customPath.closePath();\n }\n\n rc.path(customPath.toString(), {\n fill: fill ? (fillColor as string) : undefined,\n stroke: stroke ? (strokeColor as string) : undefined,\n strokeWidth: lineWidth,\n maxRandomnessOffset,\n roughness,\n bowing,\n curveFitting,\n curveTightness,\n curveStepCount,\n fillStyle,\n fillWeight,\n hachureAngle,\n hachureGap,\n simplification,\n dashOffset,\n dashGap,\n zigzagOffset,\n seed,\n fillLineDash,\n fillLineDashOffset,\n disableMultiStroke,\n disableMultiStrokeFill,\n preserveVertices,\n fixedDecimalPlaceDigits\n });\n\n context.highPerformanceRestore();\n }\n\n drawShape(\n graphic: IGraphic,\n ctx: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean\n ): void {\n if (this.canvasRenderer.drawShape) {\n return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);\n }\n }\n}\n"]}
|