@visactor/vrender-kits 0.9.0-alpha.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/README.md +9 -0
- package/cjs/canvas/contributions/canvas-module.d.ts +2 -0
- package/cjs/canvas/contributions/canvas-module.js +20 -0
- package/cjs/canvas/contributions/canvas-module.js.map +1 -0
- package/cjs/canvas/contributions/node/canvas.d.ts +44 -0
- package/cjs/canvas/contributions/node/canvas.js +100 -0
- package/cjs/canvas/contributions/node/canvas.js.map +1 -0
- package/cjs/canvas/contributions/node/context.d.ts +7 -0
- package/cjs/canvas/contributions/node/context.js +30 -0
- package/cjs/canvas/contributions/node/context.js.map +1 -0
- package/cjs/canvas/contributions/node/index.d.ts +2 -0
- package/cjs/canvas/contributions/node/index.js +21 -0
- package/cjs/canvas/contributions/node/index.js.map +1 -0
- package/cjs/canvas/contributions/node/modules.d.ts +3 -0
- package/cjs/canvas/contributions/node/modules.js +13 -0
- package/cjs/canvas/contributions/node/modules.js.map +1 -0
- package/cjs/canvas/index.d.ts +1 -0
- package/cjs/canvas/index.js +6 -0
- package/cjs/canvas/index.js.map +1 -0
- package/cjs/env/contributions/module.d.ts +3 -0
- package/cjs/env/contributions/module.js +12 -0
- package/cjs/env/contributions/module.js.map +1 -0
- package/cjs/env/contributions/node-contribution.d.ts +47 -0
- package/cjs/env/contributions/node-contribution.js +118 -0
- package/cjs/env/contributions/node-contribution.js.map +1 -0
- package/cjs/index-node.d.ts +5 -0
- package/cjs/index-node.js +25 -0
- package/cjs/index-node.js.map +1 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +16 -0
- package/cjs/index.js.map +1 -0
- package/cjs/node-bind.d.ts +2 -0
- package/cjs/node-bind.js +20 -0
- package/cjs/node-bind.js.map +1 -0
- package/cjs/render/contributions/render-module.d.ts +1 -0
- package/cjs/render/contributions/render-module.js +1 -0
- package/cjs/render/contributions/render-module.js.map +1 -0
- package/cjs/render/contributions/rough/config.d.ts +2 -0
- package/cjs/render/contributions/rough/config.js +28 -0
- package/cjs/render/contributions/rough/config.js.map +1 -0
- package/cjs/render/contributions/rough/module.d.ts +3 -0
- package/cjs/render/contributions/rough/module.js +18 -0
- package/cjs/render/contributions/rough/module.js.map +1 -0
- package/cjs/render/contributions/rough/rough-arc.d.ts +10 -0
- package/cjs/render/contributions/rough/rough-arc.js +75 -0
- package/cjs/render/contributions/rough/rough-arc.js.map +1 -0
- package/cjs/render/contributions/rough/rough-area.d.ts +8 -0
- package/cjs/render/contributions/rough/rough-area.js +67 -0
- package/cjs/render/contributions/rough/rough-area.js.map +1 -0
- package/cjs/render/contributions/rough/rough-circle.d.ts +10 -0
- package/cjs/render/contributions/rough/rough-circle.js +55 -0
- package/cjs/render/contributions/rough/rough-circle.js.map +1 -0
- package/cjs/render/contributions/rough/rough-line.d.ts +8 -0
- package/cjs/render/contributions/rough/rough-line.js +68 -0
- package/cjs/render/contributions/rough/rough-line.js.map +1 -0
- package/cjs/render/contributions/rough/rough-path.d.ts +10 -0
- package/cjs/render/contributions/rough/rough-path.js +73 -0
- package/cjs/render/contributions/rough/rough-path.js.map +1 -0
- package/cjs/render/contributions/rough/rough-rect.d.ts +10 -0
- package/cjs/render/contributions/rough/rough-rect.js +77 -0
- package/cjs/render/contributions/rough/rough-rect.js.map +1 -0
- package/cjs/render/contributions/rough/rough-symbol.d.ts +10 -0
- package/cjs/render/contributions/rough/rough-symbol.js +79 -0
- package/cjs/render/contributions/rough/rough-symbol.js.map +1 -0
- package/cjs/window/contributions/modules.d.ts +3 -0
- package/cjs/window/contributions/modules.js +13 -0
- package/cjs/window/contributions/modules.js.map +1 -0
- package/cjs/window/contributions/node-contribution.d.ts +38 -0
- package/cjs/window/contributions/node-contribution.js +109 -0
- package/cjs/window/contributions/node-contribution.js.map +1 -0
- package/dist/vrender-kits.js.js +1 -0
- package/dist/vrender-kits.js.min.js +1 -0
- package/es/canvas/contributions/canvas-module.d.ts +2 -0
- package/es/canvas/contributions/canvas-module.js +6 -0
- package/es/canvas/contributions/canvas-module.js.map +1 -0
- package/es/canvas/contributions/node/canvas.d.ts +44 -0
- package/es/canvas/contributions/node/canvas.js +99 -0
- package/es/canvas/contributions/node/canvas.js.map +1 -0
- package/es/canvas/contributions/node/context.d.ts +7 -0
- package/es/canvas/contributions/node/context.js +31 -0
- package/es/canvas/contributions/node/context.js.map +1 -0
- package/es/canvas/contributions/node/index.d.ts +2 -0
- package/es/canvas/contributions/node/index.js +4 -0
- package/es/canvas/contributions/node/index.js.map +1 -0
- package/es/canvas/contributions/node/modules.d.ts +3 -0
- package/es/canvas/contributions/node/modules.js +13 -0
- package/es/canvas/contributions/node/modules.js.map +1 -0
- package/es/canvas/index.d.ts +1 -0
- package/es/canvas/index.js +2 -0
- package/es/canvas/index.js.map +1 -0
- package/es/env/contributions/module.d.ts +3 -0
- package/es/env/contributions/module.js +10 -0
- package/es/env/contributions/module.js.map +1 -0
- package/es/env/contributions/node-contribution.d.ts +47 -0
- package/es/env/contributions/node-contribution.js +94 -0
- package/es/env/contributions/node-contribution.js.map +1 -0
- package/es/index-node.d.ts +5 -0
- package/es/index-node.js +11 -0
- package/es/index-node.js.map +1 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +10 -0
- package/es/index.js.map +1 -0
- package/es/node-bind.d.ts +2 -0
- package/es/node-bind.js +10 -0
- package/es/node-bind.js.map +1 -0
- package/es/render/contributions/render-module.d.ts +1 -0
- package/es/render/contributions/render-module.js +1 -0
- package/es/render/contributions/render-module.js.map +1 -0
- package/es/render/contributions/rough/config.d.ts +2 -0
- package/es/render/contributions/rough/config.js +24 -0
- package/es/render/contributions/rough/config.js.map +1 -0
- package/es/render/contributions/rough/module.d.ts +3 -0
- package/es/render/contributions/rough/module.js +28 -0
- package/es/render/contributions/rough/module.js.map +1 -0
- package/es/render/contributions/rough/rough-arc.d.ts +10 -0
- package/es/render/contributions/rough/rough-arc.js +71 -0
- package/es/render/contributions/rough/rough-arc.js.map +1 -0
- package/es/render/contributions/rough/rough-area.d.ts +8 -0
- package/es/render/contributions/rough/rough-area.js +64 -0
- package/es/render/contributions/rough/rough-area.js.map +1 -0
- package/es/render/contributions/rough/rough-circle.d.ts +10 -0
- package/es/render/contributions/rough/rough-circle.js +48 -0
- package/es/render/contributions/rough/rough-circle.js.map +1 -0
- package/es/render/contributions/rough/rough-line.d.ts +8 -0
- package/es/render/contributions/rough/rough-line.js +65 -0
- package/es/render/contributions/rough/rough-line.js.map +1 -0
- package/es/render/contributions/rough/rough-path.d.ts +10 -0
- package/es/render/contributions/rough/rough-path.js +69 -0
- package/es/render/contributions/rough/rough-path.js.map +1 -0
- package/es/render/contributions/rough/rough-rect.d.ts +10 -0
- package/es/render/contributions/rough/rough-rect.js +73 -0
- package/es/render/contributions/rough/rough-rect.js.map +1 -0
- package/es/render/contributions/rough/rough-symbol.d.ts +10 -0
- package/es/render/contributions/rough/rough-symbol.js +75 -0
- package/es/render/contributions/rough/rough-symbol.js.map +1 -0
- package/es/window/contributions/modules.d.ts +3 -0
- package/es/window/contributions/modules.js +10 -0
- package/es/window/contributions/modules.js.map +1 -0
- package/es/window/contributions/node-contribution.d.ts +38 -0
- package/es/window/contributions/node-contribution.js +107 -0
- package/es/window/contributions/node-contribution.js.map +1 -0
- package/package.json +50 -0
package/es/index-node.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
|
|
3
|
+
import _roughModule from "./render/contributions/rough/module";
|
|
4
|
+
|
|
5
|
+
import _canvasModuleLoader from "./canvas/contributions/canvas-module";
|
|
6
|
+
|
|
7
|
+
export const roughModule = _roughModule;
|
|
8
|
+
|
|
9
|
+
export const canvasModuleLoader = _canvasModuleLoader;
|
|
10
|
+
|
|
11
|
+
export { nodeLoader } from "./node-bind";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,YAAY,MAAM,qCAAqC,CAAC;AAC/D,OAAO,mBAAmB,MAAM,sCAAsC,CAAC;AAEvE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC","file":"index-node.js","sourcesContent":["import 'reflect-metadata';\nimport _roughModule from './render/contributions/rough/module';\nimport _canvasModuleLoader from './canvas/contributions/canvas-module';\n\nexport const roughModule = _roughModule;\nexport const canvasModuleLoader = _canvasModuleLoader;\nexport { nodeLoader } from './node-bind';\n"]}
|
package/es/index.d.ts
ADDED
package/es/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
|
|
3
|
+
import _roughModule from "./render/contributions/rough/module";
|
|
4
|
+
|
|
5
|
+
import _canvasModuleLoader from "./canvas/contributions/canvas-module";
|
|
6
|
+
|
|
7
|
+
export const roughModule = _roughModule;
|
|
8
|
+
|
|
9
|
+
export const canvasModuleLoader = _canvasModuleLoader;
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,YAAY,MAAM,qCAAqC,CAAC;AAC/D,OAAO,mBAAmB,MAAM,sCAAsC,CAAC;AAEvE,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AACxC,MAAM,CAAC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC","file":"index.js","sourcesContent":["import 'reflect-metadata';\nimport _roughModule from './render/contributions/rough/module';\nimport _canvasModuleLoader from './canvas/contributions/canvas-module';\n\nexport const roughModule = _roughModule;\nexport const canvasModuleLoader = _canvasModuleLoader;\n// export { nodeLoader } from './node-bind'; // nodeLoader只在node入口暴露\n"]}
|
package/es/node-bind.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import nodeEnv from "./env/contributions/module";
|
|
2
|
+
|
|
3
|
+
import nodeWindow from "./window/contributions/modules";
|
|
4
|
+
|
|
5
|
+
import nodeCanvas from "./canvas/contributions/node/modules";
|
|
6
|
+
|
|
7
|
+
export function nodeLoader(container) {
|
|
8
|
+
container.load(nodeEnv), container.load(nodeWindow), container.load(nodeCanvas);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=node-bind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node-bind.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,4BAA4B,CAAC;AACjD,OAAO,UAAU,MAAM,gCAAgC,CAAC;AACxD,OAAO,UAAU,MAAM,qCAAqC,CAAC;AAG7D,MAAM,UAAU,UAAU,CAAC,SAAoB;IAC7C,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC","file":"node-bind.js","sourcesContent":["import type { Container } from 'inversify';\nimport nodeEnv from './env/contributions/module';\nimport nodeWindow from './window/contributions/modules';\nimport nodeCanvas from './canvas/contributions/node/modules';\n\n// 直接绑定node环境\nexport function nodeLoader(container: Container) {\n container.load(nodeEnv);\n container.load(nodeWindow);\n container.load(nodeCanvas);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=render-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/render-module.ts"],"names":[],"mappings":"","file":"render-module.js","sourcesContent":["// import { Container } from 'inversify';\n// import roughModule from './rough/module';\n\n// export default function load(container: Container) {\n// container.load(roughModule);\n// }\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const defaultRouthThemeSpec = {
|
|
2
|
+
maxRandomnessOffset: 3,
|
|
3
|
+
roughness: 1,
|
|
4
|
+
bowing: 1,
|
|
5
|
+
curveFitting: .95,
|
|
6
|
+
curveTightness: void 0,
|
|
7
|
+
curveStepCount: 9,
|
|
8
|
+
fillStyle: "hachure",
|
|
9
|
+
fillWeight: void 0,
|
|
10
|
+
hachureAngle: 60,
|
|
11
|
+
hachureGap: 6,
|
|
12
|
+
simplification: 0,
|
|
13
|
+
dashOffset: void 0,
|
|
14
|
+
dashGap: void 0,
|
|
15
|
+
zigzagOffset: void 0,
|
|
16
|
+
seed: 1,
|
|
17
|
+
fillLineDash: void 0,
|
|
18
|
+
fillLineDashOffset: void 0,
|
|
19
|
+
disableMultiStroke: !1,
|
|
20
|
+
disableMultiStrokeFill: !1,
|
|
21
|
+
preserveVertices: !0,
|
|
22
|
+
fixedDecimalPlaceDigits: void 0
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/rough/config.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,qBAAqB,GAAY;IAC5C,mBAAmB,EAAE,CAAC;IAEtB,SAAS,EAAE,CAAC;IAEZ,MAAM,EAAE,CAAC;IAET,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,SAAS;IAEzB,cAAc,EAAE,CAAC;IAEjB,SAAS,EAAE,SAAS;IAEpB,UAAU,EAAE,SAAS;IAErB,YAAY,EAAE,EAAE;IAEhB,UAAU,EAAE,CAAC;IAEb,cAAc,EAAE,CAAC;IACjB,UAAU,EAAE,SAAS;IACrB,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,SAAS;IAEvB,IAAI,EAAE,CAAC;IACP,YAAY,EAAE,SAAS;IACvB,kBAAkB,EAAE,SAAS;IAE7B,kBAAkB,EAAE,KAAK;IACzB,sBAAsB,EAAE,KAAK;IAC7B,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,SAAS;CACnC,CAAC","file":"config.js","sourcesContent":["import type { Options } from 'roughjs/bin/core';\n\nexport const defaultRouthThemeSpec: Options = {\n maxRandomnessOffset: 3,\n // 粗糙度,值越大绘制的越乱\n roughness: 1,\n // 线段的弯曲度\n bowing: 1,\n // 曲线拟合程度\n curveFitting: 0.95,\n curveTightness: undefined,\n // 近似曲线的点数\n curveStepCount: 9,\n // 填充形式,默认斜线\n fillStyle: 'hachure',\n // 填充线的粗细、填充点的大小\n fillWeight: undefined,\n // 填充为hachure时的转角\n hachureAngle: 60,\n // 填充为hachure时线段间的间隙\n hachureGap: 6,\n // 是否简化线段\n simplification: 0,\n dashOffset: undefined,\n dashGap: undefined,\n zigzagOffset: undefined,\n // 生成随机形状的种子\n seed: 1,\n fillLineDash: undefined,\n fillLineDashOffset: undefined,\n // 禁止用多个笔画绘制\n disableMultiStroke: false,\n disableMultiStrokeFill: false,\n preserveVertices: true,\n fixedDecimalPlaceDigits: undefined\n};\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GraphicRender } from "@visactor/vrender";
|
|
2
|
+
|
|
3
|
+
import { ContainerModule } from "inversify";
|
|
4
|
+
|
|
5
|
+
import { RoughCanvasArcRender } from "./rough-arc";
|
|
6
|
+
|
|
7
|
+
import { RoughCanvasAreaRender } from "./rough-area";
|
|
8
|
+
|
|
9
|
+
import { RoughCanvasCircleRender } from "./rough-circle";
|
|
10
|
+
|
|
11
|
+
import { RoughCanvasLineRender } from "./rough-line";
|
|
12
|
+
|
|
13
|
+
import { RoughCanvasPathRender } from "./rough-path";
|
|
14
|
+
|
|
15
|
+
import { RoughCanvasRectRender } from "./rough-rect";
|
|
16
|
+
|
|
17
|
+
import { RoughCanvasSymbolRender } from "./rough-symbol";
|
|
18
|
+
|
|
19
|
+
export default new ContainerModule(((bind, unbind, isBound, rebind) => {
|
|
20
|
+
bind(RoughCanvasCircleRender).toSelf().inSingletonScope(), bind(GraphicRender).to(RoughCanvasCircleRender),
|
|
21
|
+
bind(RoughCanvasRectRender).toSelf().inSingletonScope(), bind(GraphicRender).to(RoughCanvasRectRender),
|
|
22
|
+
bind(RoughCanvasPathRender).toSelf().inSingletonScope(), bind(GraphicRender).to(RoughCanvasPathRender),
|
|
23
|
+
bind(RoughCanvasSymbolRender).toSelf().inSingletonScope(), bind(GraphicRender).to(RoughCanvasSymbolRender),
|
|
24
|
+
bind(RoughCanvasLineRender).toSelf().inSingletonScope(), bind(GraphicRender).to(RoughCanvasLineRender),
|
|
25
|
+
bind(RoughCanvasAreaRender).toSelf().inSingletonScope(), bind(GraphicRender).to(RoughCanvasAreaRender),
|
|
26
|
+
bind(RoughCanvasArcRender).toSelf().inSingletonScope(), bind(GraphicRender).to(RoughCanvasArcRender);
|
|
27
|
+
}));
|
|
28
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/rough/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,eAAe,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAEnE,IAAI,CAAC,uBAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC1D,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC;IAGhD,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACxD,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAG9C,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACxD,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAG9C,IAAI,CAAC,uBAAuB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC1D,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC;IAGhD,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACxD,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAG9C,IAAI,CAAC,qBAAqB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACxD,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC;IAG9C,IAAI,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACvD,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC","file":"module.js","sourcesContent":["import { CircleRender, PathRender, RectRender, GraphicRender } from '@visactor/vrender';\nimport { ContainerModule } from 'inversify';\nimport { RoughCanvasArcRender } from './rough-arc';\nimport { RoughCanvasAreaRender } from './rough-area';\nimport { RoughCanvasCircleRender } from './rough-circle';\nimport { RoughCanvasLineRender } from './rough-line';\nimport { RoughCanvasPathRender } from './rough-path';\nimport { RoughCanvasRectRender } from './rough-rect';\nimport { RoughCanvasSymbolRender } from './rough-symbol';\n\nexport default new ContainerModule((bind, unbind, isBound, rebind) => {\n // circle\n bind(RoughCanvasCircleRender).toSelf().inSingletonScope();\n bind(GraphicRender).to(RoughCanvasCircleRender);\n\n // rect\n bind(RoughCanvasRectRender).toSelf().inSingletonScope();\n bind(GraphicRender).to(RoughCanvasRectRender);\n\n // path\n bind(RoughCanvasPathRender).toSelf().inSingletonScope();\n bind(GraphicRender).to(RoughCanvasPathRender);\n\n // symbol\n bind(RoughCanvasSymbolRender).toSelf().inSingletonScope();\n bind(GraphicRender).to(RoughCanvasSymbolRender);\n\n // line\n bind(RoughCanvasLineRender).toSelf().inSingletonScope();\n bind(GraphicRender).to(RoughCanvasLineRender);\n\n // area\n bind(RoughCanvasAreaRender).toSelf().inSingletonScope();\n bind(GraphicRender).to(RoughCanvasAreaRender);\n\n // area\n bind(RoughCanvasArcRender).toSelf().inSingletonScope();\n bind(GraphicRender).to(RoughCanvasArcRender);\n});\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IGraphicRender, IRenderService, IArc, IGraphicAttribute, IContext2d, IGraphic, IMarkAttribute, IThemeAttribute, IDrawContext, IGraphicRenderDrawParams } from '@visactor/vrender';
|
|
2
|
+
export declare class RoughCanvasArcRender implements IGraphicRender {
|
|
3
|
+
readonly canvasRenderer: IGraphicRender;
|
|
4
|
+
type: 'arc';
|
|
5
|
+
numberType: number;
|
|
6
|
+
style: 'rough';
|
|
7
|
+
constructor(canvasRenderer: IGraphicRender);
|
|
8
|
+
draw(arc: IArc, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
|
|
9
|
+
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;
|
|
10
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
2
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
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
|
+
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
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
import { inject, injectable } from "inversify";
|
|
14
|
+
|
|
15
|
+
import { ARC_NUMBER_TYPE, DefaultCanvasArcRender, getTheme, CustomPath2D, drawArcPath } from "@visactor/vrender";
|
|
16
|
+
|
|
17
|
+
import rough from "roughjs";
|
|
18
|
+
|
|
19
|
+
import { defaultRouthThemeSpec } from "./config";
|
|
20
|
+
|
|
21
|
+
let RoughCanvasArcRender = class {
|
|
22
|
+
constructor(canvasRenderer) {
|
|
23
|
+
this.canvasRenderer = canvasRenderer, this.style = "rough", this.type = "arc", this.numberType = ARC_NUMBER_TYPE;
|
|
24
|
+
}
|
|
25
|
+
draw(arc, renderService, drawContext, params) {
|
|
26
|
+
const {context: context} = drawContext;
|
|
27
|
+
if (!context) return;
|
|
28
|
+
const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas);
|
|
29
|
+
context.highPerformanceSave();
|
|
30
|
+
const arcAttribute = getTheme(arc).arc;
|
|
31
|
+
let {x: x = arcAttribute.x, y: y = arcAttribute.y} = arc.attribute;
|
|
32
|
+
if (arc.transMatrix.onlyTranslate()) {
|
|
33
|
+
const {dx: dx = arcAttribute.dx, dy: dy = arcAttribute.dy} = arc.attribute;
|
|
34
|
+
x += dx, y += dy, context.setTransformForCurrent();
|
|
35
|
+
} else x = 0, y = 0, context.transformFromMatrix(arc.transMatrix, !0);
|
|
36
|
+
const customPath = new CustomPath2D, {fill: fill = (null == arcAttribute.fill ? !!arc.attribute.fillColor : arcAttribute.fill), stroke: stroke = (null == arcAttribute.stroke ? !!arc.attribute.strokeColor : arcAttribute.stroke), fillColor: fillColor = arcAttribute.fillColor, strokeColor: strokeColor = arcAttribute.strokeColor, lineWidth: lineWidth = arcAttribute.lineWidth, outerRadius: outerRadius = arcAttribute.outerRadius, innerRadius: innerRadius = arcAttribute.innerRadius, 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} = arc.attribute;
|
|
37
|
+
drawArcPath(arc, customPath, x, y, outerRadius, innerRadius), rc.path(customPath.toString(), {
|
|
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);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
RoughCanvasArcRender = __decorate([ injectable(), __param(0, inject(DefaultCanvasArcRender)), __metadata("design:paramtypes", [ Object ]) ], RoughCanvasArcRender);
|
|
70
|
+
|
|
71
|
+
export { RoughCanvasArcRender };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/rough/rough-arc.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAa/C,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACjH,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;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,eAAe,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,OAAO;SACR;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;QAC3C,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEhC,OAAO,CAAC,mBAAmB,EAAE,CAAC;QAG9B,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;QACvC,IAAI,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,YAAY,C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AChB,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;AA/HY,oBAAoB;IADhC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,sBAAsB,CAAC,CAAA;;GANtB,oBAAoB,CA+HhC;SA/HY,oBAAoB","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 == null ? !!arc.attribute.fillColor : arcAttribute.fill,\n stroke = arcAttribute.stroke == null ? !!arc.attribute.strokeColor : arcAttribute.stroke,\n fillColor = arcAttribute.fillColor,\n strokeColor = arcAttribute.strokeColor,\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 ? (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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IGraphicRender, IAreaCacheItem, IContext2d, IMarkAttribute, IThemeAttribute, IGraphicAttribute, IArea, IAreaGraphicAttribute } from '@visactor/vrender';
|
|
2
|
+
import { DefaultCanvasAreaRender } from '@visactor/vrender';
|
|
3
|
+
export declare class RoughCanvasAreaRender extends DefaultCanvasAreaRender implements IGraphicRender {
|
|
4
|
+
type: 'area';
|
|
5
|
+
numberType: number;
|
|
6
|
+
style: 'rough';
|
|
7
|
+
protected drawSegmentItem(context: IContext2d, cache: IAreaCacheItem, fill: boolean, fillOpacity: number, attribute: Partial<IAreaGraphicAttribute>, defaultAttribute: Required<IAreaGraphicAttribute> | Partial<IAreaGraphicAttribute>[], clipRange: number, offsetX: number, offsetY: number, offsetZ: number, area: IArea, fillCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute | IThemeAttribute[]) => boolean): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
2
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
import { injectable } from "inversify";
|
|
8
|
+
|
|
9
|
+
import { drawAreaSegments, DefaultCanvasAreaRender, CustomPath2D } from "@visactor/vrender";
|
|
10
|
+
|
|
11
|
+
import rough from "roughjs";
|
|
12
|
+
|
|
13
|
+
import { defaultRouthThemeSpec } from "./config";
|
|
14
|
+
|
|
15
|
+
let RoughCanvasAreaRender = class extends DefaultCanvasAreaRender {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments), this.style = "rough";
|
|
18
|
+
}
|
|
19
|
+
drawSegmentItem(context, cache, fill, fillOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, fillCb) {
|
|
20
|
+
if (fillCb) return super.drawSegmentItem(context, cache, fill, fillOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, fillCb);
|
|
21
|
+
context.highPerformanceSave();
|
|
22
|
+
const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas, {}), customPath = new CustomPath2D;
|
|
23
|
+
drawAreaSegments(customPath, cache, clipRange, {
|
|
24
|
+
offsetX: offsetX,
|
|
25
|
+
offsetY: offsetY
|
|
26
|
+
});
|
|
27
|
+
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;
|
|
28
|
+
let {fillColor: fillColor, strokeColor: strokeColor, lineWidth: lineWidth} = attribute;
|
|
29
|
+
return Array.isArray(defaultAttribute) ? defaultAttribute.forEach((item => {
|
|
30
|
+
fillColor = null != fillColor ? fillColor : item.fillColor, strokeColor = null != strokeColor ? strokeColor : item.strokeColor,
|
|
31
|
+
lineWidth = null != lineWidth ? lineWidth : item.lineWidth;
|
|
32
|
+
})) : (fillColor = null != fillColor ? fillColor : defaultAttribute.fillColor, strokeColor = null != strokeColor ? strokeColor : defaultAttribute.strokeColor,
|
|
33
|
+
lineWidth = null != lineWidth ? lineWidth : defaultAttribute.lineWidth), rc.path(customPath.toString(), {
|
|
34
|
+
fill: fill ? fillColor : void 0,
|
|
35
|
+
strokeWidth: lineWidth,
|
|
36
|
+
maxRandomnessOffset: maxRandomnessOffset,
|
|
37
|
+
roughness: roughness,
|
|
38
|
+
bowing: bowing,
|
|
39
|
+
curveFitting: curveFitting,
|
|
40
|
+
curveTightness: curveTightness,
|
|
41
|
+
curveStepCount: curveStepCount,
|
|
42
|
+
fillStyle: fillStyle,
|
|
43
|
+
fillWeight: fillWeight,
|
|
44
|
+
hachureAngle: hachureAngle,
|
|
45
|
+
hachureGap: hachureGap,
|
|
46
|
+
simplification: simplification,
|
|
47
|
+
dashOffset: dashOffset,
|
|
48
|
+
dashGap: dashGap,
|
|
49
|
+
zigzagOffset: zigzagOffset,
|
|
50
|
+
seed: seed,
|
|
51
|
+
fillLineDash: fillLineDash,
|
|
52
|
+
fillLineDashOffset: fillLineDashOffset,
|
|
53
|
+
disableMultiStroke: disableMultiStroke,
|
|
54
|
+
disableMultiStrokeFill: disableMultiStrokeFill,
|
|
55
|
+
preserveVertices: preserveVertices,
|
|
56
|
+
fixedDecimalPlaceDigits: fixedDecimalPlaceDigits
|
|
57
|
+
}), context.highPerformanceRestore(), !1;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
RoughCanvasAreaRender = __decorate([ injectable() ], RoughCanvasAreaRender);
|
|
62
|
+
|
|
63
|
+
export { RoughCanvasAreaRender };
|
|
64
|
+
//# sourceMappingURL=rough-area.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/rough/rough-area.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAW/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AAW,CAAC;YAC1D,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,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;AAtIY,qBAAqB;IADjC,UAAU,EAAE;GACA,qBAAqB,CAsIjC;SAtIY,qBAAqB","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 { fillColor, strokeColor, lineWidth } = attribute;\n\n if (Array.isArray(defaultAttribute)) {\n defaultAttribute.forEach(item => {\n fillColor = fillColor ?? item.fillColor;\n strokeColor = strokeColor ?? item.strokeColor;\n lineWidth = lineWidth ?? item.lineWidth;\n });\n } else {\n fillColor = fillColor ?? defaultAttribute.fillColor;\n strokeColor = strokeColor ?? defaultAttribute.strokeColor;\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"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IGraphicRender, IRenderService, IGraphic, ICircle, IContext2d, IMarkAttribute, IThemeAttribute, IGraphicAttribute, IDrawContext, IGraphicRenderDrawParams } from '@visactor/vrender';
|
|
2
|
+
export declare class RoughCanvasCircleRender implements IGraphicRender {
|
|
3
|
+
readonly canvasRenderer: IGraphicRender;
|
|
4
|
+
type: 'circle';
|
|
5
|
+
numberType: number;
|
|
6
|
+
style: 'rough';
|
|
7
|
+
constructor(canvasRenderer: IGraphicRender);
|
|
8
|
+
draw(circle: ICircle, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
|
|
9
|
+
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;
|
|
10
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
2
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
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
|
+
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
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
import { inject, injectable } from "inversify";
|
|
14
|
+
|
|
15
|
+
import { CIRCLE_NUMBER_TYPE, DefaultCanvasCircleRender, getTheme } from "@visactor/vrender";
|
|
16
|
+
|
|
17
|
+
import rough from "roughjs";
|
|
18
|
+
|
|
19
|
+
let RoughCanvasCircleRender = class {
|
|
20
|
+
constructor(canvasRenderer) {
|
|
21
|
+
this.canvasRenderer = canvasRenderer, this.style = "rough", this.type = "circle",
|
|
22
|
+
this.numberType = CIRCLE_NUMBER_TYPE;
|
|
23
|
+
}
|
|
24
|
+
draw(circle, renderService, drawContext, params) {
|
|
25
|
+
const {context: context} = drawContext;
|
|
26
|
+
if (!context) return;
|
|
27
|
+
const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas, {}), circleAttribute = getTheme(circle).circle;
|
|
28
|
+
let {x: x = circleAttribute.x, y: y = circleAttribute.y} = circle.attribute;
|
|
29
|
+
circle.transMatrix.onlyTranslate() ? context.onlyTranslate() || context.clearMatrix() : (x = 0,
|
|
30
|
+
y = 0, context.transformFromMatrix(circle.transMatrix, !0));
|
|
31
|
+
const {fillColor: fillColor = circleAttribute.fillColor, strokeColor: strokeColor = circleAttribute.strokeColor, radius: radius = circleAttribute.radius, fill: fill = circleAttribute.fill, stroke: stroke = circleAttribute.stroke, lineWidth: lineWidth = circleAttribute.lineWidth} = circle.attribute;
|
|
32
|
+
rc.circle(x, y, radius, {
|
|
33
|
+
fill: fill ? fillColor : void 0,
|
|
34
|
+
stroke: stroke ? strokeColor : void 0,
|
|
35
|
+
strokeWidth: lineWidth,
|
|
36
|
+
fillStyle: "zigzag",
|
|
37
|
+
roughness: .5
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb) {
|
|
41
|
+
if (this.canvasRenderer.drawShape) return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
RoughCanvasCircleRender = __decorate([ injectable(), __param(0, inject(DefaultCanvasCircleRender)), __metadata("design:paramtypes", [ Object ]) ], RoughCanvasCircleRender);
|
|
46
|
+
|
|
47
|
+
export { RoughCanvasCircleRender };
|
|
48
|
+
//# sourceMappingURL=rough-circle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/rough/rough-circle.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAa/C,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,QAAQ,EAAE,MAAM,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AAG,eAAe,CAAC,MAAM,EAC/B,SAAS,GAAG,eAAe,CAAC,SAAS,EACtC,GAAG,MAAM,CAAC,SAAS,CAAC;QACrB,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE;YACtB,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,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;AA1EY,uBAAuB;IADnC,UAAU,EAAE;IAOR,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;;GANzB,uBAAuB,CA0EnC;SA1EY,uBAAuB","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 fillColor = circleAttribute.fillColor,\n strokeColor = circleAttribute.strokeColor,\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 ? (fillColor as string) : undefined,\n stroke: stroke ? (strokeColor 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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IGraphicRender, IContext2d, IMarkAttribute, IThemeAttribute, IGraphicAttribute, ISegPath2D, ILine, ILineGraphicAttribute, IClipRangeByDimensionType } from '@visactor/vrender';
|
|
2
|
+
import { DefaultCanvasLineRender } from '@visactor/vrender';
|
|
3
|
+
export declare class RoughCanvasLineRender extends DefaultCanvasLineRender implements IGraphicRender {
|
|
4
|
+
type: 'line';
|
|
5
|
+
numberType: number;
|
|
6
|
+
style: 'rough';
|
|
7
|
+
protected drawSegmentItem(context: IContext2d, cache: ISegPath2D, fill: boolean, stroke: boolean, fillOpacity: number, strokeOpacity: number, attribute: Partial<ILineGraphicAttribute>, defaultAttribute: Required<ILineGraphicAttribute> | Partial<ILineGraphicAttribute>[], clipRange: number, clipRangeByDimension: IClipRangeByDimensionType, offsetX: number, offsetY: number, line: ILine, fillCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute | IThemeAttribute[]) => boolean, strokeCb?: (ctx: IContext2d, lineAttribute: Partial<IMarkAttribute & IGraphicAttribute>, themeAttribute: IThemeAttribute | IThemeAttribute[]) => boolean): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
2
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
import { injectable } from "inversify";
|
|
8
|
+
|
|
9
|
+
import { DefaultCanvasLineRender, CustomPath2D, drawSegments } from "@visactor/vrender";
|
|
10
|
+
|
|
11
|
+
import rough from "roughjs";
|
|
12
|
+
|
|
13
|
+
import { defaultRouthThemeSpec } from "./config";
|
|
14
|
+
|
|
15
|
+
let RoughCanvasLineRender = class extends DefaultCanvasLineRender {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments), this.style = "rough";
|
|
18
|
+
}
|
|
19
|
+
drawSegmentItem(context, cache, fill, stroke, fillOpacity, strokeOpacity, attribute, defaultAttribute, clipRange, clipRangeByDimension, offsetX, offsetY, line, fillCb, strokeCb) {
|
|
20
|
+
if (fillCb || strokeCb) return super.drawSegmentItem(context, cache, fill, stroke, fillOpacity, strokeOpacity, attribute, defaultAttribute, clipRange, clipRangeByDimension, offsetX, offsetY, line, fillCb, strokeCb);
|
|
21
|
+
context.highPerformanceSave();
|
|
22
|
+
const canvas = context.canvas.nativeCanvas, rc = rough.canvas(canvas, {}), customPath = new CustomPath2D;
|
|
23
|
+
drawSegments(context.camera ? context : context.nativeContext, cache, clipRange, clipRangeByDimension, {
|
|
24
|
+
offsetX: offsetX,
|
|
25
|
+
offsetY: offsetY
|
|
26
|
+
});
|
|
27
|
+
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;
|
|
28
|
+
let {fillColor: fillColor, strokeColor: strokeColor, lineWidth: lineWidth} = attribute;
|
|
29
|
+
return Array.isArray(defaultAttribute) ? defaultAttribute.forEach((item => {
|
|
30
|
+
fillColor = null != fillColor ? fillColor : item.fillColor, strokeColor = null != strokeColor ? strokeColor : item.strokeColor,
|
|
31
|
+
lineWidth = null != lineWidth ? lineWidth : item.lineWidth;
|
|
32
|
+
})) : (fillColor = null != fillColor ? fillColor : defaultAttribute.fillColor, strokeColor = null != strokeColor ? strokeColor : defaultAttribute.strokeColor,
|
|
33
|
+
lineWidth = null != lineWidth ? lineWidth : defaultAttribute.lineWidth), rc.path(customPath.toString(), {
|
|
34
|
+
fill: fill ? fillColor : void 0,
|
|
35
|
+
stroke: stroke ? strokeColor : void 0,
|
|
36
|
+
strokeWidth: lineWidth,
|
|
37
|
+
maxRandomnessOffset: maxRandomnessOffset,
|
|
38
|
+
roughness: roughness,
|
|
39
|
+
bowing: bowing,
|
|
40
|
+
curveFitting: curveFitting,
|
|
41
|
+
curveTightness: curveTightness,
|
|
42
|
+
curveStepCount: curveStepCount,
|
|
43
|
+
fillStyle: fillStyle,
|
|
44
|
+
fillWeight: fillWeight,
|
|
45
|
+
hachureAngle: hachureAngle,
|
|
46
|
+
hachureGap: hachureGap,
|
|
47
|
+
simplification: simplification,
|
|
48
|
+
dashOffset: dashOffset,
|
|
49
|
+
dashGap: dashGap,
|
|
50
|
+
zigzagOffset: zigzagOffset,
|
|
51
|
+
seed: seed,
|
|
52
|
+
fillLineDash: fillLineDash,
|
|
53
|
+
fillLineDashOffset: fillLineDashOffset,
|
|
54
|
+
disableMultiStroke: disableMultiStroke,
|
|
55
|
+
disableMultiStrokeFill: disableMultiStrokeFill,
|
|
56
|
+
preserveVertices: preserveVertices,
|
|
57
|
+
fixedDecimalPlaceDigits: fixedDecimalPlaceDigits
|
|
58
|
+
}), context.highPerformanceRestore(), !1;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
RoughCanvasLineRender = __decorate([ injectable() ], RoughCanvasLineRender);
|
|
63
|
+
|
|
64
|
+
export { RoughCanvasLineRender };
|
|
65
|
+
//# sourceMappingURL=rough-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render/contributions/rough/rough-line.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAU,UAAU,EAAE,MAAM,WAAW,CAAC;AAY/C,OAAO,EAA4B,uBAAuB,EAAY,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5H,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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AAU;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,UAAU,EAAE;GACA,qBAAqB,CAgJjC;SAhJY,qBAAqB","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 { IRenderService, IGraphic, DefaultCanvasLineRender, getTheme, CustomPath2D, drawSegments } 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 { fillColor, strokeColor, lineWidth } = attribute;\n\n if (Array.isArray(defaultAttribute)) {\n defaultAttribute.forEach(item => {\n fillColor = fillColor ?? item.fillColor;\n strokeColor = strokeColor ?? item.strokeColor;\n lineWidth = lineWidth ?? item.lineWidth;\n });\n } else {\n fillColor = fillColor ?? defaultAttribute.fillColor;\n strokeColor = strokeColor ?? defaultAttribute.strokeColor;\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"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IGraphicRender, IRenderService, IGraphic, IContext2d, IMarkAttribute, IThemeAttribute, IGraphicAttribute, IPath, IDrawContext, IGraphicRenderDrawParams } from '@visactor/vrender';
|
|
2
|
+
export declare class RoughCanvasPathRender implements IGraphicRender {
|
|
3
|
+
readonly canvasRenderer: IGraphicRender;
|
|
4
|
+
type: 'path';
|
|
5
|
+
numberType: number;
|
|
6
|
+
style: 'rough';
|
|
7
|
+
constructor(canvasRenderer: IGraphicRender);
|
|
8
|
+
draw(path: IPath, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams): void;
|
|
9
|
+
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;
|
|
10
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
2
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
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
|
+
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
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
import { inject, injectable } from "inversify";
|
|
14
|
+
|
|
15
|
+
import { PATH_NUMBER_TYPE, DefaultCanvasPathRender, getTheme } from "@visactor/vrender";
|
|
16
|
+
|
|
17
|
+
import rough from "roughjs";
|
|
18
|
+
|
|
19
|
+
import { defaultRouthThemeSpec } from "./config";
|
|
20
|
+
|
|
21
|
+
let RoughCanvasPathRender = class {
|
|
22
|
+
constructor(canvasRenderer) {
|
|
23
|
+
this.canvasRenderer = canvasRenderer, this.style = "rough", this.type = "path",
|
|
24
|
+
this.numberType = PATH_NUMBER_TYPE;
|
|
25
|
+
}
|
|
26
|
+
draw(path, 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 pathAttribute = getTheme(path).path;
|
|
32
|
+
context.transformFromMatrix(path.transMatrix, !0);
|
|
33
|
+
const {fill: fill = (null == pathAttribute.fill ? !!path.attribute.fillColor : pathAttribute.fill), stroke: stroke = (null == pathAttribute.stroke ? !!path.attribute.strokeColor : pathAttribute.stroke), fillColor: fillColor = pathAttribute.fillColor, strokeColor: strokeColor = pathAttribute.strokeColor, lineWidth: lineWidth = pathAttribute.lineWidth, path: p = pathAttribute.path, 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} = path.attribute;
|
|
34
|
+
"string" == typeof p && rc.path(p, {
|
|
35
|
+
fill: fill ? fillColor : void 0,
|
|
36
|
+
stroke: stroke ? strokeColor : void 0,
|
|
37
|
+
strokeWidth: lineWidth,
|
|
38
|
+
maxRandomnessOffset: maxRandomnessOffset,
|
|
39
|
+
roughness: roughness,
|
|
40
|
+
bowing: bowing,
|
|
41
|
+
curveFitting: curveFitting,
|
|
42
|
+
curveTightness: curveTightness,
|
|
43
|
+
curveStepCount: curveStepCount,
|
|
44
|
+
fillStyle: fillStyle,
|
|
45
|
+
fillWeight: fillWeight,
|
|
46
|
+
hachureAngle: hachureAngle,
|
|
47
|
+
hachureGap: hachureGap,
|
|
48
|
+
simplification: simplification,
|
|
49
|
+
dashOffset: dashOffset,
|
|
50
|
+
dashGap: dashGap,
|
|
51
|
+
zigzagOffset: zigzagOffset,
|
|
52
|
+
seed: seed,
|
|
53
|
+
fillLineDash: fillLineDash,
|
|
54
|
+
fillLineDashOffset: fillLineDashOffset,
|
|
55
|
+
disableMultiStroke: disableMultiStroke,
|
|
56
|
+
disableMultiStrokeFill: disableMultiStrokeFill,
|
|
57
|
+
preserveVertices: preserveVertices,
|
|
58
|
+
fixedDecimalPlaceDigits: fixedDecimalPlaceDigits
|
|
59
|
+
}), context.highPerformanceRestore();
|
|
60
|
+
}
|
|
61
|
+
drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb) {
|
|
62
|
+
if (this.canvasRenderer.drawShape) return this.canvasRenderer.drawShape(graphic, ctx, x, y, drawContext, params, fillCb, strokeCb);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
RoughCanvasPathRender = __decorate([ injectable(), __param(0, inject(DefaultCanvasPathRender)), __metadata("design:paramtypes", [ Object ]) ], RoughCanvasPathRender);
|
|
67
|
+
|
|
68
|
+
export { RoughCanvasPathRender };
|
|
69
|
+
//# sourceMappingURL=rough-path.js.map
|