@visactor/vrender-kits 0.22.10 → 0.22.12

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.
Files changed (42) hide show
  1. package/cjs/canvas/contributions/browser/context.d.ts +3 -2
  2. package/cjs/canvas/contributions/browser/context.js +23 -16
  3. package/cjs/canvas/contributions/browser/context.js.map +1 -1
  4. package/cjs/render/contributions/rough/base-render.d.ts +4 -1
  5. package/cjs/render/contributions/rough/base-render.js +53 -0
  6. package/cjs/render/contributions/rough/base-render.js.map +1 -1
  7. package/cjs/render/contributions/rough/config.js +4 -4
  8. package/cjs/render/contributions/rough/config.js.map +1 -1
  9. package/cjs/render/contributions/rough/context.d.ts +142 -0
  10. package/cjs/render/contributions/rough/context.js +408 -0
  11. package/cjs/render/contributions/rough/context.js.map +1 -0
  12. package/cjs/render/contributions/rough/rough-line.d.ts +6 -4
  13. package/cjs/render/contributions/rough/rough-line.js +14 -48
  14. package/cjs/render/contributions/rough/rough-line.js.map +1 -1
  15. package/cjs/render/contributions/rough/rough-rect.d.ts +1 -1
  16. package/cjs/render/contributions/rough/rough-rect.js +2 -44
  17. package/cjs/render/contributions/rough/rough-rect.js.map +1 -1
  18. package/cjs/render/contributions/rough/rough-symbol.d.ts +3 -4
  19. package/cjs/render/contributions/rough/rough-symbol.js +3 -47
  20. package/cjs/render/contributions/rough/rough-symbol.js.map +1 -1
  21. package/dist/index.es.js +509 -186
  22. package/es/canvas/contributions/browser/context.d.ts +3 -2
  23. package/es/canvas/contributions/browser/context.js +23 -16
  24. package/es/canvas/contributions/browser/context.js.map +1 -1
  25. package/es/render/contributions/rough/base-render.d.ts +4 -1
  26. package/es/render/contributions/rough/base-render.js +53 -0
  27. package/es/render/contributions/rough/base-render.js.map +1 -1
  28. package/es/render/contributions/rough/config.js +4 -4
  29. package/es/render/contributions/rough/config.js.map +1 -1
  30. package/es/render/contributions/rough/context.d.ts +142 -0
  31. package/es/render/contributions/rough/context.js +402 -0
  32. package/es/render/contributions/rough/context.js.map +1 -0
  33. package/es/render/contributions/rough/rough-line.d.ts +6 -4
  34. package/es/render/contributions/rough/rough-line.js +15 -48
  35. package/es/render/contributions/rough/rough-line.js.map +1 -1
  36. package/es/render/contributions/rough/rough-rect.d.ts +1 -1
  37. package/es/render/contributions/rough/rough-rect.js +1 -43
  38. package/es/render/contributions/rough/rough-rect.js.map +1 -1
  39. package/es/render/contributions/rough/rough-symbol.d.ts +3 -4
  40. package/es/render/contributions/rough/rough-symbol.js +4 -46
  41. package/es/render/contributions/rough/rough-symbol.js.map +1 -1
  42. package/package.json +5 -5
@@ -2,62 +2,29 @@ var __decorate = this && this.__decorate || function(decorators, target, key, de
2
2
  var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
3
3
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
4
4
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5
+ }, __metadata = this && this.__metadata || function(k, v) {
6
+ if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
7
+ }, __param = this && this.__param || function(paramIndex, decorator) {
8
+ return function(target, key) {
9
+ decorator(target, key, paramIndex);
10
+ };
5
11
  };
6
12
 
7
- import { DefaultCanvasLineRender, CustomPath2D, drawSegments, injectable } from "@visactor/vrender-core";
13
+ import { DefaultCanvasLineRender, injectable, inject, LINE_NUMBER_TYPE } from "@visactor/vrender-core";
8
14
 
9
- import rough from "roughjs";
15
+ import { RoughBaseRender } from "./base-render";
10
16
 
11
- import { defaultRouthThemeSpec } from "./config";
12
-
13
- let RoughCanvasLineRender = class extends DefaultCanvasLineRender {
14
- constructor() {
15
- super(...arguments), this.style = "rough";
17
+ let RoughCanvasLineRender = class extends RoughBaseRender {
18
+ constructor(canvasRenderer) {
19
+ super(), this.canvasRenderer = canvasRenderer, this.style = "rough", this.type = "line",
20
+ this.numberType = LINE_NUMBER_TYPE;
16
21
  }
17
- drawSegmentItem(context, cache, fill, stroke, fillOpacity, strokeOpacity, attribute, defaultAttribute, clipRange, clipRangeByDimension, offsetX, offsetY, line, fillCb, strokeCb) {
18
- if (fillCb || strokeCb) return super.drawSegmentItem(context, cache, fill, stroke, fillOpacity, strokeOpacity, attribute, defaultAttribute, clipRange, clipRangeByDimension, offsetX, offsetY, line, fillCb, strokeCb);
19
- context.highPerformanceSave();
20
- const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas, {}), customPath = new CustomPath2D;
21
- drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {
22
- offsetX: offsetX,
23
- offsetY: offsetY
24
- });
25
- const {maxRandomnessOffset: maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = defaultRouthThemeSpec.roughness, bowing: bowing = defaultRouthThemeSpec.bowing, curveFitting: curveFitting = defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = defaultRouthThemeSpec.hachureGap, simplification: simplification = defaultRouthThemeSpec.simplification, dashOffset: dashOffset = defaultRouthThemeSpec.dashOffset, dashGap: dashGap = defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = defaultRouthThemeSpec.zigzagOffset, seed: seed = defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits} = attribute;
26
- let {fill: fillColor, stroke: strokeColor, lineWidth: lineWidth} = attribute;
27
- return Array.isArray(defaultAttribute) ? defaultAttribute.forEach((item => {
28
- fillColor = null != fillColor ? fillColor : item.fill, strokeColor = null != strokeColor ? strokeColor : item.stroke,
29
- lineWidth = null != lineWidth ? lineWidth : item.lineWidth;
30
- })) : (fillColor = null != fillColor ? fillColor : defaultAttribute.fill, strokeColor = null != strokeColor ? strokeColor : defaultAttribute.stroke,
31
- lineWidth = null != lineWidth ? lineWidth : defaultAttribute.lineWidth), rc.path(customPath.toString(), {
32
- fill: fill ? fillColor : void 0,
33
- stroke: stroke ? strokeColor : void 0,
34
- strokeWidth: lineWidth,
35
- maxRandomnessOffset: maxRandomnessOffset,
36
- roughness: roughness,
37
- bowing: bowing,
38
- curveFitting: curveFitting,
39
- curveTightness: curveTightness,
40
- curveStepCount: curveStepCount,
41
- fillStyle: fillStyle,
42
- fillWeight: fillWeight,
43
- hachureAngle: hachureAngle,
44
- hachureGap: hachureGap,
45
- simplification: simplification,
46
- dashOffset: dashOffset,
47
- dashGap: dashGap,
48
- zigzagOffset: zigzagOffset,
49
- seed: seed,
50
- fillLineDash: fillLineDash,
51
- fillLineDashOffset: fillLineDashOffset,
52
- disableMultiStroke: disableMultiStroke,
53
- disableMultiStrokeFill: disableMultiStrokeFill,
54
- preserveVertices: preserveVertices,
55
- fixedDecimalPlaceDigits: fixedDecimalPlaceDigits
56
- }), context.highPerformanceRestore(), !1;
22
+ draw(line, renderService, drawContext, params) {
23
+ this.doDraw(line, renderService, drawContext, params);
57
24
  }
58
25
  };
59
26
 
60
- RoughCanvasLineRender = __decorate([ injectable() ], RoughCanvasLineRender);
27
+ RoughCanvasLineRender = __decorate([ injectable(), __param(0, inject(DefaultCanvasLineRender)), __metadata("design:paramtypes", [ Object ]) ], RoughCanvasLineRender);
61
28
 
62
29
  export { RoughCanvasLineRender };
63
30
  //# sourceMappingURL=rough-line.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/rough/rough-line.ts"],"names":[],"mappings":";;;;;;AAWA,OAAO,EAGL,uBAAuB,EAEvB,YAAY,EACZ,YAAY,EACZ,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAG1C,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,uBAAuB;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,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEpC,MAAM,UAAU,GAAG,IAAI,YAAY,EAAE,CAAC;QAEtC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC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n IThemeAttribute,\n IGraphicAttribute,\n ISegPath2D,\n ILine,\n ILineGraphicAttribute,\n IClipRangeByDimensionType\n} from '@visactor/vrender-core';\nimport {\n IRenderService,\n IGraphic,\n DefaultCanvasLineRender,\n getTheme,\n CustomPath2D,\n drawSegments,\n injectable\n} from '@visactor/vrender-core';\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"]}
1
+ {"version":3,"sources":["../src/render/contributions/rough/rough-line.ts"],"names":[],"mappings":";;;;;;;;;;;;AAcA,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACvG,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGzC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,eAAe;IAKxD,YAEkB,cAA8B;QAE9C,KAAK,EAAE,CAAC;QAFQ,mBAAc,GAAd,cAAc,CAAgB;QAJhD,UAAK,GAAY,OAAO,CAAC;QAOvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,IAAW,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC3G,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAjBY,qBAAqB;IADjC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;;GANvB,qBAAqB,CAiBjC;SAjBY,qBAAqB","file":"rough-line.js","sourcesContent":["import type {\n IGraphicRender,\n IContext2d,\n IMarkAttribute,\n IThemeAttribute,\n IGraphicAttribute,\n ISegPath2D,\n ILine,\n ILineGraphicAttribute,\n IClipRangeByDimensionType,\n IDrawContext,\n IGraphicRenderDrawParams,\n IRenderService\n} from '@visactor/vrender-core';\nimport { DefaultCanvasLineRender, injectable, inject, LINE_NUMBER_TYPE } from '@visactor/vrender-core';\nimport { RoughBaseRender } from './base-render';\n\n@injectable()\nexport class RoughCanvasLineRender extends RoughBaseRender implements IGraphicRender {\n declare type: 'line';\n declare numberType: number;\n style: 'rough' = 'rough';\n\n constructor(\n @inject(DefaultCanvasLineRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n super();\n this.type = 'line';\n this.numberType = LINE_NUMBER_TYPE;\n }\n\n draw(line: ILine, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n this.doDraw(line, renderService, drawContext, params);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { IGraphicRender, IRenderService, IRect, IDrawContext, IGraphicRenderDrawParams } from '@visactor/vrender-core';
1
+ import { type IGraphicRender, type IRenderService, type IRect, type IDrawContext, type IGraphicRenderDrawParams } from '@visactor/vrender-core';
2
2
  import { RoughBaseRender } from './base-render';
3
3
  export declare class RoughCanvasRectRender extends RoughBaseRender implements IGraphicRender {
4
4
  readonly canvasRenderer: IGraphicRender;
@@ -12,10 +12,6 @@ var __decorate = this && this.__decorate || function(decorators, target, key, de
12
12
 
13
13
  import { RECT_NUMBER_TYPE, DefaultCanvasRectRender, inject, injectable } from "@visactor/vrender-core";
14
14
 
15
- import rough from "roughjs";
16
-
17
- import { defaultRouthThemeSpec } from "./config";
18
-
19
15
  import { RoughBaseRender } from "./base-render";
20
16
 
21
17
  let RoughCanvasRectRender = class extends RoughBaseRender {
@@ -24,45 +20,7 @@ let RoughCanvasRectRender = class extends RoughBaseRender {
24
20
  this.numberType = RECT_NUMBER_TYPE;
25
21
  }
26
22
  draw(rect, renderService, drawContext, params) {
27
- const {context: context} = drawContext;
28
- if (!context) return;
29
- const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas);
30
- context.highPerformanceSave();
31
- const rectAttribute = rect.getGraphicTheme();
32
- let {x: x = rectAttribute.x, y: y = rectAttribute.y} = rect.attribute;
33
- if (rect.transMatrix.onlyTranslate()) {
34
- const {dx: dx = rectAttribute.dx, dy: dy = rectAttribute.dy} = rect.attribute;
35
- x += dx, y += dy, context.setTransformForCurrent();
36
- } else x = 0, y = 0, context.transformFromMatrix(rect.transMatrix, !0);
37
- const {fill: fill = rectAttribute.fill, stroke: stroke = rectAttribute.stroke, fillColor: fillColor = rectAttribute.fill, strokeColor: strokeColor = rectAttribute.stroke, x1: x1, y1: y1, lineWidth: lineWidth = rectAttribute.lineWidth, maxRandomnessOffset: maxRandomnessOffset = defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = defaultRouthThemeSpec.roughness, bowing: bowing = defaultRouthThemeSpec.bowing, curveFitting: curveFitting = defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = defaultRouthThemeSpec.hachureGap, simplification: simplification = defaultRouthThemeSpec.simplification, dashOffset: dashOffset = defaultRouthThemeSpec.dashOffset, dashGap: dashGap = defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = defaultRouthThemeSpec.zigzagOffset, seed: seed = defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits} = rect.attribute;
38
- let {width: width = rectAttribute.width, height: height = rectAttribute.height} = rect.attribute;
39
- width = (null != width ? width : x1 - x) || 0, height = (null != height ? height : y1 - y) || 0,
40
- rc.rectangle(x, y, width, height, {
41
- fill: fill ? fillColor : void 0,
42
- stroke: stroke ? strokeColor : void 0,
43
- strokeWidth: lineWidth,
44
- maxRandomnessOffset: maxRandomnessOffset,
45
- roughness: roughness,
46
- bowing: bowing,
47
- curveFitting: curveFitting,
48
- curveTightness: curveTightness,
49
- curveStepCount: curveStepCount,
50
- fillStyle: fillStyle,
51
- fillWeight: fillWeight,
52
- hachureAngle: hachureAngle,
53
- hachureGap: hachureGap,
54
- simplification: simplification,
55
- dashOffset: dashOffset,
56
- dashGap: dashGap,
57
- zigzagOffset: zigzagOffset,
58
- seed: seed,
59
- fillLineDash: fillLineDash,
60
- fillLineDashOffset: fillLineDashOffset,
61
- disableMultiStroke: disableMultiStroke,
62
- disableMultiStrokeFill: disableMultiStrokeFill,
63
- preserveVertices: preserveVertices,
64
- fixedDecimalPlaceDigits: fixedDecimalPlaceDigits
65
- }), context.highPerformanceRestore();
23
+ this.doDraw(rect, renderService, drawContext, params);
66
24
  }
67
25
  };
68
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/rough/rough-rect.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAY,MAAM,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACjH,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGzC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,eAAe;IAKxD,YAEkB,cAA8B;QAE9C,KAAK,EAAE,CAAC;QAFQ,mBAAc,GAAd,cAAc,CAAgB;QAJhD,UAAK,GAAY,OAAO,CAAC;QAOvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG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AChC,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;CACF,CAAA;AA1GY,qBAAqB;IADjC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;;GANvB,qBAAqB,CA0GjC;SA1GY,qBAAqB","file":"rough-rect.js","sourcesContent":["import type {\n IGraphicRender,\n IRenderService,\n IRect,\n IDrawContext,\n IGraphicRenderDrawParams\n} from '@visactor/vrender-core';\nimport { RECT_NUMBER_TYPE, DefaultCanvasRectRender, getTheme, inject, injectable } from '@visactor/vrender-core';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\nimport { RoughBaseRender } from './base-render';\n\n@injectable()\nexport class RoughCanvasRectRender extends RoughBaseRender 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 super();\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 = rect.getGraphicTheme();\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 x1,\n y1,\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\n let { width = rectAttribute.width, height = rectAttribute.height } = rect.attribute;\n\n width = (width ?? x1 - x) || 0;\n height = (height ?? y1 - y) || 0;\n\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"]}
1
+ {"version":3,"sources":["../src/render/contributions/rough/rough-rect.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAML,gBAAgB,EAChB,uBAAuB,EACvB,MAAM,EACN,UAAU,EAEX,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIzC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,eAAe;IAKxD,YAEkB,cAA8B;QAE9C,KAAK,EAAE,CAAC;QAFQ,mBAAc,GAAd,cAAc,CAAgB;QAJhD,UAAK,GAAY,OAAO,CAAC;QAOvB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC;IACrC,CAAC;IAED,IAAI,CAAC,IAAW,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC3G,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAjBY,qBAAqB;IADjC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,uBAAuB,CAAC,CAAA;;GANvB,qBAAqB,CAiBjC;SAjBY,qBAAqB","file":"rough-rect.js","sourcesContent":["import {\n type IGraphicRender,\n type IRenderService,\n type IRect,\n type IDrawContext,\n type IGraphicRenderDrawParams,\n RECT_NUMBER_TYPE,\n DefaultCanvasRectRender,\n inject,\n injectable,\n CustomPath2D\n} from '@visactor/vrender-core';\n\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\nimport { RoughBaseRender } from './base-render';\nimport { RoughContext2d } from './context';\n\n@injectable()\nexport class RoughCanvasRectRender extends RoughBaseRender 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 super();\n this.type = 'rect';\n this.numberType = RECT_NUMBER_TYPE;\n }\n\n draw(rect: IRect, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n this.doDraw(rect, renderService, drawContext, params);\n }\n}\n"]}
@@ -1,11 +1,10 @@
1
- import type { IGraphicRender, IRenderService, ISymbol, IGraphicAttribute, IContext2d, IGraphic, IMarkAttribute, IThemeAttribute, IDrawContext, IGraphicRenderDrawParams } from '@visactor/vrender-core';
2
- import { BaseRender } from '@visactor/vrender-core';
3
- export declare class RoughCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {
1
+ import type { IGraphicRender, IRenderService, ISymbol, IDrawContext, IGraphicRenderDrawParams } from '@visactor/vrender-core';
2
+ import { RoughBaseRender } from './base-render';
3
+ export declare class RoughCanvasSymbolRender extends RoughBaseRender implements IGraphicRender {
4
4
  readonly canvasRenderer: IGraphicRender;
5
5
  type: 'symbol';
6
6
  numberType: number;
7
7
  style: 'rough';
8
8
  constructor(canvasRenderer: IGraphicRender);
9
9
  draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
10
- 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;
11
10
  }
@@ -10,59 +10,17 @@ var __decorate = this && this.__decorate || function(decorators, target, key, de
10
10
  };
11
11
  };
12
12
 
13
- import { SYMBOL_NUMBER_TYPE, DefaultCanvasSymbolRender, BaseRender, CustomPath2D, inject, injectable } from "@visactor/vrender-core";
13
+ import { SYMBOL_NUMBER_TYPE, DefaultCanvasSymbolRender, inject, injectable } from "@visactor/vrender-core";
14
14
 
15
- import rough from "roughjs";
15
+ import { RoughBaseRender } from "./base-render";
16
16
 
17
- import { defaultRouthThemeSpec } from "./config";
18
-
19
- let RoughCanvasSymbolRender = class extends BaseRender {
17
+ let RoughCanvasSymbolRender = class extends RoughBaseRender {
20
18
  constructor(canvasRenderer) {
21
19
  super(), this.canvasRenderer = canvasRenderer, this.type = "symbol", this.numberType = SYMBOL_NUMBER_TYPE,
22
20
  this.style = "rough";
23
21
  }
24
22
  draw(symbol, renderService, drawContext, params) {
25
- const {context: context} = drawContext;
26
- if (!context) return;
27
- const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas);
28
- context.highPerformanceSave();
29
- const symbolAttribute = symbol.getGraphicTheme(), data = this.transform(symbol, symbolAttribute, context), {x: x, y: y, z: z, lastModelMatrix: lastModelMatrix} = data, parsedPath = symbol.getParsedPath();
30
- if (!parsedPath) return;
31
- 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 = defaultRouthThemeSpec.maxRandomnessOffset, roughness: roughness = defaultRouthThemeSpec.roughness, bowing: bowing = defaultRouthThemeSpec.bowing, curveFitting: curveFitting = defaultRouthThemeSpec.curveFitting, curveTightness: curveTightness = defaultRouthThemeSpec.curveTightness, curveStepCount: curveStepCount = defaultRouthThemeSpec.curveStepCount, fillStyle: fillStyle = defaultRouthThemeSpec.fillStyle, fillWeight: fillWeight = defaultRouthThemeSpec.fillWeight, hachureAngle: hachureAngle = defaultRouthThemeSpec.hachureAngle, hachureGap: hachureGap = defaultRouthThemeSpec.hachureGap, simplification: simplification = defaultRouthThemeSpec.simplification, dashOffset: dashOffset = defaultRouthThemeSpec.dashOffset, dashGap: dashGap = defaultRouthThemeSpec.dashGap, zigzagOffset: zigzagOffset = defaultRouthThemeSpec.zigzagOffset, seed: seed = defaultRouthThemeSpec.seed, fillLineDash: fillLineDash = defaultRouthThemeSpec.fillLineDash, fillLineDashOffset: fillLineDashOffset = defaultRouthThemeSpec.fillLineDashOffset, disableMultiStroke: disableMultiStroke = defaultRouthThemeSpec.disableMultiStroke, disableMultiStrokeFill: disableMultiStrokeFill = defaultRouthThemeSpec.disableMultiStrokeFill, preserveVertices: preserveVertices = defaultRouthThemeSpec.preserveVertices, fixedDecimalPlaceDigits: fixedDecimalPlaceDigits = defaultRouthThemeSpec.fixedDecimalPlaceDigits} = symbol.attribute;
32
- let svgPath = "";
33
- if (parsedPath.drawToSvgPath) svgPath = parsedPath.drawToSvgPath(size, x, y); else {
34
- const customPath = new CustomPath2D;
35
- parsedPath.draw(customPath, size, x, y) && customPath.closePath(), svgPath = customPath.toString();
36
- }
37
- rc.path(svgPath, {
38
- fill: fill ? fillColor : void 0,
39
- stroke: stroke ? strokeColor : void 0,
40
- strokeWidth: lineWidth,
41
- maxRandomnessOffset: maxRandomnessOffset,
42
- roughness: roughness,
43
- bowing: bowing,
44
- curveFitting: curveFitting,
45
- curveTightness: curveTightness,
46
- curveStepCount: curveStepCount,
47
- fillStyle: fillStyle,
48
- fillWeight: fillWeight,
49
- hachureAngle: hachureAngle,
50
- hachureGap: hachureGap,
51
- simplification: simplification,
52
- dashOffset: dashOffset,
53
- dashGap: dashGap,
54
- zigzagOffset: zigzagOffset,
55
- seed: seed,
56
- fillLineDash: fillLineDash,
57
- fillLineDashOffset: fillLineDashOffset,
58
- disableMultiStroke: disableMultiStroke,
59
- disableMultiStrokeFill: disableMultiStrokeFill,
60
- preserveVertices: preserveVertices,
61
- fixedDecimalPlaceDigits: fixedDecimalPlaceDigits
62
- }), context.highPerformanceRestore();
63
- }
64
- drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb) {
65
- if (this.canvasRenderer.drawShape) return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);
23
+ this.doDraw(symbol, renderService, drawContext, params);
66
24
  }
67
25
  };
68
26
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/rough/rough-symbol.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,UAAU,EAEV,YAAY,EACZ,MAAM,EACN,UAAU,EACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAG1C,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,UAAmB;IAK9D,YAEkB,cAA8B;QAE9C,KAAK,EAAE,CAAC;QAFQ,mBAAc,GAAd,cAAc,CAAgB;QAG9C,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,kBAAkB,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;IACvB,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,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CA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AAe,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;AAhIY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;;GANzB,uBAAuB,CAgInC;SAhIY,uBAAuB","file":"rough-symbol.js","sourcesContent":["import 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-core';\nimport {\n SYMBOL_NUMBER_TYPE,\n DefaultCanvasSymbolRender,\n BaseRender,\n getTheme,\n CustomPath2D,\n inject,\n injectable\n} from '@visactor/vrender-core';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\n\n@injectable()\nexport class RoughCanvasSymbolRender extends BaseRender<ISymbol> implements IGraphicRender {\n type: 'symbol';\n numberType: number;\n style: 'rough';\n\n constructor(\n @inject(DefaultCanvasSymbolRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n super();\n this.type = 'symbol';\n this.numberType = SYMBOL_NUMBER_TYPE;\n this.style = 'rough';\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 const symbolAttribute = symbol.getGraphicTheme();\n const data = this.transform(symbol, symbolAttribute, context);\n const { x, y, z, lastModelMatrix } = data;\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 let svgPath = '';\n if (parsedPath.drawToSvgPath) {\n svgPath = parsedPath.drawToSvgPath(size, x, y);\n } else {\n const customPath = new CustomPath2D();\n if (parsedPath.draw(customPath, size, x, y)) {\n customPath.closePath();\n }\n svgPath = customPath.toString();\n }\n\n rc.path(svgPath, {\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"]}
1
+ {"version":3,"sources":["../src/render/contributions/rough/rough-symbol.ts"],"names":[],"mappings":";;;;;;;;;;;;AAYA,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EAIzB,MAAM,EACN,UAAU,EACX,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGzC,IAAM,uBAAuB,GAA7B,MAAM,uBAAwB,SAAQ,eAAe;IAK1D,YAEkB,cAA8B;QAE9C,KAAK,EAAE,CAAC;QAFQ,mBAAc,GAAd,cAAc,CAAgB;QAG9C,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,kBAAkB,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;IACvB,CAAC;IAED,IAAI,CAAC,MAAe,EAAE,aAA6B,EAAE,WAAyB,EAAE,MAAiC;QAC/G,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AAlBY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;;GANzB,uBAAuB,CAkBnC;SAlBY,uBAAuB","file":"rough-symbol.js","sourcesContent":["import 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-core';\nimport {\n SYMBOL_NUMBER_TYPE,\n DefaultCanvasSymbolRender,\n BaseRender,\n getTheme,\n CustomPath2D,\n inject,\n injectable\n} from '@visactor/vrender-core';\nimport rough from 'roughjs';\nimport { defaultRouthThemeSpec } from './config';\nimport { RoughContext2d } from './context';\nimport { RoughBaseRender } from './base-render';\n\n@injectable()\nexport class RoughCanvasSymbolRender extends RoughBaseRender implements IGraphicRender {\n type: 'symbol';\n numberType: number;\n style: 'rough';\n\n constructor(\n @inject(DefaultCanvasSymbolRender)\n public readonly canvasRenderer: IGraphicRender\n ) {\n super();\n this.type = 'symbol';\n this.numberType = SYMBOL_NUMBER_TYPE;\n this.style = 'rough';\n }\n\n draw(symbol: ISymbol, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n this.doDraw(symbol, renderService, drawContext, params);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-kits",
3
- "version": "0.22.10",
3
+ "version": "0.22.12",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -12,8 +12,8 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@visactor/vutils": "~0.19.5",
16
- "@visactor/vrender-core": "0.22.10",
15
+ "@visactor/vutils": "1.0.6",
16
+ "@visactor/vrender-core": "0.22.12",
17
17
  "@resvg/resvg-js": "2.4.1",
18
18
  "roughjs": "4.5.2",
19
19
  "gifuct-js": "2.1.2",
@@ -34,8 +34,8 @@
34
34
  "typescript": "4.9.5",
35
35
  "cross-env": "^7.0.3",
36
36
  "@internal/bundler": "0.0.1",
37
- "@internal/eslint-config": "0.0.1",
38
- "@internal/ts-config": "0.0.1"
37
+ "@internal/ts-config": "0.0.1",
38
+ "@internal/eslint-config": "0.0.1"
39
39
  },
40
40
  "keywords": [
41
41
  "VisActor",