@visactor/vrender-kits 1.0.0-alpha.17 → 1.0.0-alpha.19

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.
@@ -4,4 +4,5 @@ export declare abstract class RoughBaseRender {
4
4
  canvasRenderer: IGraphicRender;
5
5
  drawShape(graphic: IGraphic, ctx: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
6
6
  doDraw(graphic: IGraphic, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
7
+ reInit(): void;
7
8
  }
@@ -57,6 +57,10 @@ class RoughBaseRender {
57
57
  this.canvasRenderer.drawShape(graphic, roughContext, 0, 0, drawContext, params, (() => (doRender(),
58
58
  !1)), (() => (doRender(), !1))), context.restore();
59
59
  }
60
+ reInit() {
61
+ var _a;
62
+ null === (_a = this.canvasRenderer) || void 0 === _a || _a.reInit();
63
+ }
60
64
  }
61
65
 
62
66
  exports.RoughBaseRender = RoughBaseRender;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/rough/base-render.ts"],"names":[],"mappings":";;;;;;AACA,yDAUgC;AAChC,sDAA4B;AAC5B,uCAA2C;AAC3C,qCAAiD;AAEjD,MAAsB,eAAe;IAEnC,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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AAC,CACF,CAAC;QAEF,OAAO,CAAC,OAAO,EAAE,CAAC;IAGpB,CAAC;CACF;AAlID,0CAkIC","file":"base-render.js","sourcesContent":["import type { IRenderService } from '@visactor/vrender-core';\nimport {\n type IGraphicAttribute,\n type IContext2d,\n type IGraphic,\n type IMarkAttribute,\n type IThemeAttribute,\n type IDrawContext,\n type IGraphicRenderDrawParams,\n type IGraphicRender,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport rough from 'roughjs';\nimport { RoughContext2d } from './context';\nimport { defaultRouthThemeSpec } from './config';\n\nexport abstract class RoughBaseRender {\n canvasRenderer!: IGraphicRender;\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 doDraw(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\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 customPath = new CustomPath2D();\n const roughContext = new RoughContext2d(context, customPath);\n\n context.save();\n // 不管怎么样,都transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n const { fill, stroke, roughStyle = {}, lineWidth } = graphic.attribute as any;\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 } = roughStyle;\n\n let rendered = false;\n const doRender = () => {\n if (rendered) {\n return;\n }\n rendered = true;\n const path = customPath.toString();\n context.beginPath();\n rc.path(path, {\n fill,\n stroke,\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 this.canvasRenderer.drawShape(\n graphic,\n roughContext,\n 0,\n 0,\n drawContext,\n params,\n () => {\n doRender();\n return false;\n },\n () => {\n doRender();\n return false;\n }\n );\n\n context.restore();\n\n // context.highPerformanceRestore();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/rough/base-render.ts"],"names":[],"mappings":";;;;;;AACA,yDAUgC;AACh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,kBAAkB;gBAClB,sBAAsB;gBACtB,gBAAgB;gBAChB,uBAAuB;aACxB,CAAC,CAAC;QACL,CAAC,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,SAAS,CAC3B,OAAO,EACP,YAAY,EACZ,CAAC,EACD,CAAC,EACD,WAAW,EACX,MAAM,EACN,GAAG,EAAE;YACH,QAAQ,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC,EACD,GAAG,EAAE;YACH,QAAQ,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC,CACF,CAAC;QAEF,OAAO,CAAC,OAAO,EAAE,CAAC;IAGpB,CAAC;IACD,MAAM;;QACJ,MAAA,IAAI,CAAC,cAAc,0CAAE,MAAM,EAAE,CAAC;IAChC,CAAC;CACF;AArID,0CAqIC","file":"base-render.js","sourcesContent":["import type { IRenderService } from '@visactor/vrender-core';\nimport {\n type IGraphicAttribute,\n type IContext2d,\n type IGraphic,\n type IMarkAttribute,\n type IThemeAttribute,\n type IDrawContext,\n type IGraphicRenderDrawParams,\n type IGraphicRender,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport rough from 'roughjs';\nimport { RoughContext2d } from './context';\nimport { defaultRouthThemeSpec } from './config';\n\nexport abstract class RoughBaseRender {\n canvasRenderer!: IGraphicRender;\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 doDraw(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\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 customPath = new CustomPath2D();\n const roughContext = new RoughContext2d(context, customPath);\n\n context.save();\n // 不管怎么样,都transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n const { fill, stroke, roughStyle = {}, lineWidth } = graphic.attribute as any;\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 } = roughStyle;\n\n let rendered = false;\n const doRender = () => {\n if (rendered) {\n return;\n }\n rendered = true;\n const path = customPath.toString();\n context.beginPath();\n rc.path(path, {\n fill,\n stroke,\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 this.canvasRenderer.drawShape(\n graphic,\n roughContext,\n 0,\n 0,\n drawContext,\n params,\n () => {\n doRender();\n return false;\n },\n () => {\n doRender();\n return false;\n }\n );\n\n context.restore();\n\n // context.highPerformanceRestore();\n }\n reInit() {\n this.canvasRenderer?.reInit();\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -2020,6 +2020,10 @@ class RoughBaseRender {
2020
2020
  });
2021
2021
  context.restore();
2022
2022
  }
2023
+ reInit() {
2024
+ var _a;
2025
+ (_a = this.canvasRenderer) === null || _a === void 0 ? void 0 : _a.reInit();
2026
+ }
2023
2027
  }
2024
2028
 
2025
2029
  let RoughCanvasArcRender = class RoughCanvasArcRender extends RoughBaseRender {
@@ -4,4 +4,5 @@ export declare abstract class RoughBaseRender {
4
4
  canvasRenderer: IGraphicRender;
5
5
  drawShape(graphic: IGraphic, ctx: IContext2d, x: number, y: number, drawContext: IDrawContext, params?: IGraphicRenderDrawParams, fillCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean): void;
6
6
  doDraw(graphic: IGraphic, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
7
+ reInit(): void;
7
8
  }
@@ -51,5 +51,9 @@ export class RoughBaseRender {
51
51
  this.canvasRenderer.drawShape(graphic, roughContext, 0, 0, drawContext, params, (() => (doRender(),
52
52
  !1)), (() => (doRender(), !1))), context.restore();
53
53
  }
54
+ reInit() {
55
+ var _a;
56
+ null === (_a = this.canvasRenderer) || void 0 === _a || _a.reInit();
57
+ }
54
58
  }
55
59
  //# sourceMappingURL=base-render.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/rough/base-render.ts"],"names":[],"mappings":"AACA,OAAO,EASL,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,OAAgB,eAAe;IAEnC,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;IAED,MAAM,CACJ,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,MAAiC;QAEjC,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,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAIhC,MAAM,UAAU,GAAG,IAAI,YAAY,EAAE,CAAC;QACtC,MAAM,YAAY,GAAG,IAAI,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAE7D,OAAO,CAAC,IAAI,EAAE,CAAC;QAEf,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAEvD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GA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IAAI;gBACJ,MAAM;gBACN,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;QACL,CAAC,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,SAAS,CAC3B,OAAO,EACP,YAAY,EACZ,CAAC,EACD,CAAC,EACD,WAAW,EACX,MAAM,EACN,GAAG,EAAE;YACH,QAAQ,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC,EACD,GAAG,EAAE;YACH,QAAQ,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC,CACF,CAAC;QAEF,OAAO,CAAC,OAAO,EAAE,CAAC;IAGpB,CAAC;CACF","file":"base-render.js","sourcesContent":["import type { IRenderService } from '@visactor/vrender-core';\nimport {\n type IGraphicAttribute,\n type IContext2d,\n type IGraphic,\n type IMarkAttribute,\n type IThemeAttribute,\n type IDrawContext,\n type IGraphicRenderDrawParams,\n type IGraphicRender,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport rough from 'roughjs';\nimport { RoughContext2d } from './context';\nimport { defaultRouthThemeSpec } from './config';\n\nexport abstract class RoughBaseRender {\n canvasRenderer!: IGraphicRender;\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 doDraw(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\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 customPath = new CustomPath2D();\n const roughContext = new RoughContext2d(context, customPath);\n\n context.save();\n // 不管怎么样,都transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n const { fill, stroke, roughStyle = {}, lineWidth } = graphic.attribute as any;\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 } = roughStyle;\n\n let rendered = false;\n const doRender = () => {\n if (rendered) {\n return;\n }\n rendered = true;\n const path = customPath.toString();\n context.beginPath();\n rc.path(path, {\n fill,\n stroke,\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 this.canvasRenderer.drawShape(\n graphic,\n roughContext,\n 0,\n 0,\n drawContext,\n params,\n () => {\n doRender();\n return false;\n },\n () => {\n doRender();\n return false;\n }\n );\n\n context.restore();\n\n // context.highPerformanceRestore();\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/rough/base-render.ts"],"names":[],"mappings":"AACA,OAAO,EASL,YAAY,EACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,MAAM,OAAgB,eAAe;IAEnC,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;IAED,MAAM,CACJ,OAAiB,EACjB,aAA6B,EAC7B,WAAyB,EACzB,MAAiC;QAEjC,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;QAChC,IAAI,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} from '@visactor/vrender-core';\nimport {\n type IGraphicAttribute,\n type IContext2d,\n type IGraphic,\n type IMarkAttribute,\n type IThemeAttribute,\n type IDrawContext,\n type IGraphicRenderDrawParams,\n type IGraphicRender,\n CustomPath2D\n} from '@visactor/vrender-core';\nimport rough from 'roughjs';\nimport { RoughContext2d } from './context';\nimport { defaultRouthThemeSpec } from './config';\n\nexport abstract class RoughBaseRender {\n canvasRenderer!: IGraphicRender;\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 doDraw(\n graphic: IGraphic,\n renderService: IRenderService,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams\n ) {\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 customPath = new CustomPath2D();\n const roughContext = new RoughContext2d(context, customPath);\n\n context.save();\n // 不管怎么样,都transform\n context.transformFromMatrix(graphic.transMatrix, true);\n\n const { fill, stroke, roughStyle = {}, lineWidth } = graphic.attribute as any;\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 } = roughStyle;\n\n let rendered = false;\n const doRender = () => {\n if (rendered) {\n return;\n }\n rendered = true;\n const path = customPath.toString();\n context.beginPath();\n rc.path(path, {\n fill,\n stroke,\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 this.canvasRenderer.drawShape(\n graphic,\n roughContext,\n 0,\n 0,\n drawContext,\n params,\n () => {\n doRender();\n return false;\n },\n () => {\n doRender();\n return false;\n }\n );\n\n context.restore();\n\n // context.highPerformanceRestore();\n }\n reInit() {\n this.canvasRenderer?.reInit();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-kits",
3
- "version": "1.0.0-alpha.17",
3
+ "version": "1.0.0-alpha.19",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "@visactor/vutils": "1.0.4",
16
- "@visactor/vrender-core": "1.0.0-alpha.17",
16
+ "@visactor/vrender-core": "1.0.0-alpha.19",
17
17
  "@resvg/resvg-js": "2.4.1",
18
18
  "roughjs": "4.5.2",
19
19
  "gifuct-js": "2.1.2",
@@ -33,8 +33,8 @@
33
33
  "vite": "3.2.6",
34
34
  "typescript": "4.9.5",
35
35
  "cross-env": "^7.0.3",
36
- "@internal/bundler": "0.0.1",
37
36
  "@internal/eslint-config": "0.0.1",
37
+ "@internal/bundler": "0.0.1",
38
38
  "@internal/ts-config": "0.0.1"
39
39
  },
40
40
  "keywords": [