@visactor/vrender-core 0.17.19-alpha.1 → 0.18.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/cjs/common/canvas-utils.js +2 -2
- package/cjs/common/canvas-utils.js.map +1 -1
- package/cjs/common/render-area.js +15 -3
- package/cjs/common/render-area.js.map +1 -1
- package/cjs/common/render-curve.js +16 -4
- package/cjs/common/render-curve.js.map +1 -1
- package/cjs/common/segment/basis.js +3 -2
- package/cjs/common/segment/basis.js.map +1 -1
- package/cjs/common/segment/common.d.ts +1 -4
- package/cjs/common/segment/common.js +3 -13
- package/cjs/common/segment/common.js.map +1 -1
- package/cjs/common/segment/linear-closed.d.ts +16 -2
- package/cjs/common/segment/linear-closed.js +34 -3
- package/cjs/common/segment/linear-closed.js.map +1 -1
- package/cjs/common/segment/linear.d.ts +1 -1
- package/cjs/common/segment/linear.js +3 -2
- package/cjs/common/segment/linear.js.map +1 -1
- package/cjs/common/segment/monotone.d.ts +2 -2
- package/cjs/common/segment/monotone.js +12 -10
- package/cjs/common/segment/monotone.js.map +1 -1
- package/cjs/common/sort.js +1 -2
- package/cjs/common/split-path.js +2 -2
- package/cjs/common/split-path.js.map +1 -1
- package/cjs/core/application.js +1 -1
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/stage.js +1 -4
- package/cjs/core/stage.js.map +1 -1
- package/cjs/env-check.js +17 -17
- package/cjs/env-check.js.map +1 -1
- package/cjs/event/event-system.js +3 -3
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/graphic/arc.js +1 -1
- package/cjs/graphic/arc.js.map +1 -1
- package/cjs/graphic/arc3d.js +1 -1
- package/cjs/graphic/arc3d.js.map +1 -1
- package/cjs/graphic/area.js +1 -1
- package/cjs/graphic/area.js.map +1 -1
- package/cjs/graphic/bounds.d.ts +2 -2
- package/cjs/graphic/bounds.js +1 -1
- package/cjs/graphic/bounds.js.map +1 -1
- package/cjs/graphic/circle.js +1 -1
- package/cjs/graphic/circle.js.map +1 -1
- package/cjs/graphic/config.js +0 -4
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/glyph.js +1 -1
- package/cjs/graphic/glyph.js.map +1 -1
- package/cjs/graphic/graphic-service/graphic-service.js +11 -13
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/graphic/graphic.js +4 -5
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.js +1 -1
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/image.d.ts +1 -3
- package/cjs/graphic/image.js +1 -7
- package/cjs/graphic/image.js.map +1 -1
- package/cjs/graphic/line.js +1 -1
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/node-tree.js +1 -4
- package/cjs/graphic/node-tree.js.map +1 -1
- package/cjs/graphic/path.js +1 -1
- package/cjs/graphic/path.js.map +1 -1
- package/cjs/graphic/polygon.js +1 -1
- package/cjs/graphic/polygon.js.map +1 -1
- package/cjs/graphic/pyramid3d.js +1 -1
- package/cjs/graphic/pyramid3d.js.map +1 -1
- package/cjs/graphic/rect.js +7 -4
- package/cjs/graphic/rect.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +1 -1
- package/cjs/graphic/richtext.js +6 -10
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/symbol.js +1 -1
- package/cjs/graphic/symbol.js.map +1 -1
- package/cjs/graphic/text.js +4 -4
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/interface/event.d.ts +0 -2
- package/cjs/interface/event.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +1 -1
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic/symbol.d.ts +1 -1
- package/cjs/interface/graphic/symbol.js.map +1 -1
- package/cjs/interface/graphic.d.ts +1 -14
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/stage.d.ts +0 -4
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/modules.d.ts +0 -3
- package/cjs/modules.js +10 -9
- package/cjs/modules.js.map +1 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +7 -6
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +5 -5
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/arc-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/arc-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/area-contribution-render.d.ts +9 -1
- package/cjs/render/contributions/render/contributions/area-contribution-render.js +55 -3
- package/cjs/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +20 -2
- package/cjs/render/contributions/render/contributions/base-contribution-render.js +125 -25
- package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/circle-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/circle-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/group-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/image-contribution-render.js +2 -3
- package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/index.d.ts +0 -2
- package/cjs/render/contributions/render/contributions/index.js +1 -2
- package/cjs/render/contributions/render/contributions/index.js.map +1 -1
- package/cjs/render/contributions/render/contributions/path-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/path-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/path-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/polygon-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/polygon-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -1
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +2 -2
- package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/text-contribution-render.js +8 -23
- package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/cjs/render/contributions/render/draw-contribution.js +7 -6
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +2 -4
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/incremental-draw-contribution.d.ts +1 -0
- package/cjs/render/contributions/render/incremental-draw-contribution.js +5 -1
- package/cjs/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/index.d.ts +0 -1
- package/cjs/render/contributions/render/index.js +1 -2
- package/cjs/render/contributions/render/index.js.map +1 -1
- package/cjs/render/contributions/render/utils.d.ts +1 -1
- package/cjs/render/contributions/render/utils.js.map +1 -1
- package/cjs/resource-loader/loader.d.ts +0 -5
- package/cjs/resource-loader/loader.js +15 -56
- package/cjs/resource-loader/loader.js.map +1 -1
- package/dist/index.js +27707 -0
- package/dist/index.min.js +1 -0
- package/es/common/canvas-utils.js +1 -3
- package/es/common/canvas-utils.js.map +1 -1
- package/es/common/render-area.js +12 -2
- package/es/common/render-area.js.map +1 -1
- package/es/common/render-curve.js +15 -2
- package/es/common/render-curve.js.map +1 -1
- package/es/common/segment/basis.js +8 -2
- package/es/common/segment/basis.js.map +1 -1
- package/es/common/segment/common.d.ts +1 -4
- package/es/common/segment/common.js +0 -11
- package/es/common/segment/common.js.map +1 -1
- package/es/common/segment/linear-closed.d.ts +16 -2
- package/es/common/segment/linear-closed.js +38 -4
- package/es/common/segment/linear-closed.js.map +1 -1
- package/es/common/segment/linear.d.ts +1 -1
- package/es/common/segment/linear.js +8 -2
- package/es/common/segment/linear.js.map +1 -1
- package/es/common/segment/monotone.d.ts +2 -2
- package/es/common/segment/monotone.js +13 -7
- package/es/common/segment/monotone.js.map +1 -1
- package/es/common/sort.js +1 -2
- package/es/common/split-path.js +1 -3
- package/es/common/split-path.js.map +1 -1
- package/es/core/application.js +1 -1
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/stage.js +1 -4
- package/es/core/stage.js.map +1 -1
- package/es/env-check.js +13 -12
- package/es/env-check.js.map +1 -1
- package/es/event/event-system.js +3 -3
- package/es/event/event-system.js.map +1 -1
- package/es/graphic/arc.js +1 -1
- package/es/graphic/arc.js.map +1 -1
- package/es/graphic/arc3d.js +1 -1
- package/es/graphic/arc3d.js.map +1 -1
- package/es/graphic/area.js +1 -1
- package/es/graphic/area.js.map +1 -1
- package/es/graphic/bounds.d.ts +2 -2
- package/es/graphic/bounds.js +1 -1
- package/es/graphic/bounds.js.map +1 -1
- package/es/graphic/circle.js +1 -1
- package/es/graphic/circle.js.map +1 -1
- package/es/graphic/config.js +0 -4
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/glyph.js +1 -1
- package/es/graphic/glyph.js.map +1 -1
- package/es/graphic/graphic-service/graphic-service.js +11 -13
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/graphic/graphic.js +5 -6
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.js +1 -1
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/image.d.ts +1 -3
- package/es/graphic/image.js +1 -7
- package/es/graphic/image.js.map +1 -1
- package/es/graphic/line.js +1 -1
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/node-tree.js +1 -4
- package/es/graphic/node-tree.js.map +1 -1
- package/es/graphic/path.js +1 -1
- package/es/graphic/path.js.map +1 -1
- package/es/graphic/polygon.js +1 -1
- package/es/graphic/polygon.js.map +1 -1
- package/es/graphic/pyramid3d.js +1 -1
- package/es/graphic/pyramid3d.js.map +1 -1
- package/es/graphic/rect.js +7 -4
- package/es/graphic/rect.js.map +1 -1
- package/es/graphic/richtext.d.ts +1 -1
- package/es/graphic/richtext.js +5 -11
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/symbol.js +1 -1
- package/es/graphic/symbol.js.map +1 -1
- package/es/graphic/text.js +4 -4
- package/es/graphic/text.js.map +1 -1
- package/es/interface/event.d.ts +0 -2
- package/es/interface/event.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +1 -1
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic/symbol.d.ts +1 -1
- package/es/interface/graphic/symbol.js.map +1 -1
- package/es/interface/graphic.d.ts +1 -14
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/stage.d.ts +0 -4
- package/es/interface/stage.js.map +1 -1
- package/es/modules.d.ts +0 -3
- package/es/modules.js +6 -4
- package/es/modules.js.map +1 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.js +7 -6
- package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/es/render/contributions/render/area-render.js +5 -5
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/contributions/arc-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/arc-contribution-render.js +1 -3
- package/es/render/contributions/render/contributions/arc-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/area-contribution-render.d.ts +9 -1
- package/es/render/contributions/render/contributions/area-contribution-render.js +51 -2
- package/es/render/contributions/render/contributions/area-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/base-contribution-render.d.ts +20 -2
- package/es/render/contributions/render/contributions/base-contribution-render.js +123 -23
- package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/circle-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/circle-contribution-render.js +1 -3
- package/es/render/contributions/render/contributions/circle-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/group-contribution-render.js +2 -2
- package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/image-contribution-render.js +2 -3
- package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/index.d.ts +0 -2
- package/es/render/contributions/render/contributions/index.js +0 -4
- package/es/render/contributions/render/contributions/index.js.map +1 -1
- package/es/render/contributions/render/contributions/path-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/path-contribution-render.js +1 -3
- package/es/render/contributions/render/contributions/path-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/polygon-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/polygon-contribution-render.js +1 -3
- package/es/render/contributions/render/contributions/polygon-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/rect-contribution-render.js +1 -3
- package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +1 -1
- package/es/render/contributions/render/contributions/symbol-contribution-render.js +1 -3
- package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
- package/es/render/contributions/render/contributions/text-contribution-render.js +7 -28
- package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
- package/es/render/contributions/render/draw-contribution.js +7 -6
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/image-render.js +2 -6
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/incremental-draw-contribution.d.ts +1 -0
- package/es/render/contributions/render/incremental-draw-contribution.js +5 -1
- package/es/render/contributions/render/incremental-draw-contribution.js.map +1 -1
- package/es/render/contributions/render/index.d.ts +0 -1
- package/es/render/contributions/render/index.js +0 -2
- package/es/render/contributions/render/index.js.map +1 -1
- package/es/render/contributions/render/utils.d.ts +1 -1
- package/es/render/contributions/render/utils.js.map +1 -1
- package/es/resource-loader/loader.d.ts +0 -5
- package/es/resource-loader/loader.js +14 -56
- package/es/resource-loader/loader.js.map +1 -1
- package/package.json +4 -6
- package/cjs/common/color-utils.d.ts +0 -9
- package/cjs/common/color-utils.js +0 -231
- package/cjs/common/color-utils.js.map +0 -1
- package/cjs/common/rect-utils.d.ts +0 -7
- package/cjs/common/rect-utils.js +0 -27
- package/cjs/common/rect-utils.js.map +0 -1
- package/cjs/common/render-utils.d.ts +0 -10
- package/cjs/common/render-utils.js +0 -22
- package/cjs/common/render-utils.js.map +0 -1
- package/cjs/render/contributions/render/contributions/area-texture-contribution-render.d.ts +0 -9
- package/cjs/render/contributions/render/contributions/area-texture-contribution-render.js +0 -26
- package/cjs/render/contributions/render/contributions/area-texture-contribution-render.js.map +0 -1
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.d.ts +0 -21
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +0 -128
- package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +0 -1
- package/es/common/color-utils.d.ts +0 -9
- package/es/common/color-utils.js +0 -224
- package/es/common/color-utils.js.map +0 -1
- package/es/common/rect-utils.d.ts +0 -7
- package/es/common/rect-utils.js +0 -20
- package/es/common/rect-utils.js.map +0 -1
- package/es/common/render-utils.d.ts +0 -10
- package/es/common/render-utils.js +0 -14
- package/es/common/render-utils.js.map +0 -1
- package/es/render/contributions/render/contributions/area-texture-contribution-render.d.ts +0 -9
- package/es/render/contributions/render/contributions/area-texture-contribution-render.js +0 -18
- package/es/render/contributions/render/contributions/area-texture-contribution-render.js.map +0 -1
- package/es/render/contributions/render/contributions/base-texture-contribution-render.d.ts +0 -21
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js +0 -124
- package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +0 -1
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.GradientParser = void 0;
|
|
6
|
-
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), parse = function() {
|
|
8
|
-
const tokens = {
|
|
9
|
-
linearGradient: /^(linear\-gradient)/i,
|
|
10
|
-
radialGradient: /^(radial\-gradient)/i,
|
|
11
|
-
conicGradient: /^(conic\-gradient)/i,
|
|
12
|
-
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
|
13
|
-
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
|
14
|
-
positionKeywords: /^(left|center|right|top|bottom)/i,
|
|
15
|
-
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
|
16
|
-
percentageValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,
|
|
17
|
-
emValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,
|
|
18
|
-
angleValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
19
|
-
fromAngleValue: /^from\s*(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,
|
|
20
|
-
startCall: /^\(/,
|
|
21
|
-
endCall: /^\)/,
|
|
22
|
-
comma: /^,/,
|
|
23
|
-
hexColor: /(^\#[0-9a-fA-F]+)/,
|
|
24
|
-
literalColor: /^([a-zA-Z]+)/,
|
|
25
|
-
rgbColor: /^(rgb\(\d{1,3},\s*\d{1,3},\s*\d{1,3}\))/i,
|
|
26
|
-
rgbaColor: /^(rgba\(\d{1,3},\s*\d{1,3},\s*\d{1,3},\s*((\d\.\d+)|\d{1,3})\))/i,
|
|
27
|
-
number: /^(([0-9]*\.[0-9]+)|([0-9]+\.?))/
|
|
28
|
-
};
|
|
29
|
-
let input = "";
|
|
30
|
-
function error(msg) {
|
|
31
|
-
const err = new Error(input + ": " + msg);
|
|
32
|
-
throw err.source = input, err;
|
|
33
|
-
}
|
|
34
|
-
function getAST() {
|
|
35
|
-
const ast = matchListing(matchDefinition);
|
|
36
|
-
return input.length > 0 && error("Invalid input not EOF"), ast;
|
|
37
|
-
}
|
|
38
|
-
function matchDefinition() {
|
|
39
|
-
return matchGradient("linear", tokens.linearGradient, matchLinearOrientation) || matchGradient("radial", tokens.radialGradient, matchListRadialOrientations) || matchGradient("conic", tokens.conicGradient, matchConicalOrientation);
|
|
40
|
-
}
|
|
41
|
-
function matchGradient(gradientType, pattern, orientationMatcher) {
|
|
42
|
-
return function(pattern, callback) {
|
|
43
|
-
const captures = scan(pattern);
|
|
44
|
-
if (captures) {
|
|
45
|
-
scan(tokens.startCall) || error("Missing (");
|
|
46
|
-
const result = callback(captures);
|
|
47
|
-
return scan(tokens.endCall) || error("Missing )"), result;
|
|
48
|
-
}
|
|
49
|
-
}(pattern, (function(captures) {
|
|
50
|
-
const orientation = orientationMatcher();
|
|
51
|
-
return orientation && (scan(tokens.comma) || error("Missing comma before color stops")),
|
|
52
|
-
{
|
|
53
|
-
type: gradientType,
|
|
54
|
-
orientation: orientation,
|
|
55
|
-
colorStops: matchListing(matchColorStop)
|
|
56
|
-
};
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
function matchLinearOrientation() {
|
|
60
|
-
return match("directional", tokens.sideOrCorner, 1) || match("angular", tokens.angleValue, 1);
|
|
61
|
-
}
|
|
62
|
-
function matchConicalOrientation() {
|
|
63
|
-
return match("angular", tokens.fromAngleValue, 1);
|
|
64
|
-
}
|
|
65
|
-
function matchListRadialOrientations() {
|
|
66
|
-
let radialOrientations, lookaheadCache, radialOrientation = matchRadialOrientation();
|
|
67
|
-
return radialOrientation && (radialOrientations = [], radialOrientations.push(radialOrientation),
|
|
68
|
-
lookaheadCache = input, scan(tokens.comma) && (radialOrientation = matchRadialOrientation(),
|
|
69
|
-
radialOrientation ? radialOrientations.push(radialOrientation) : input = lookaheadCache)),
|
|
70
|
-
radialOrientations;
|
|
71
|
-
}
|
|
72
|
-
function matchRadialOrientation() {
|
|
73
|
-
let radialType = function() {
|
|
74
|
-
const circle = match("shape", /^(circle)/i, 0);
|
|
75
|
-
circle && (circle.style = matchLength() || matchExtentKeyword());
|
|
76
|
-
return circle;
|
|
77
|
-
}() || function() {
|
|
78
|
-
const ellipse = match("shape", /^(ellipse)/i, 0);
|
|
79
|
-
ellipse && (ellipse.style = matchDistance() || matchExtentKeyword());
|
|
80
|
-
return ellipse;
|
|
81
|
-
}();
|
|
82
|
-
if (radialType) radialType.at = matchAtPosition(); else {
|
|
83
|
-
const extent = matchExtentKeyword();
|
|
84
|
-
if (extent) {
|
|
85
|
-
radialType = extent;
|
|
86
|
-
const positionAt = matchAtPosition();
|
|
87
|
-
positionAt && (radialType.at = positionAt);
|
|
88
|
-
} else {
|
|
89
|
-
const defaultPosition = matchPositioning();
|
|
90
|
-
defaultPosition && (radialType = {
|
|
91
|
-
type: "default-radial",
|
|
92
|
-
at: defaultPosition
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return radialType;
|
|
97
|
-
}
|
|
98
|
-
function matchExtentKeyword() {
|
|
99
|
-
return match("extent-keyword", tokens.extentKeywords, 1);
|
|
100
|
-
}
|
|
101
|
-
function matchAtPosition() {
|
|
102
|
-
if (match("position", /^at/, 0)) {
|
|
103
|
-
const positioning = matchPositioning();
|
|
104
|
-
return positioning || error("Missing positioning value"), positioning;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function matchPositioning() {
|
|
108
|
-
const location = {
|
|
109
|
-
x: matchDistance(),
|
|
110
|
-
y: matchDistance()
|
|
111
|
-
};
|
|
112
|
-
if (location.x || location.y) return {
|
|
113
|
-
type: "position",
|
|
114
|
-
value: location
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
function matchListing(matcher) {
|
|
118
|
-
let captures = matcher();
|
|
119
|
-
const result = [];
|
|
120
|
-
if (captures) for (result.push(captures); scan(tokens.comma); ) captures = matcher(),
|
|
121
|
-
captures ? result.push(captures) : error("One extra comma");
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
function matchColorStop() {
|
|
125
|
-
const color = match("hex", tokens.hexColor, 1) || match("rgba", tokens.rgbaColor, 1) || match("rgb", tokens.rgbColor, 1) || match("literal", tokens.literalColor, 0);
|
|
126
|
-
return color || error("Expected color definition"), color.length = matchDistance(),
|
|
127
|
-
color;
|
|
128
|
-
}
|
|
129
|
-
function matchDistance() {
|
|
130
|
-
return match("%", tokens.percentageValue, 1) || match("position-keyword", tokens.positionKeywords, 1) || matchLength();
|
|
131
|
-
}
|
|
132
|
-
function matchLength() {
|
|
133
|
-
return match("px", tokens.pixelValue, 1) || match("em", tokens.emValue, 1);
|
|
134
|
-
}
|
|
135
|
-
function match(type, pattern, captureIndex) {
|
|
136
|
-
const captures = scan(pattern);
|
|
137
|
-
if (captures) return {
|
|
138
|
-
type: type,
|
|
139
|
-
value: captures[captureIndex]
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function scan(regexp) {
|
|
143
|
-
const blankCaptures = /^[\n\r\t\s]+/.exec(input);
|
|
144
|
-
blankCaptures && consume(blankCaptures[0].length);
|
|
145
|
-
const captures = regexp.exec(input);
|
|
146
|
-
return captures && consume(captures[0].length), captures;
|
|
147
|
-
}
|
|
148
|
-
function consume(size) {
|
|
149
|
-
input = input.substr(size);
|
|
150
|
-
}
|
|
151
|
-
return function(code) {
|
|
152
|
-
return input = code.toString(), getAST();
|
|
153
|
-
};
|
|
154
|
-
}();
|
|
155
|
-
|
|
156
|
-
class GradientParser {
|
|
157
|
-
static IsGradient(c) {
|
|
158
|
-
return !("string" == typeof c && c.length < 10);
|
|
159
|
-
}
|
|
160
|
-
static IsGradientStr(c) {
|
|
161
|
-
return "string" == typeof c && c.length > 10;
|
|
162
|
-
}
|
|
163
|
-
static Parse(c) {
|
|
164
|
-
if (GradientParser.IsGradientStr(c)) try {
|
|
165
|
-
const datum = parse(c)[0];
|
|
166
|
-
if (datum) {
|
|
167
|
-
if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
|
|
168
|
-
if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
|
|
169
|
-
if ("conic" === datum.type) return GradientParser.ParseConic(datum);
|
|
170
|
-
}
|
|
171
|
-
} catch (err) {
|
|
172
|
-
return c;
|
|
173
|
-
}
|
|
174
|
-
return c;
|
|
175
|
-
}
|
|
176
|
-
static ParseConic(datum) {
|
|
177
|
-
const {orientation: orientation, colorStops: colorStops = []} = datum, halfPi = vutils_1.pi / 2, sa = parseFloat(orientation.value) / 180 * vutils_1.pi - halfPi;
|
|
178
|
-
return {
|
|
179
|
-
gradient: "conical",
|
|
180
|
-
x: .5,
|
|
181
|
-
y: .5,
|
|
182
|
-
startAngle: sa,
|
|
183
|
-
endAngle: sa + vutils_1.pi2,
|
|
184
|
-
stops: colorStops.map((item => ({
|
|
185
|
-
color: item.value,
|
|
186
|
-
offset: parseFloat(item.length.value) / 100
|
|
187
|
-
})))
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
static ParseRadial(datum) {
|
|
191
|
-
const {colorStops: colorStops = []} = datum;
|
|
192
|
-
return {
|
|
193
|
-
gradient: "radial",
|
|
194
|
-
x0: .5,
|
|
195
|
-
y0: .5,
|
|
196
|
-
x1: .5,
|
|
197
|
-
y1: .5,
|
|
198
|
-
r0: 0,
|
|
199
|
-
r1: 1,
|
|
200
|
-
stops: colorStops.map((item => ({
|
|
201
|
-
color: item.value,
|
|
202
|
-
offset: parseFloat(item.length.value) / 100
|
|
203
|
-
})))
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
static ParseLinear(datum) {
|
|
207
|
-
const {orientation: orientation, colorStops: colorStops = []} = datum, halfPi = vutils_1.pi / 2;
|
|
208
|
-
let angle = "angular" === orientation.type ? parseFloat(orientation.value) / 180 * vutils_1.pi : 0;
|
|
209
|
-
for (;angle < 0; ) angle += vutils_1.pi2;
|
|
210
|
-
for (;angle > vutils_1.pi2; ) angle -= vutils_1.pi2;
|
|
211
|
-
let x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
|
212
|
-
return angle < halfPi ? (x0 = 0, y0 = 1, x1 = Math.sin(angle), y1 = Math.cos(angle)) : angle < vutils_1.pi ? (x0 = 0,
|
|
213
|
-
y0 = 0, x1 = Math.cos(angle - halfPi), y1 = Math.sin(angle - halfPi)) : angle < vutils_1.pi + halfPi ? (x0 = 1,
|
|
214
|
-
y0 = 0, x1 = x0 - Math.sin(angle - vutils_1.pi), y1 = Math.cos(angle - vutils_1.pi)) : (x0 = 1,
|
|
215
|
-
x1 = x0 - Math.cos(angle - halfPi - vutils_1.pi), y1 -= Math.sin(angle - halfPi - vutils_1.pi)),
|
|
216
|
-
{
|
|
217
|
-
gradient: "linear",
|
|
218
|
-
x0: x0,
|
|
219
|
-
y0: y0,
|
|
220
|
-
x1: x1,
|
|
221
|
-
y1: y1,
|
|
222
|
-
stops: colorStops.map((item => ({
|
|
223
|
-
color: item.value,
|
|
224
|
-
offset: parseFloat(item.length.value) / 100
|
|
225
|
-
})))
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
exports.GradientParser = GradientParser;
|
|
231
|
-
//# sourceMappingURL=color-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/color-utils.ts"],"names":[],"mappings":";;;AA4BA,6CAA2C;AAK3C,MAAM,KAAK,GAAG,CAAC;IACb,MAAM,MAAM,GAAG;QACb,cAAc,EAAE,sBAAsB;QACtC,cAAc,EAAE,sBAAsB;QACtC,aAAa,EAAE,qBAAqB;QACpC,YAAY,EACV,wGAAwG;QAC1G,cAAc,EAAE,gFAAgF;QAChG,gBAAgB,EAAE,kCAAkC;QACpD,UAAU,EAAE,uCAAuC;QACnD,eAAe,EAAE,uCAAuC;QACx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E,CAAC,CAAC;SACzC;QACD,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,EAAE;YACF,EAAE;YACF,EAAE;YACF,EAAE;YACF,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE;gBAClC,OAAO;oBACL,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG;iBAC5C,CAAC;YACJ,CAAC,CAAC;SACH,CAAC;IACJ,CAAC;CACF;AAlHD,wCAkHC","file":"color-utils.js","sourcesContent":["// 解析字符串gradient-color\n/**\n * The MIT License (MIT)\n\n Copyright (c) 2014 Rafael Carício\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n */\n// Copyright (c) 2014 Rafael Caricio. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport { pi, pi2 } from '@visactor/vutils';\nimport type { IColor, IConicalGradient, ILinearGradient, IRadialGradient } from '../interface';\n\n// @ts-ignore\n\nconst parse = (function () {\n const tokens = {\n linearGradient: /^(linear\\-gradient)/i,\n radialGradient: /^(radial\\-gradient)/i,\n conicGradient: /^(conic\\-gradient)/i,\n sideOrCorner:\n /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,\n extentKeywords: /^(closest\\-side|closest\\-corner|farthest\\-side|farthest\\-corner|contain|cover)/,\n positionKeywords: /^(left|center|right|top|bottom)/i,\n pixelValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))px/,\n percentageValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))\\%/,\n emValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))em/,\n angleValue: /^(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n fromAngleValue: /^from\\s*(-?(([0-9]*\\.[0-9]+)|([0-9]+\\.?)))deg/,\n startCall: /^\\(/,\n endCall: /^\\)/,\n comma: /^,/,\n hexColor: /(^\\#[0-9a-fA-F]+)/,\n literalColor: /^([a-zA-Z]+)/,\n rgbColor: /^(rgb\\(\\d{1,3},\\s*\\d{1,3},\\s*\\d{1,3}\\))/i,\n rgbaColor: /^(rgba\\(\\d{1,3},\\s*\\d{1,3},\\s*\\d{1,3},\\s*((\\d\\.\\d+)|\\d{1,3})\\))/i,\n number: /^(([0-9]*\\.[0-9]+)|([0-9]+\\.?))/\n };\n\n let input = '';\n\n function error(msg: any) {\n const err: any = new Error(input + ': ' + msg);\n err.source = input;\n throw err;\n }\n\n function getAST() {\n const ast = matchListDefinitions();\n\n if (input.length > 0) {\n error('Invalid input not EOF');\n }\n\n return ast;\n }\n\n function matchListDefinitions() {\n return matchListing(matchDefinition);\n }\n\n function matchDefinition() {\n return (\n matchGradient('linear', tokens.linearGradient, matchLinearOrientation) ||\n matchGradient('radial', tokens.radialGradient, matchListRadialOrientations) ||\n matchGradient('conic', tokens.conicGradient, matchConicalOrientation)\n );\n }\n\n function matchGradient(gradientType: string, pattern: RegExp, orientationMatcher: any) {\n return matchCall(pattern, function (captures: any) {\n const orientation = orientationMatcher();\n if (orientation) {\n if (!scan(tokens.comma)) {\n error('Missing comma before color stops');\n }\n }\n\n return {\n type: gradientType,\n orientation: orientation,\n colorStops: matchListing(matchColorStop)\n };\n });\n }\n\n function matchCall(pattern: RegExp, callback: any) {\n const captures = scan(pattern);\n\n if (captures) {\n if (!scan(tokens.startCall)) {\n error('Missing (');\n }\n\n const result = callback(captures);\n\n if (!scan(tokens.endCall)) {\n error('Missing )');\n }\n\n return result;\n }\n }\n\n function matchLinearOrientation() {\n return matchSideOrCorner() || matchAngle();\n }\n function matchConicalOrientation() {\n return matchFromAngle();\n }\n\n function matchSideOrCorner() {\n return match('directional', tokens.sideOrCorner, 1);\n }\n\n function matchAngle() {\n return match('angular', tokens.angleValue, 1);\n }\n function matchFromAngle() {\n return match('angular', tokens.fromAngleValue, 1);\n }\n\n function matchListRadialOrientations() {\n let radialOrientations;\n let radialOrientation = matchRadialOrientation();\n let lookaheadCache;\n\n if (radialOrientation) {\n radialOrientations = [];\n radialOrientations.push(radialOrientation);\n\n lookaheadCache = input;\n if (scan(tokens.comma)) {\n radialOrientation = matchRadialOrientation();\n if (radialOrientation) {\n radialOrientations.push(radialOrientation);\n } else {\n input = lookaheadCache;\n }\n }\n }\n\n return radialOrientations;\n }\n\n function matchRadialOrientation() {\n let radialType: any = matchCircle() || matchEllipse();\n\n if (radialType) {\n radialType.at = matchAtPosition();\n } else {\n const extent = matchExtentKeyword();\n if (extent) {\n radialType = extent;\n const positionAt = matchAtPosition();\n if (positionAt) {\n radialType.at = positionAt;\n }\n } else {\n const defaultPosition = matchPositioning();\n if (defaultPosition) {\n radialType = {\n type: 'default-radial',\n at: defaultPosition\n };\n }\n }\n }\n\n return radialType;\n }\n\n function matchCircle() {\n const circle: any = match('shape', /^(circle)/i, 0);\n\n if (circle) {\n circle.style = matchLength() || matchExtentKeyword();\n }\n\n return circle;\n }\n\n function matchEllipse() {\n const ellipse: any = match('shape', /^(ellipse)/i, 0);\n\n if (ellipse) {\n ellipse.style = matchDistance() || matchExtentKeyword();\n }\n\n return ellipse;\n }\n\n function matchExtentKeyword() {\n return match('extent-keyword', tokens.extentKeywords, 1);\n }\n\n function matchAtPosition() {\n if (match('position', /^at/, 0)) {\n const positioning = matchPositioning();\n\n if (!positioning) {\n error('Missing positioning value');\n }\n\n return positioning;\n }\n }\n\n function matchPositioning() {\n const location = matchCoordinates();\n\n if (location.x || location.y) {\n return {\n type: 'position',\n value: location\n };\n }\n }\n\n function matchCoordinates() {\n return {\n x: matchDistance(),\n y: matchDistance()\n };\n }\n\n function matchListing(matcher: any) {\n let captures = matcher();\n const result = [];\n\n if (captures) {\n result.push(captures);\n while (scan(tokens.comma)) {\n captures = matcher();\n if (captures) {\n result.push(captures);\n } else {\n error('One extra comma');\n }\n }\n }\n\n return result;\n }\n\n function matchColorStop() {\n const color: any = matchColor();\n\n if (!color) {\n error('Expected color definition');\n }\n\n color.length = matchDistance();\n return color;\n }\n\n function matchColor() {\n return matchHexColor() || matchRGBAColor() || matchRGBColor() || matchLiteralColor();\n }\n\n function matchLiteralColor() {\n return match('literal', tokens.literalColor, 0);\n }\n\n function matchHexColor() {\n return match('hex', tokens.hexColor, 1);\n }\n\n function matchRGBColor() {\n return match('rgb', tokens.rgbColor, 1);\n }\n\n function matchRGBAColor() {\n return match('rgba', tokens.rgbaColor, 1);\n }\n\n function matchNumber() {\n return scan(tokens.number)[1];\n }\n\n function matchDistance() {\n return match('%', tokens.percentageValue, 1) || matchPositionKeyword() || matchLength();\n }\n\n function matchPositionKeyword() {\n return match('position-keyword', tokens.positionKeywords, 1);\n }\n\n function matchLength() {\n return match('px', tokens.pixelValue, 1) || match('em', tokens.emValue, 1);\n }\n\n function match(type: string, pattern: RegExp, captureIndex: number) {\n const captures = scan(pattern);\n if (captures) {\n return {\n type: type,\n value: captures[captureIndex]\n };\n }\n }\n\n function scan(regexp: RegExp) {\n const blankCaptures = /^[\\n\\r\\t\\s]+/.exec(input);\n if (blankCaptures) {\n consume(blankCaptures[0].length);\n }\n\n const captures = regexp.exec(input);\n if (captures) {\n consume(captures[0].length);\n }\n\n return captures;\n }\n\n function consume(size: number) {\n input = input.substr(size);\n }\n\n return function (code: string) {\n input = code.toString();\n return getAST();\n };\n})();\n\nexport class GradientParser {\n static IsGradient(c: IColor) {\n return !(typeof c === 'string' && c.length < 10);\n }\n\n static IsGradientStr(c: IColor) {\n return typeof c === 'string' && c.length > 10;\n }\n\n static Parse(c: IColor): IColor {\n if (GradientParser.IsGradientStr(c)) {\n try {\n const data = parse(c as string);\n const datum = data[0];\n if (datum) {\n if (datum.type === 'linear') {\n return GradientParser.ParseLinear(datum);\n } else if (datum.type === 'radial') {\n return GradientParser.ParseRadial(datum);\n } else if (datum.type === 'conic') {\n return GradientParser.ParseConic(datum);\n }\n }\n } catch (err) {\n return c;\n }\n }\n return c;\n }\n private static ParseConic(datum: any): IConicalGradient {\n const { orientation, colorStops = [] } = datum;\n const halfPi = pi / 2;\n const sa = (parseFloat(orientation.value) / 180) * pi - halfPi;\n return {\n gradient: 'conical',\n x: 0.5,\n y: 0.5,\n startAngle: sa,\n endAngle: sa + pi2,\n stops: colorStops.map((item: any) => {\n return {\n color: item.value,\n offset: parseFloat(item.length.value) / 100\n };\n })\n };\n }\n private static ParseRadial(datum: any): IRadialGradient {\n const { colorStops = [] } = datum;\n return {\n gradient: 'radial',\n x0: 0.5,\n y0: 0.5,\n x1: 0.5,\n y1: 0.5,\n r0: 0,\n r1: 1,\n stops: colorStops.map((item: any) => {\n return {\n color: item.value,\n offset: parseFloat(item.length.value) / 100\n };\n })\n };\n }\n private static ParseLinear(datum: any): ILinearGradient {\n const { orientation, colorStops = [] } = datum;\n const halfPi = pi / 2;\n let angle = orientation.type === 'angular' ? (parseFloat(orientation.value) / 180) * pi : 0;\n while (angle < 0) {\n angle += pi2;\n }\n while (angle > pi2) {\n angle -= pi2;\n }\n let x0 = 0;\n let y0 = 0;\n let x1 = 0;\n let y1 = 0;\n if (angle < halfPi) {\n x0 = 0;\n y0 = 1;\n x1 = Math.sin(angle);\n y1 = Math.cos(angle);\n } else if (angle < pi) {\n x0 = 0;\n y0 = 0;\n x1 = Math.cos(angle - halfPi);\n y1 = Math.sin(angle - halfPi);\n } else if (angle < pi + halfPi) {\n x0 = 1;\n y0 = 0;\n x1 = x0 - Math.sin(angle - pi);\n y1 = Math.cos(angle - pi);\n } else {\n x0 = 1;\n y0 - 1;\n x1 = x0 - Math.cos(angle - halfPi - pi);\n y1 = y1 - Math.sin(angle - halfPi - pi);\n }\n return {\n gradient: 'linear',\n x0,\n y0,\n x1,\n y1,\n stops: colorStops.map((item: any) => {\n return {\n color: item.value,\n offset: parseFloat(item.length.value) / 100\n };\n })\n };\n }\n}\n"]}
|
package/cjs/common/rect-utils.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.normalizeRectAttributes = void 0;
|
|
6
|
-
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), normalizeRectAttributes = attribute => {
|
|
8
|
-
if (!attribute) return {
|
|
9
|
-
x: 0,
|
|
10
|
-
y: 0,
|
|
11
|
-
width: 0,
|
|
12
|
-
height: 0
|
|
13
|
-
};
|
|
14
|
-
let width = (0, vutils_1.isNil)(attribute.width) ? attribute.x1 - attribute.x : attribute.width, height = (0,
|
|
15
|
-
vutils_1.isNil)(attribute.height) ? attribute.y1 - attribute.y : attribute.height, x = 0, y = 0;
|
|
16
|
-
return width < 0 ? (x = width, width = -width) : Number.isNaN(width) && (width = 0),
|
|
17
|
-
height < 0 ? (y = height, height = -height) : Number.isNaN(height) && (height = 0),
|
|
18
|
-
{
|
|
19
|
-
x: x,
|
|
20
|
-
y: y,
|
|
21
|
-
width: width,
|
|
22
|
-
height: height
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.normalizeRectAttributes = normalizeRectAttributes;
|
|
27
|
-
//# sourceMappingURL=rect-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/rect-utils.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AAGlC,MAAM,uBAAuB,GAAG,CAAC,SAAgC,EAAE,EAAE;IAC1E,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KAC5C;IAED,IAAI,KAAK,GAAG,IAAA,cAAK,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC;IAClF,IAAI,MAAM,GAAG,IAAA,cAAK,EAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;IACrF,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,CAAC,GAAG,KAAK,CAAC;QACV,KAAK,GAAG,CAAC,KAAK,CAAC;KAChB;SAAM,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QAC9B,KAAK,GAAG,CAAC,CAAC;KACX;IAED,IAAI,MAAM,GAAG,CAAC,EAAE;QACd,CAAC,GAAG,MAAM,CAAC;QACX,MAAM,GAAG,CAAC,MAAM,CAAC;KAClB;SAAM,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QAC/B,MAAM,GAAG,CAAC,CAAC;KACZ;IAED,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC,CAAC;AAzBW,QAAA,uBAAuB,2BAyBlC","file":"rect-utils.js","sourcesContent":["import { isNil } from '@visactor/vutils';\nimport type { IRectGraphicAttribute } from '../interface/graphic/rect';\n\nexport const normalizeRectAttributes = (attribute: IRectGraphicAttribute) => {\n if (!attribute) {\n return { x: 0, y: 0, width: 0, height: 0 };\n }\n\n let width = isNil(attribute.width) ? attribute.x1 - attribute.x : attribute.width;\n let height = isNil(attribute.height) ? attribute.y1 - attribute.y : attribute.height;\n let x = 0;\n let y = 0;\n\n if (width < 0) {\n x = width;\n width = -width;\n } else if (Number.isNaN(width)) {\n width = 0;\n }\n\n if (height < 0) {\n y = height;\n height = -height;\n } else if (Number.isNaN(height)) {\n height = 0;\n }\n\n return { x, y, width, height };\n};\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IPoint } from '@visactor/vutils';
|
|
2
|
-
import type { ICurve, IPath2D } from '../interface';
|
|
3
|
-
export declare function drawSegItem(ctx: IPath2D, curve: ICurve<IPoint>, endPercent: number, params?: {
|
|
4
|
-
startLenPercent?: number;
|
|
5
|
-
endLenPercent?: number;
|
|
6
|
-
start?: number;
|
|
7
|
-
offsetX?: number;
|
|
8
|
-
offsetY?: number;
|
|
9
|
-
offsetZ?: number;
|
|
10
|
-
}): void;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.drawSegItem = void 0;
|
|
6
|
-
|
|
7
|
-
const cubic_bezier_1 = require("./segment/curve/cubic-bezier");
|
|
8
|
-
|
|
9
|
-
function drawSegItem(ctx, curve, endPercent, params) {
|
|
10
|
-
if (!curve.p1) return;
|
|
11
|
-
const {offsetX: offsetX = 0, offsetY: offsetY = 0, offsetZ: offsetZ = 0} = params || {};
|
|
12
|
-
if (1 === endPercent) curve.p2 && curve.p3 ? ctx.bezierCurveTo(offsetX + curve.p1.x, offsetY + curve.p1.y, offsetX + curve.p2.x, offsetY + curve.p2.y, offsetX + curve.p3.x, offsetY + curve.p3.y, offsetZ) : ctx.lineTo(offsetX + curve.p1.x, offsetY + curve.p1.y, offsetZ); else if (curve.p2 && curve.p3) {
|
|
13
|
-
const [curve1] = (0, cubic_bezier_1.divideCubic)(curve, endPercent);
|
|
14
|
-
ctx.bezierCurveTo(offsetX + curve1.p1.x, offsetY + curve1.p1.y, offsetX + curve1.p2.x, offsetY + curve1.p2.y, offsetX + curve1.p3.x, offsetY + curve1.p3.y, offsetZ);
|
|
15
|
-
} else {
|
|
16
|
-
const p = curve.getPointAt(endPercent);
|
|
17
|
-
ctx.lineTo(offsetX + p.x, offsetY + p.y, offsetZ);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.drawSegItem = drawSegItem;
|
|
22
|
-
//# sourceMappingURL=render-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/common/render-utils.ts"],"names":[],"mappings":";;;AAEA,+DAA2D;AAQ3D,SAAgB,WAAW,CACzB,GAAY,EACZ,KAAqB,EACrB,UAAkB,EAClB,MAOC;IAED,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE;QACb,OAAO;KACR;IACD,MAAM,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;IAG/D,IAAI,UAAU,KAAK,CAAC,EAAE;QACpB,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,EAAE;YACxB,GAAG,CAAC,aAAa,CACf,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EACpB,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EACpB,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EACpB,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EACpB,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EACpB,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EACpB,OAAO,CACR,CAAC;SACH;aAAM;YAEL,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SACjE;KACF;SAAM;QAEL,IAAI,KAAK,CAAC,EAAE,IAAI,KAAK,CAAC,EAAE,EAAE;YACxB,MAAM,CAAC,MAAM,CAAC,GAAG,IAAA,0BAAW,EAAC,KAA0B,EAAE,UAAU,CAAC,CAAC;YACrE,GAAG,CAAC,aAAa,CACf,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EACrB,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EACrB,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EACrB,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EACrB,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EACrB,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,EACrB,OAAO,CACR,CAAC;SACH;aAAM;YAEL,MAAM,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YACvC,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;SACnD;KACF;AACH,CAAC;AArDD,kCAqDC","file":"render-utils.js","sourcesContent":["import type { IPoint } from '@visactor/vutils';\nimport type { ICubicBezierCurve, ICurve, IPath2D } from '../interface';\nimport { divideCubic } from './segment/curve/cubic-bezier';\n\n/**\n * 绘制某个segment\n * @param ctx\n * @param seg\n * @param t 绘制这个segment的比例,t > 0从start到end,t < 0从end到start\n */\nexport function drawSegItem(\n ctx: IPath2D,\n curve: ICurve<IPoint>,\n endPercent: number,\n params?: {\n startLenPercent?: number;\n endLenPercent?: number;\n start?: number;\n offsetX?: number;\n offsetY?: number;\n offsetZ?: number;\n }\n) {\n if (!curve.p1) {\n return;\n }\n const { offsetX = 0, offsetY = 0, offsetZ = 0 } = params || {};\n\n // 完全绘制\n if (endPercent === 1) {\n if (curve.p2 && curve.p3) {\n ctx.bezierCurveTo(\n offsetX + curve.p1.x,\n offsetY + curve.p1.y,\n offsetX + curve.p2.x,\n offsetY + curve.p2.y,\n offsetX + curve.p3.x,\n offsetY + curve.p3.y,\n offsetZ\n );\n } else {\n // linear的线段\n ctx.lineTo(offsetX + curve.p1.x, offsetY + curve.p1.y, offsetZ);\n }\n } else {\n // 绘制一部分\n if (curve.p2 && curve.p3) {\n const [curve1] = divideCubic(curve as ICubicBezierCurve, endPercent);\n ctx.bezierCurveTo(\n offsetX + curve1.p1.x,\n offsetY + curve1.p1.y,\n offsetX + curve1.p2.x,\n offsetY + curve1.p2.y,\n offsetX + curve1.p3.x,\n offsetY + curve1.p3.y,\n offsetZ\n );\n } else {\n // linear的线段\n const p = curve.getPointAt(endPercent);\n ctx.lineTo(offsetX + p.x, offsetY + p.y, offsetZ);\n }\n }\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseRenderContributionTime } from '../../../../common/enums';
|
|
2
|
-
import type { IArcGraphicAttribute, IArea, IAreaRenderContribution, IContext2d, IDrawContext, IGraphicAttribute, IThemeAttribute } from '../../../../interface';
|
|
3
|
-
import { DefaultBaseTextureRenderContribution } from './base-texture-contribution-render';
|
|
4
|
-
export declare class DefaultAreaTextureRenderContribution extends DefaultBaseTextureRenderContribution implements IAreaRenderContribution {
|
|
5
|
-
time: BaseRenderContributionTime;
|
|
6
|
-
drawShape(graphic: IArea, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, graphicAttribute: Required<IGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, options?: {
|
|
7
|
-
attribute?: Partial<IArcGraphicAttribute>;
|
|
8
|
-
}): void;
|
|
9
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.DefaultAreaTextureRenderContribution = void 0;
|
|
6
|
-
|
|
7
|
-
const enums_1 = require("../../../../common/enums"), base_texture_contribution_render_1 = require("./base-texture-contribution-render"), utils_1 = require("../../../../common/utils");
|
|
8
|
-
|
|
9
|
-
class DefaultAreaTextureRenderContribution extends base_texture_contribution_render_1.DefaultBaseTextureRenderContribution {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(...arguments), this.time = enums_1.BaseRenderContributionTime.afterFillStroke;
|
|
12
|
-
}
|
|
13
|
-
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
|
|
14
|
-
var _a, _b, _c, _d;
|
|
15
|
-
this.textureMap || this.initTextureMap(context, graphic.stage);
|
|
16
|
-
const {attribute: attribute = graphic.attribute} = options || {}, {texture: texture = (null !== (_a = graphic.attribute.texture) && void 0 !== _a ? _a : (0,
|
|
17
|
-
utils_1.getAttributeFromDefaultAttrList)(graphicAttribute, "texture")), textureColor: textureColor = (null !== (_b = graphic.attribute.textureColor) && void 0 !== _b ? _b : (0,
|
|
18
|
-
utils_1.getAttributeFromDefaultAttrList)(graphicAttribute, "textureColor")), textureSize: textureSize = (null !== (_c = graphic.attribute.textureSize) && void 0 !== _c ? _c : (0,
|
|
19
|
-
utils_1.getAttributeFromDefaultAttrList)(graphicAttribute, "textureSize")), texturePadding: texturePadding = (null !== (_d = graphic.attribute.texturePadding) && void 0 !== _d ? _d : (0,
|
|
20
|
-
utils_1.getAttributeFromDefaultAttrList)(graphicAttribute, "texturePadding"))} = attribute;
|
|
21
|
-
texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.DefaultAreaTextureRenderContribution = DefaultAreaTextureRenderContribution;
|
|
26
|
-
//# sourceMappingURL=area-texture-contribution-render.js.map
|
package/cjs/render/contributions/render/contributions/area-texture-contribution-render.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/contributions/area-texture-contribution-render.ts"],"names":[],"mappings":";;;AAAA,oDAAsE;AAUtE,yFAA0F;AAC1F,oDAA2E;AAE3E,MAAa,oCACX,SAAQ,uEAAoC;IAD9C;;QAIE,SAAI,GAA+B,kCAA0B,CAAC,eAAe,CAAC;IAsChF,CAAC;IApCC,SAAS,CACP,OAAc,EACd,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,MAAe,EACf,QAAiB,EACjB,QAAiB,EACjB,QAAiB,EACjB,gBAA6C,EAC7C,WAAyB,EACzB,MAAiH,EACjH,QAAmH,EACnH,OAEC;;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;SAC7C;QAED,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAExD,MAAM,EACJ,OAAO,GAAG,MAAA,OAAO,CAAC,SAAS,CAAC,OAAO,mCAAI,IAAA,uCAA+B,EAAC,gBAAgB,EAAE,SAAS,CAAC,EACnG,YAAY,GAAG,MAAA,OAAO,CAAC,SAAS,CAAC,YAAY,mCAC3C,IAAA,uCAA+B,EAAC,gBAAgB,EAAE,cAAc,CAAC,EACnE,WAAW,GAAG,MAAA,OAAO,CAAC,SAAS,CAAC,WAAW,mCAAI,IAAA,uCAA+B,EAAC,gBAAgB,EAAE,aAAa,CAAC,EAC/G,cAAc,GAAG,MAAA,OAAO,CAAC,SAAS,CAAC,cAAc,mCAC/C,IAAA,uCAA+B,EAAC,gBAAgB,EAAE,gBAAgB,CAAC,EACtE,GAAG,SAAS,CAAC;QACd,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QACD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,gBAAgB,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IACjH,CAAC;CACF;AA1CD,oFA0CC","file":"area-texture-contribution-render.js","sourcesContent":["import { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IArcGraphicAttribute,\n IArea,\n IAreaRenderContribution,\n IContext2d,\n IDrawContext,\n IGraphicAttribute,\n IThemeAttribute\n} from '../../../../interface';\nimport { DefaultBaseTextureRenderContribution } from './base-texture-contribution-render';\nimport { getAttributeFromDefaultAttrList } from '../../../../common/utils';\n\nexport class DefaultAreaTextureRenderContribution\n extends DefaultBaseTextureRenderContribution\n implements IAreaRenderContribution\n{\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n\n drawShape(\n graphic: IArea,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: {\n attribute?: Partial<IArcGraphicAttribute>;\n }\n ) {\n if (!this.textureMap) {\n this.initTextureMap(context, graphic.stage);\n }\n\n const { attribute = graphic.attribute } = options || {};\n\n const {\n texture = graphic.attribute.texture ?? getAttributeFromDefaultAttrList(graphicAttribute, 'texture'),\n textureColor = graphic.attribute.textureColor ??\n getAttributeFromDefaultAttrList(graphicAttribute, 'textureColor'),\n textureSize = graphic.attribute.textureSize ?? getAttributeFromDefaultAttrList(graphicAttribute, 'textureSize'),\n texturePadding = graphic.attribute.texturePadding ??\n getAttributeFromDefaultAttrList(graphicAttribute, 'texturePadding')\n } = attribute;\n if (!texture) {\n return;\n }\n this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);\n }\n}\n"]}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BaseRenderContributionTime } from '../../../../common/enums';
|
|
2
|
-
import type { IBaseRenderContribution, IContext2d, IDrawContext, IGraphic, IGraphicAttribute, IStage, IThemeAttribute } from '../../../../interface';
|
|
3
|
-
export declare class DefaultBaseTextureRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {
|
|
4
|
-
time: BaseRenderContributionTime;
|
|
5
|
-
useStyle: boolean;
|
|
6
|
-
textureMap?: Map<string, CanvasPattern>;
|
|
7
|
-
order: number;
|
|
8
|
-
createCommonPattern(size: number, padding: number, color: string, targetContext: IContext2d, cb: (r: number, targetContext: IContext2d) => void): CanvasPattern;
|
|
9
|
-
createCirclePattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
10
|
-
createDiamondPattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
11
|
-
createRectPattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
12
|
-
createVerticalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
13
|
-
createHorizontalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
14
|
-
createBiasLRLinePattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
15
|
-
createBiasRLLinePattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
16
|
-
createGridPattern(size: number, padding: number, color: string, targetContext: IContext2d): CanvasPattern;
|
|
17
|
-
initTextureMap(ctx: IContext2d, stage: IStage): void;
|
|
18
|
-
drawShape(graphic: IGraphic, context: IContext2d, x: number, y: number, doFill: boolean, doStroke: boolean, fVisible: boolean, sVisible: boolean, graphicAttribute: Required<IGraphicAttribute>, drawContext: IDrawContext, fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean, options?: any): void;
|
|
19
|
-
protected drawTexture(texture: string, graphic: IGraphic, context: IContext2d, x: number, y: number, graphicAttribute: Required<IGraphicAttribute>, textureColor: string, textureSize: number, texturePadding: number): void;
|
|
20
|
-
}
|
|
21
|
-
export declare const defaultBaseTextureRenderContribution: DefaultBaseTextureRenderContribution;
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: !0
|
|
5
|
-
}), exports.defaultBaseTextureRenderContribution = exports.DefaultBaseTextureRenderContribution = void 0;
|
|
6
|
-
|
|
7
|
-
const canvas_allocate_1 = require("../../../../allocator/canvas-allocate"), enums_1 = require("../../../../common/enums"), vutils_1 = require("@visactor/vutils");
|
|
8
|
-
|
|
9
|
-
class DefaultBaseTextureRenderContribution {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.time = enums_1.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0,
|
|
12
|
-
this.order = 10;
|
|
13
|
-
}
|
|
14
|
-
createCommonPattern(size, padding, color, targetContext, cb) {
|
|
15
|
-
const r = (size - 2 * padding) / 2, dpr = targetContext.dpr, canvas = canvas_allocate_1.canvasAllocate.allocate({
|
|
16
|
-
width: size,
|
|
17
|
-
height: size,
|
|
18
|
-
dpr: dpr
|
|
19
|
-
}), ctx = canvas.getContext("2d");
|
|
20
|
-
if (!ctx) return null;
|
|
21
|
-
ctx.inuse = !0, ctx.clearMatrix(), ctx.setTransformForCurrent(!0), ctx.clearRect(0, 0, size, size),
|
|
22
|
-
cb(r, ctx);
|
|
23
|
-
const pattern = targetContext.createPattern(canvas.nativeCanvas, "repeat");
|
|
24
|
-
return pattern.setTransform && pattern.setTransform(new DOMMatrix([ 1 / dpr, 0, 0, 1 / dpr, 0, 0 ])),
|
|
25
|
-
canvas_allocate_1.canvasAllocate.free(canvas), pattern;
|
|
26
|
-
}
|
|
27
|
-
createCirclePattern(size, padding, color, targetContext) {
|
|
28
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
29
|
-
ctx.fillStyle = color, ctx.arc(r, r, r, 0, vutils_1.pi2), ctx.fill();
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
createDiamondPattern(size, padding, color, targetContext) {
|
|
33
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
34
|
-
const x = size / 2, y = x;
|
|
35
|
-
ctx.fillStyle = color, ctx.moveTo(x, y - r), ctx.lineTo(r + x, y), ctx.lineTo(x, y + r),
|
|
36
|
-
ctx.lineTo(x - r, y), ctx.closePath(), ctx.fill();
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
createRectPattern(size, padding, color, targetContext) {
|
|
40
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
41
|
-
const x = padding, y = x;
|
|
42
|
-
ctx.fillStyle = color, ctx.fillRect(x, y, 2 * r, 2 * r);
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
createVerticalLinePattern(size, padding, color, targetContext) {
|
|
46
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
47
|
-
const x = padding;
|
|
48
|
-
ctx.fillStyle = color, ctx.fillRect(x, 0, 2 * r, size);
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
createHorizontalLinePattern(size, padding, color, targetContext) {
|
|
52
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
53
|
-
const y = padding;
|
|
54
|
-
ctx.fillStyle = color, ctx.fillRect(0, y, size, 2 * r);
|
|
55
|
-
}));
|
|
56
|
-
}
|
|
57
|
-
createBiasLRLinePattern(size, padding, color, targetContext) {
|
|
58
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
59
|
-
ctx.strokeStyle = color, ctx.lineWidth = r, ctx.moveTo(0, 0), ctx.lineTo(size, size);
|
|
60
|
-
const dx = size / 2, dy = -dx;
|
|
61
|
-
ctx.moveTo(dx, dy), ctx.lineTo(dx + size, dy + size), ctx.moveTo(-dx, -dy), ctx.lineTo(-dx + size, -dy + size),
|
|
62
|
-
ctx.stroke();
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
createBiasRLLinePattern(size, padding, color, targetContext) {
|
|
66
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
67
|
-
ctx.strokeStyle = color, ctx.lineWidth = r, ctx.moveTo(size, 0), ctx.lineTo(0, size);
|
|
68
|
-
const dx = size / 2, dy = dx;
|
|
69
|
-
ctx.moveTo(size + dx, dy), ctx.lineTo(dx, dy + size), ctx.moveTo(size - dx, -dy),
|
|
70
|
-
ctx.lineTo(-dx, -dy + size), ctx.stroke();
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
createGridPattern(size, padding, color, targetContext) {
|
|
74
|
-
return this.createCommonPattern(size, padding, color, targetContext, ((r, ctx) => {
|
|
75
|
-
const x = padding, y = x;
|
|
76
|
-
ctx.fillStyle = color, ctx.fillRect(x, y, r, r), ctx.fillRect(x + r, y + r, r, r);
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
initTextureMap(ctx, stage) {
|
|
80
|
-
this.textureMap = new Map;
|
|
81
|
-
}
|
|
82
|
-
drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb, options) {
|
|
83
|
-
this.textureMap || this.initTextureMap(context, graphic.stage);
|
|
84
|
-
const {texture: texture = graphicAttribute.texture, textureColor: textureColor = graphicAttribute.textureColor, textureSize: textureSize = graphicAttribute.textureSize, texturePadding: texturePadding = graphicAttribute.texturePadding} = graphic.attribute;
|
|
85
|
-
texture && this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);
|
|
86
|
-
}
|
|
87
|
-
drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding) {
|
|
88
|
-
let pattern = this.textureMap.get(texture);
|
|
89
|
-
if (!pattern) switch (texture) {
|
|
90
|
-
case "circle":
|
|
91
|
-
pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);
|
|
92
|
-
break;
|
|
93
|
-
|
|
94
|
-
case "diamond":
|
|
95
|
-
pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);
|
|
96
|
-
break;
|
|
97
|
-
|
|
98
|
-
case "rect":
|
|
99
|
-
pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);
|
|
100
|
-
break;
|
|
101
|
-
|
|
102
|
-
case "vertical-line":
|
|
103
|
-
pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);
|
|
104
|
-
break;
|
|
105
|
-
|
|
106
|
-
case "horizontal-line":
|
|
107
|
-
pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);
|
|
108
|
-
break;
|
|
109
|
-
|
|
110
|
-
case "bias-lr":
|
|
111
|
-
pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);
|
|
112
|
-
break;
|
|
113
|
-
|
|
114
|
-
case "bias-rl":
|
|
115
|
-
pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);
|
|
116
|
-
break;
|
|
117
|
-
|
|
118
|
-
case "grid":
|
|
119
|
-
pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);
|
|
120
|
-
}
|
|
121
|
-
pattern && (context.highPerformanceSave(), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute),
|
|
122
|
-
context.fillStyle = pattern, context.fill(), context.highPerformanceRestore());
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
exports.DefaultBaseTextureRenderContribution = DefaultBaseTextureRenderContribution,
|
|
127
|
-
exports.defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution;
|
|
128
|
-
//# sourceMappingURL=base-texture-contribution-render.js.map
|
package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/render/contributions/render/contributions/base-texture-contribution-render.ts"],"names":[],"mappings":";;;AAAA,2EAAuE;AACvE,oDAAsE;AAUtE,6CAAuC;AAEvC,MAAa,oCAAoC;IAAjD;QACE,SAAI,GAA+B,kCAA0B,CAAC,eAAe,CAAC;QAC9E,aAAQ,GAAY,IAAI,CAAC;QAEzB,UAAK,GAAW,EAAE,CAAC;IAsNrB,CAAC;IApNC,mBAAmB,CACjB,IAAY,EACZ,OAAe,EACf,KAAa,EACb,aAAyB,EACzB,EAAkD;QAElD,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC;QAC9B,MAAM,MAAM,GAAG,gCAAc,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3E,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,IAAI,CAAC;SACb;QACD,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC;QACjB,GA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AI,OAAO,EAAE;YACX,OAAO,CAAC,mBAAmB,EAAE,CAAC;YAC9B,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;YAC3E,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC;YAC5B,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,OAAO,CAAC,sBAAsB,EAAE,CAAC;SAClC;IACH,CAAC;CACF;AA1ND,oFA0NC;AAEY,QAAA,oCAAoC,GAAG,IAAI,oCAAoC,EAAE,CAAC","file":"base-texture-contribution-render.js","sourcesContent":["import { canvasAllocate } from '../../../../allocator/canvas-allocate';\nimport { BaseRenderContributionTime } from '../../../../common/enums';\nimport type {\n IBaseRenderContribution,\n IContext2d,\n IDrawContext,\n IGraphic,\n IGraphicAttribute,\n IStage,\n IThemeAttribute\n} from '../../../../interface';\nimport { pi2 } from '@visactor/vutils';\n\nexport class DefaultBaseTextureRenderContribution implements IBaseRenderContribution<IGraphic, IGraphicAttribute> {\n time: BaseRenderContributionTime = BaseRenderContributionTime.afterFillStroke;\n useStyle: boolean = true;\n textureMap?: Map<string, CanvasPattern>;\n order: number = 10;\n\n createCommonPattern(\n size: number,\n padding: number,\n color: string,\n targetContext: IContext2d,\n cb: (r: number, targetContext: IContext2d) => void\n ) {\n const r = (size - padding * 2) / 2;\n const dpr = targetContext.dpr;\n const canvas = canvasAllocate.allocate({ width: size, height: size, dpr });\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return null;\n }\n ctx.inuse = true;\n ctx.clearMatrix();\n ctx.setTransformForCurrent(true);\n ctx.clearRect(0, 0, size, size);\n //setup up design for pattern\n cb(r, ctx);\n const pattern = targetContext.createPattern(canvas.nativeCanvas, 'repeat');\n pattern.setTransform && pattern.setTransform(new DOMMatrix([1 / dpr, 0, 0, 1 / dpr, 0, 0]));\n\n canvasAllocate.free(canvas);\n return pattern;\n }\n\n createCirclePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.fillStyle = color;\n ctx.arc(r, r, r, 0, pi2);\n ctx.fill();\n });\n }\n\n createDiamondPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = size / 2;\n const y = x;\n ctx.fillStyle = color;\n ctx.moveTo(x, y - r);\n ctx.lineTo(r + x, y);\n ctx.lineTo(x, y + r);\n ctx.lineTo(x - r, y);\n ctx.closePath();\n ctx.fill();\n });\n }\n\n createRectPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, r * 2);\n });\n }\n\n createVerticalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = 0;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r * 2, size);\n });\n }\n\n createHorizontalLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = 0;\n const y = padding;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, size, r * 2);\n });\n }\n\n createBiasLRLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(0, 0);\n ctx.lineTo(size, size);\n const dx = size / 2;\n const dy = -dx;\n ctx.moveTo(dx, dy);\n ctx.lineTo(dx + size, dy + size);\n ctx.moveTo(-dx, -dy);\n ctx.lineTo(-dx + size, -dy + size);\n ctx.stroke();\n });\n }\n\n createBiasRLLinePattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n ctx.strokeStyle = color;\n ctx.lineWidth = r;\n ctx.moveTo(size, 0);\n ctx.lineTo(0, size);\n const dx = size / 2;\n const dy = dx;\n ctx.moveTo(size + dx, dy);\n ctx.lineTo(dx, dy + size);\n ctx.moveTo(size - dx, -dy);\n ctx.lineTo(-dx, -dy + size);\n ctx.stroke();\n });\n }\n\n createGridPattern(size: number, padding: number, color: string, targetContext: IContext2d) {\n return this.createCommonPattern(size, padding, color, targetContext, (r, ctx) => {\n const x = padding;\n const y = x;\n ctx.fillStyle = color;\n ctx.fillRect(x, y, r, r);\n ctx.fillRect(x + r, y + r, r, r);\n });\n }\n\n initTextureMap(ctx: IContext2d, stage: IStage) {\n this.textureMap = new Map();\n // ResourceLoader.GetImage(rect1, {\n // imageLoadFail: () => {\n // return;\n // },\n // imageLoadSuccess: (url, img) => {\n // const pattern = ctx.createPattern(img, 'repeat');\n // this.textureMap.set('rect1', pattern);\n // stage && stage.renderNextFrame();\n // }\n // });\n }\n\n drawShape(\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n doFill: boolean,\n doStroke: boolean,\n fVisible: boolean,\n sVisible: boolean,\n graphicAttribute: Required<IGraphicAttribute>,\n drawContext: IDrawContext,\n fillCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n strokeCb?: (ctx: IContext2d, markAttribute: Partial<IGraphicAttribute>, themeAttribute: IThemeAttribute) => boolean,\n options?: any\n ) {\n if (!this.textureMap) {\n this.initTextureMap(context, graphic.stage);\n }\n const {\n texture = graphicAttribute.texture,\n textureColor = graphicAttribute.textureColor,\n textureSize = graphicAttribute.textureSize,\n texturePadding = graphicAttribute.texturePadding\n } = graphic.attribute;\n if (!texture) {\n return;\n }\n this.drawTexture(texture, graphic, context, x, y, graphicAttribute, textureColor, textureSize, texturePadding);\n }\n\n protected drawTexture(\n texture: string,\n graphic: IGraphic,\n context: IContext2d,\n x: number,\n y: number,\n graphicAttribute: Required<IGraphicAttribute>,\n textureColor: string,\n textureSize: number,\n texturePadding: number\n ) {\n let pattern: CanvasPattern = this.textureMap.get(texture);\n\n if (!pattern) {\n switch (texture) {\n case 'circle':\n pattern = this.createCirclePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'diamond':\n pattern = this.createDiamondPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'rect':\n pattern = this.createRectPattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'vertical-line':\n pattern = this.createVerticalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'horizontal-line':\n pattern = this.createHorizontalLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-lr':\n pattern = this.createBiasLRLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'bias-rl':\n pattern = this.createBiasRLLinePattern(textureSize, texturePadding, textureColor, context);\n break;\n case 'grid':\n pattern = this.createGridPattern(textureSize, texturePadding, textureColor, context);\n break;\n }\n }\n\n if (pattern) {\n context.highPerformanceSave();\n context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute);\n context.fillStyle = pattern;\n context.fill();\n context.highPerformanceRestore();\n }\n }\n}\n\nexport const defaultBaseTextureRenderContribution = new DefaultBaseTextureRenderContribution();\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IColor } from '../interface';
|
|
2
|
-
export declare class GradientParser {
|
|
3
|
-
static IsGradient(c: IColor): boolean;
|
|
4
|
-
static IsGradientStr(c: IColor): boolean;
|
|
5
|
-
static Parse(c: IColor): IColor;
|
|
6
|
-
private static ParseConic;
|
|
7
|
-
private static ParseRadial;
|
|
8
|
-
private static ParseLinear;
|
|
9
|
-
}
|