@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.
- package/cjs/canvas/contributions/browser/context.d.ts +3 -2
- package/cjs/canvas/contributions/browser/context.js +23 -16
- package/cjs/canvas/contributions/browser/context.js.map +1 -1
- package/cjs/render/contributions/rough/base-render.d.ts +4 -1
- package/cjs/render/contributions/rough/base-render.js +53 -0
- package/cjs/render/contributions/rough/base-render.js.map +1 -1
- package/cjs/render/contributions/rough/config.js +4 -4
- package/cjs/render/contributions/rough/config.js.map +1 -1
- package/cjs/render/contributions/rough/context.d.ts +142 -0
- package/cjs/render/contributions/rough/context.js +408 -0
- package/cjs/render/contributions/rough/context.js.map +1 -0
- package/cjs/render/contributions/rough/rough-line.d.ts +6 -4
- package/cjs/render/contributions/rough/rough-line.js +14 -48
- package/cjs/render/contributions/rough/rough-line.js.map +1 -1
- package/cjs/render/contributions/rough/rough-rect.d.ts +1 -1
- package/cjs/render/contributions/rough/rough-rect.js +2 -44
- package/cjs/render/contributions/rough/rough-rect.js.map +1 -1
- package/cjs/render/contributions/rough/rough-symbol.d.ts +3 -4
- package/cjs/render/contributions/rough/rough-symbol.js +3 -47
- package/cjs/render/contributions/rough/rough-symbol.js.map +1 -1
- package/dist/index.es.js +509 -186
- package/es/canvas/contributions/browser/context.d.ts +3 -2
- package/es/canvas/contributions/browser/context.js +23 -16
- package/es/canvas/contributions/browser/context.js.map +1 -1
- package/es/render/contributions/rough/base-render.d.ts +4 -1
- package/es/render/contributions/rough/base-render.js +53 -0
- package/es/render/contributions/rough/base-render.js.map +1 -1
- package/es/render/contributions/rough/config.js +4 -4
- package/es/render/contributions/rough/config.js.map +1 -1
- package/es/render/contributions/rough/context.d.ts +142 -0
- package/es/render/contributions/rough/context.js +402 -0
- package/es/render/contributions/rough/context.js.map +1 -0
- package/es/render/contributions/rough/rough-line.d.ts +6 -4
- package/es/render/contributions/rough/rough-line.js +15 -48
- package/es/render/contributions/rough/rough-line.js.map +1 -1
- package/es/render/contributions/rough/rough-rect.d.ts +1 -1
- package/es/render/contributions/rough/rough-rect.js +1 -43
- package/es/render/contributions/rough/rough-rect.js.map +1 -1
- package/es/render/contributions/rough/rough-symbol.d.ts +3 -4
- package/es/render/contributions/rough/rough-symbol.js +4 -46
- package/es/render/contributions/rough/rough-symbol.js.map +1 -1
- 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,
|
|
13
|
+
import { DefaultCanvasLineRender, injectable, inject, LINE_NUMBER_TYPE } from "@visactor/vrender-core";
|
|
8
14
|
|
|
9
|
-
import
|
|
15
|
+
import { RoughBaseRender } from "./base-render";
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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":"
|
|
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
|
|
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
|
-
|
|
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":";;;;;;;;;;;;
|
|
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,
|
|
2
|
-
import {
|
|
3
|
-
export declare class RoughCanvasSymbolRender extends
|
|
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,
|
|
13
|
+
import { SYMBOL_NUMBER_TYPE, DefaultCanvasSymbolRender, inject, injectable } from "@visactor/vrender-core";
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import { RoughBaseRender } from "./base-render";
|
|
16
16
|
|
|
17
|
-
|
|
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
|
-
|
|
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,
|
|
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.
|
|
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": "
|
|
16
|
-
"@visactor/vrender-core": "0.22.
|
|
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/
|
|
38
|
-
"@internal/
|
|
37
|
+
"@internal/ts-config": "0.0.1",
|
|
38
|
+
"@internal/eslint-config": "0.0.1"
|
|
39
39
|
},
|
|
40
40
|
"keywords": [
|
|
41
41
|
"VisActor",
|