@visactor/vrender-core 0.16.15-alpha.0 → 0.16.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/cjs/color-string/colorName.js +1 -1
  2. package/cjs/color-string/index.js +1 -1
  3. package/cjs/color-string/interpolate.js +1 -1
  4. package/cjs/color-string/store.js +1 -1
  5. package/cjs/common/bezier-utils.js +1 -2
  6. package/cjs/common/custom-path2d.js +2 -1
  7. package/cjs/common/split-path.js +1 -2
  8. package/cjs/core/application.js +2 -1
  9. package/cjs/core/global-module.js +2 -0
  10. package/cjs/core/global.js +1 -1
  11. package/cjs/core/graphic-utils.js +1 -1
  12. package/cjs/core/index.js +1 -1
  13. package/cjs/graphic/builtin-symbol/index.js +0 -1
  14. package/cjs/graphic/builtin-symbol/index.js.map +1 -1
  15. package/cjs/graphic/builtin-symbol/rect.d.ts +2 -1
  16. package/cjs/graphic/builtin-symbol/rect.js +11 -6
  17. package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
  18. package/dist/index.js +18 -11
  19. package/dist/index.min.js +1 -1
  20. package/es/color-string/colorName.js +1 -1
  21. package/es/color-string/index.js +1 -1
  22. package/es/color-string/interpolate.js +1 -1
  23. package/es/color-string/store.js +1 -1
  24. package/es/common/bezier-utils.js +1 -2
  25. package/es/common/custom-path2d.js +2 -1
  26. package/es/common/split-path.js +1 -2
  27. package/es/core/application.js +2 -1
  28. package/es/core/global-module.js +2 -0
  29. package/es/core/global.js +1 -1
  30. package/es/core/graphic-utils.js +1 -1
  31. package/es/core/index.js +1 -1
  32. package/es/graphic/builtin-symbol/index.js +0 -1
  33. package/es/graphic/builtin-symbol/index.js.map +1 -1
  34. package/es/graphic/builtin-symbol/rect.d.ts +2 -1
  35. package/es/graphic/builtin-symbol/rect.js +9 -4
  36. package/es/graphic/builtin-symbol/rect.js.map +1 -1
  37. package/package.json +4 -4
@@ -10,4 +10,4 @@ Object.keys(vutils_1.DEFAULT_COLORS).forEach((k => {
10
10
  const c = vutils_1.DEFAULT_COLORS[k];
11
11
  parsedColors[k] = [ c >> 16 & 255, c >> 8 & 255, 255 & c ];
12
12
  })), exports.default = parsedColors;
13
- //# sourceMappingURL=colorName.js.map
13
+ //# sourceMappingURL=colorName.js.map
@@ -19,4 +19,4 @@ Object.defineProperty(exports, "__esModule", {
19
19
  value: !0
20
20
  }), __exportStar(require("./interpolate"), exports), __exportStar(require("./store"), exports),
21
21
  __exportStar(require("./colorName"), exports);
22
- //# sourceMappingURL=index.js.map
22
+ //# sourceMappingURL=index.js.map
@@ -100,4 +100,4 @@ function colorStringInterpolationToStr(fromColor, toColor, ratio) {
100
100
  }
101
101
 
102
102
  exports.colorStringInterpolationToStr = colorStringInterpolationToStr;
103
- //# sourceMappingURL=interpolate.js.map
103
+ //# sourceMappingURL=interpolate.js.map
@@ -51,4 +51,4 @@ class ColorStore {
51
51
  }
52
52
 
53
53
  exports.ColorStore = ColorStore, ColorStore.store255 = {}, ColorStore.store1 = {};
54
- //# sourceMappingURL=store.js.map
54
+ //# sourceMappingURL=store.js.map
@@ -31,5 +31,4 @@ function cubicPointAt(p0, p1, p2, p3, t) {
31
31
  }
32
32
 
33
33
  exports.snapLength = snapLength, exports.cubicLength = cubicLength, exports.cubicCalc = cubicCalc,
34
- exports.cubicPointAt = cubicPointAt;
35
- //# sourceMappingURL=bezier-utils.js.map
34
+ exports.cubicPointAt = cubicPointAt;
@@ -329,4 +329,5 @@ function scale(current, sX, sY) {
329
329
  temp[3] = current[3], temp[4] = current[4], temp[5] = current[5], temp[6] = sX * current[6],
330
330
  temp[7] = sY * current[7]; else if ("h" === c || "H" === c) temp[1] = sX * current[1]; else if ("v" === c || "V" === c) temp[1] = sY * current[1]; else for (let i = 1, n = current.length; i < n; ++i) temp[i] = (i % 2 == 1 ? sX : sY) * current[i];
331
331
  return temp;
332
- }
332
+ }
333
+ //# sourceMappingURL=custom-path2d.js.map
@@ -268,5 +268,4 @@ const splitPath = (path, count) => {
268
268
  return res;
269
269
  };
270
270
 
271
- exports.splitPath = splitPath;
272
- //# sourceMappingURL=split-path.js.map
271
+ exports.splitPath = splitPath;
@@ -2,4 +2,5 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.ApplicationContribution = void 0, exports.ApplicationContribution = Symbol("ApplicationContribution");
5
+ }), exports.ApplicationContribution = void 0, exports.ApplicationContribution = Symbol("ApplicationContribution");
6
+ //# sourceMappingURL=application.js.map
@@ -1 +1,3 @@
1
+
2
+
1
3
  //# sourceMappingURL=global-module.js.map
@@ -173,4 +173,4 @@ DefaultGlobal = __decorate([ (0, inversify_lite_1.injectable)(), __param(0, (0,
173
173
  inversify_lite_1.inject)(contribution_provider_1.ContributionProvider)), __param(0, (0,
174
174
  inversify_lite_1.named)(constants_1.EnvContribution)), __metadata("design:paramtypes", [ Object ]) ], DefaultGlobal),
175
175
  exports.DefaultGlobal = DefaultGlobal;
176
- //# sourceMappingURL=global.js.map
176
+ //# sourceMappingURL=global.js.map
@@ -136,4 +136,4 @@ let DefaultTransformUtil = class {
136
136
 
137
137
  DefaultTransformUtil = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", []) ], DefaultTransformUtil),
138
138
  exports.DefaultTransformUtil = DefaultTransformUtil;
139
- //# sourceMappingURL=graphic-utils.js.map
139
+ //# sourceMappingURL=graphic-utils.js.map
package/cjs/core/index.js CHANGED
@@ -22,4 +22,4 @@ __exportStar(require("./layer"), exports), __exportStar(require("./stage"), expo
22
22
  __exportStar(require("./graphic-utils"), exports), __exportStar(require("./contributions"), exports),
23
23
  __exportStar(require("./layer-service"), exports), __exportStar(require("./constants"), exports),
24
24
  __exportStar(require("../interface/core"), exports);
25
- //# sourceMappingURL=index.js.map
25
+ //# sourceMappingURL=index.js.map
@@ -31,7 +31,6 @@ exports.builtinSymbolsMap = {}, exports.builtinSymbols.forEach((symbol => {
31
31
  })), exports.builtInSymbolStrMap = {
32
32
  arrowLeft: "M 0.25 -0.5 L -0.25 0 l 0.5 0.5",
33
33
  arrowRight: "M -0.25 -0.5 l 0.5 0.5 l -0.5 0.5",
34
- rect: "M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z",
35
34
  rectRound: "M 0.3 -0.5 C 0.41 -0.5 0.5 -0.41 0.5 -0.3 C 0.5 -0.3 0.5 0.3 0.5 0.3 C 0.5 0.41 0.41 0.5 0.3 0.5 C 0.3 0.5 -0.3 0.5 -0.3 0.5 C -0.41 0.5 -0.5 0.41 -0.5 0.3 C -0.5 0.3 -0.5 -0.3 -0.5 -0.3 C -0.5 -0.41 -0.41 -0.5 -0.3 -0.5 C -0.3 -0.5 0.3 -0.5 0.3 -0.5 Z",
36
35
  roundLine: "M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z"
37
36
  }, __exportStar(require("./utils"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/builtin-symbol/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,oDAA4B;AAC5B,wDAAgC;AAChC,sDAA8B;AAC9B,0DAAkC;AAClC,kDAA0B;AAC1B,oDAA4B;AAC5B,oDAA4B;AAC5B,sDAA8B;AAC9B,gDAAwB;AACxB,oEAA2C;AAC3C,sEAA6C;AAC7C,gEAAuC;AACvC,oEAA2C;AAC3C,oEAA2C;AAC3C,gEAAuC;AACvC,kEAAyC;AACzC,4DAAmC;AACnC,gEAAuC;AACvC,sDAA6B;AAC7B,sDAA6B;AAC7B,oDAA4B;AAC5B,kDAA0B;AAGb,QAAA,cAAc,GAAG;IAC5B,gBAAM;IACN,eAAK;IACL,iBAAO;IACP,gBAAM;IACN,uBAAY;IACZ,kBAAQ;IACR,cAAI;IACJ,eAAK;IACL,eAAK;IACL,gBAAM;IACN,aAAG;IACH,uBAAY;IACZ,wBAAa;IACb,qBAAU;IACV,uBAAY;IACZ,qBAAU;IACV,sBAAW;IACX,mBAAQ;IACR,qBAAU;IACV,cAAI;IACJ,gBAAK;IACL,gBAAK;IACL,eAAK;CACN,CAAC;AACW,QAAA,iBAAiB,GAAiC,EAAE,CAAC;AAElE,sBAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;IAC9B,yBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEU,QAAA,mBAAmB,GAA2B;IACzD,SAAS,EAAE,iCAAiC;IAC5C,UAAU,EAAE,mCAAmC;IAC/C,IAAI,EAAE,mDAAmD;IACzD,SAAS,EAEP,8PAA8P;IAChQ,SAAS,EACP,sNAAsN;CACzN,CAAC;AAEF,0CAAwB","file":"index.js","sourcesContent":["import circle from './circle';\nimport cross from './cross';\nimport diamond from './diamond';\nimport square from './square';\nimport triangle from './triangle';\nimport star from './star';\nimport arrow from './arrow';\nimport wedge from './wedge';\nimport stroke from './stroke';\nimport wye from './wye';\nimport triangleLeft from './triangle-left';\nimport triangleRight from './triangle-right';\nimport triangleUp from './triangle-up';\nimport triangleDown from './triangle-down';\nimport thinTriangle from './thin-triangle';\nimport arrow2Left from './arrow2-left';\nimport arrow2Right from './arrow2-right';\nimport arrow2Up from './arrow2-up';\nimport arrow2Down from './arrow2-down';\nimport lineV from './line-v';\nimport lineH from './line-h';\nimport close from './close';\nimport rect from './rect';\nimport type { ISymbolClass } from '../../interface';\n\nexport const builtinSymbols = [\n circle,\n cross,\n diamond,\n square,\n thinTriangle,\n triangle,\n star,\n arrow,\n wedge,\n stroke,\n wye,\n triangleLeft,\n triangleRight,\n triangleUp,\n triangleDown,\n arrow2Left,\n arrow2Right,\n arrow2Up,\n arrow2Down,\n rect,\n lineV,\n lineH,\n close\n];\nexport const builtinSymbolsMap: Record<string, ISymbolClass> = {};\n\nbuiltinSymbols.forEach(symbol => {\n builtinSymbolsMap[symbol.type] = symbol;\n});\n\nexport const builtInSymbolStrMap: Record<string, string> = {\n arrowLeft: 'M 0.25 -0.5 L -0.25 0 l 0.5 0.5',\n arrowRight: 'M -0.25 -0.5 l 0.5 0.5 l -0.5 0.5',\n rect: 'M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z',\n rectRound:\n // eslint-disable-next-line max-len\n 'M 0.3 -0.5 C 0.41 -0.5 0.5 -0.41 0.5 -0.3 C 0.5 -0.3 0.5 0.3 0.5 0.3 C 0.5 0.41 0.41 0.5 0.3 0.5 C 0.3 0.5 -0.3 0.5 -0.3 0.5 C -0.41 0.5 -0.5 0.41 -0.5 0.3 C -0.5 0.3 -0.5 -0.3 -0.5 -0.3 C -0.5 -0.41 -0.41 -0.5 -0.3 -0.5 C -0.3 -0.5 0.3 -0.5 0.3 -0.5 Z',\n roundLine:\n 'M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z'\n};\n\nexport * from './utils';\n"]}
1
+ {"version":3,"sources":["../src/graphic/builtin-symbol/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,oDAA4B;AAC5B,wDAAgC;AAChC,sDAA8B;AAC9B,0DAAkC;AAClC,kDAA0B;AAC1B,oDAA4B;AAC5B,oDAA4B;AAC5B,sDAA8B;AAC9B,gDAAwB;AACxB,oEAA2C;AAC3C,sEAA6C;AAC7C,gEAAuC;AACvC,oEAA2C;AAC3C,oEAA2C;AAC3C,gEAAuC;AACvC,kEAAyC;AACzC,4DAAmC;AACnC,gEAAuC;AACvC,sDAA6B;AAC7B,sDAA6B;AAC7B,oDAA4B;AAC5B,kDAA0B;AAGb,QAAA,cAAc,GAAG;IAC5B,gBAAM;IACN,eAAK;IACL,iBAAO;IACP,gBAAM;IACN,uBAAY;IACZ,kBAAQ;IACR,cAAI;IACJ,eAAK;IACL,eAAK;IACL,gBAAM;IACN,aAAG;IACH,uBAAY;IACZ,wBAAa;IACb,qBAAU;IACV,uBAAY;IACZ,qBAAU;IACV,sBAAW;IACX,mBAAQ;IACR,qBAAU;IACV,cAAI;IACJ,gBAAK;IACL,gBAAK;IACL,eAAK;CACN,CAAC;AACW,QAAA,iBAAiB,GAAiC,EAAE,CAAC;AAElE,sBAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;IAC9B,yBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEU,QAAA,mBAAmB,GAA2B;IACzD,SAAS,EAAE,iCAAiC;IAC5C,UAAU,EAAE,mCAAmC;IAE/C,SAAS,EAEP,8PAA8P;IAChQ,SAAS,EACP,sNAAsN;CACzN,CAAC;AAEF,0CAAwB","file":"index.js","sourcesContent":["import circle from './circle';\nimport cross from './cross';\nimport diamond from './diamond';\nimport square from './square';\nimport triangle from './triangle';\nimport star from './star';\nimport arrow from './arrow';\nimport wedge from './wedge';\nimport stroke from './stroke';\nimport wye from './wye';\nimport triangleLeft from './triangle-left';\nimport triangleRight from './triangle-right';\nimport triangleUp from './triangle-up';\nimport triangleDown from './triangle-down';\nimport thinTriangle from './thin-triangle';\nimport arrow2Left from './arrow2-left';\nimport arrow2Right from './arrow2-right';\nimport arrow2Up from './arrow2-up';\nimport arrow2Down from './arrow2-down';\nimport lineV from './line-v';\nimport lineH from './line-h';\nimport close from './close';\nimport rect from './rect';\nimport type { ISymbolClass } from '../../interface';\n\nexport const builtinSymbols = [\n circle,\n cross,\n diamond,\n square,\n thinTriangle,\n triangle,\n star,\n arrow,\n wedge,\n stroke,\n wye,\n triangleLeft,\n triangleRight,\n triangleUp,\n triangleDown,\n arrow2Left,\n arrow2Right,\n arrow2Up,\n arrow2Down,\n rect,\n lineV,\n lineH,\n close\n];\nexport const builtinSymbolsMap: Record<string, ISymbolClass> = {};\n\nbuiltinSymbols.forEach(symbol => {\n builtinSymbolsMap[symbol.type] = symbol;\n});\n\nexport const builtInSymbolStrMap: Record<string, string> = {\n arrowLeft: 'M 0.25 -0.5 L -0.25 0 l 0.5 0.5',\n arrowRight: 'M -0.25 -0.5 l 0.5 0.5 l -0.5 0.5',\n // rect: 'M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z',\n rectRound:\n // eslint-disable-next-line max-len\n 'M 0.3 -0.5 C 0.41 -0.5 0.5 -0.41 0.5 -0.3 C 0.5 -0.3 0.5 0.3 0.5 0.3 C 0.5 0.41 0.41 0.5 0.3 0.5 C 0.3 0.5 -0.3 0.5 -0.3 0.5 C -0.41 0.5 -0.5 0.41 -0.5 0.3 C -0.5 0.3 -0.5 -0.3 -0.5 -0.3 C -0.5 -0.41 -0.41 -0.5 -0.3 -0.5 C -0.3 -0.5 0.3 -0.5 0.3 -0.5 Z',\n roundLine:\n 'M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z'\n};\n\nexport * from './utils';\n"]}
@@ -1,6 +1,7 @@
1
1
  import type { IContext2d, SymbolType, ISymbolClass } from '../../interface';
2
2
  import { BaseSymbol } from './base';
3
- export declare function rect(ctx: IContext2d, size: [number, number], x: number, y: number): boolean;
3
+ export declare function rectSizeArray(ctx: IContext2d, size: [number, number], x: number, y: number): boolean;
4
+ export declare function rectSize(ctx: IContext2d, size: number, x: number, y: number): boolean;
4
5
  export declare class RectSymbol extends BaseSymbol implements ISymbolClass {
5
6
  type: SymbolType;
6
7
  pathStr: string;
@@ -2,25 +2,30 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
- }), exports.RectSymbol = exports.rect = void 0;
5
+ }), exports.RectSymbol = exports.rectSize = exports.rectSizeArray = void 0;
6
6
 
7
7
  const vutils_1 = require("@visactor/vutils"), base_1 = require("./base");
8
8
 
9
- function rect(ctx, size, x, y) {
9
+ function rectSizeArray(ctx, size, x, y) {
10
10
  return ctx.rect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]), !1;
11
11
  }
12
12
 
13
- exports.rect = rect;
13
+ function rectSize(ctx, size, x, y) {
14
+ const w = size, h = size / 2;
15
+ return ctx.rect(x - w / 2, y - h / 2, w, h), !1;
16
+ }
17
+
18
+ exports.rectSizeArray = rectSizeArray, exports.rectSize = rectSize;
14
19
 
15
20
  class RectSymbol extends base_1.BaseSymbol {
16
21
  constructor() {
17
- super(...arguments), this.type = "rect", this.pathStr = "M-0.5,-0.5h1v1h-1Z";
22
+ super(...arguments), this.type = "rect", this.pathStr = "M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z";
18
23
  }
19
24
  draw(ctx, size, x, y) {
20
- return rect(ctx, (0, vutils_1.isNumber)(size) ? [ size, size ] : size, x, y);
25
+ return (0, vutils_1.isNumber)(size) ? rectSize(ctx, size, x, y) : rectSizeArray(ctx, size, x, y);
21
26
  }
22
27
  drawOffset(ctx, size, x, y, offset) {
23
- return rect(ctx, (0, vutils_1.isNumber)(size) ? [ size + 2 * offset, size + 2 * offset ] : [ size[0] + 2 * offset, size[1] + 2 * offset ], x, y);
28
+ return (0, vutils_1.isNumber)(size) ? rectSize(ctx, size + 2 * offset, x, y) : rectSizeArray(ctx, [ size[0] + 2 * offset, size[1] + 2 * offset ], x, y);
24
29
  }
25
30
  }
26
31
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/builtin-symbol/rect.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE5C,iCAAoC;AAiCpC,SAAgB,IAAI,CAAC,GAAe,EAAE,IAAsB,EAAE,CAAS,EAAE,CAAS;IAChF,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,KAAK,CAAC;AACf,CAAC;AAHD,oBAGC;AAGD,MAAa,UAAW,SAAQ,iBAAU;IAA1C;;QACE,SAAI,GAAe,MAAM,CAAC;QAC1B,YAAO,GAAW,oBAAoB,CAAC;IAazC,CAAC;IAXC,IAAI,CAAC,GAAe,EAAE,IAA+B,EAAE,CAAS,EAAE,CAAS;QACzE,MAAM,QAAQ,GAAqB,IAAA,iBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxE,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;IAED,UAAU,CAAC,GAAe,EAAE,IAA+B,EAAE,CAAS,EAAE,CAAS,EAAE,MAAc;QAC/F,MAAM,QAAQ,GAAqB,IAAA,iBAAQ,EAAC,IAAI,CAAC;YAC/C,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,MAAM,EAAE,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC;YACxC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,CAAC;CACF;AAfD,gCAeC;AAED,kBAAe,IAAI,UAAU,EAAE,CAAC","file":"rect.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport { isNumber } from '@visactor/vutils';\nimport type { IContext2d, SymbolType, ISymbolClass } from '../../interface';\nimport { BaseSymbol } from './base';\n\n/**\n * 部分源码参考 https://github.com/vega/vega/blob/main/packages/vega-scenegraph/src/path/symbols.js\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function rect(ctx: IContext2d, size: [number, number], x: number, y: number) {\n ctx.rect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]);\n return false;\n}\n\n// 以中心为锚点,size为circle外接正方形的面积\nexport class RectSymbol extends BaseSymbol implements ISymbolClass {\n type: SymbolType = 'rect';\n pathStr: string = 'M-0.5,-0.5h1v1h-1Z';\n\n draw(ctx: IContext2d, size: number | [number, number], x: number, y: number) {\n const rectSize: [number, number] = isNumber(size) ? [size, size] : size;\n return rect(ctx, rectSize, x, y);\n }\n\n drawOffset(ctx: IContext2d, size: number | [number, number], x: number, y: number, offset: number) {\n const rectSize: [number, number] = isNumber(size)\n ? [size + 2 * offset, size + 2 * offset]\n : [size[0] + 2 * offset, size[1] + 2 * offset];\n return rect(ctx, rectSize, x, y);\n }\n}\n\nexport default new RectSymbol();\n"]}
1
+ {"version":3,"sources":["../src/graphic/builtin-symbol/rect.ts"],"names":[],"mappings":";;;AACA,6CAA4C;AAE5C,iCAAoC;AAiCpC,SAAgB,aAAa,CAAC,GAAe,EAAE,IAAsB,EAAE,CAAS,EAAE,CAAS;IACzF,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,OAAO,KAAK,CAAC;AACf,CAAC;AAHD,sCAGC;AAED,SAAgB,QAAQ,CAAC,GAAe,EAAE,IAAY,EAAE,CAAS,EAAE,CAAS;IAC1E,MAAM,CAAC,GAAG,IAAI,CAAC;IACf,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IACnB,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC;AALD,4BAKC;AAGD,MAAa,UAAW,SAAQ,iBAAU;IAA1C;;QACE,SAAI,GAAe,MAAM,CAAC;QAC1B,YAAO,GAAW,mDAAmD,CAAC;IAiBxE,CAAC;IAfC,IAAI,CAAC,GAAe,EAAE,IAA+B,EAAE,CAAS,EAAE,CAAS;QACzE,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,EAAE;YAClB,OAAO,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SAClC;QACD,OAAO,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAGxC,CAAC;IAED,UAAU,CAAC,GAAe,EAAE,IAA+B,EAAE,CAAS,EAAE,CAAS,EAAE,MAAc;QAC/F,IAAI,IAAA,iBAAQ,EAAC,IAAI,CAAC,EAAE;YAClB,OAAO,QAAQ,CAAC,GAAG,EAAE,IAAI,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;SAC/C;QACD,OAAO,aAAa,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAChF,CAAC;CACF;AAnBD,gCAmBC;AAED,kBAAe,IAAI,UAAU,EAAE,CAAC","file":"rect.js","sourcesContent":["import type { IBounds } from '@visactor/vutils';\nimport { isNumber } from '@visactor/vutils';\nimport type { IContext2d, SymbolType, ISymbolClass } from '../../interface';\nimport { BaseSymbol } from './base';\n\n/**\n * 部分源码参考 https://github.com/vega/vega/blob/main/packages/vega-scenegraph/src/path/symbols.js\n * Copyright (c) 2015-2023, University of Washington Interactive Data Lab\n All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n 1. Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n\n 2. Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n 3. Neither the name of the copyright holder nor the names of its contributors\n may be used to endorse or promote products derived from this software\n without specific prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE\n FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nexport function rectSizeArray(ctx: IContext2d, size: [number, number], x: number, y: number) {\n ctx.rect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]);\n return false;\n}\n\nexport function rectSize(ctx: IContext2d, size: number, x: number, y: number) {\n const w = size;\n const h = size / 2;\n ctx.rect(x - w / 2, y - h / 2, w, h);\n return false;\n}\n\n// 以中心为锚点,size为circle外接正方形的面积\nexport class RectSymbol extends BaseSymbol implements ISymbolClass {\n type: SymbolType = 'rect';\n pathStr: string = 'M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z';\n\n draw(ctx: IContext2d, size: number | [number, number], x: number, y: number) {\n if (isNumber(size)) {\n return rectSize(ctx, size, x, y);\n }\n return rectSizeArray(ctx, size, x, y);\n // const rectSize: [number, number] = ? [size, size] : size;\n // return rect(ctx, rectSize, x, y);\n }\n\n drawOffset(ctx: IContext2d, size: number | [number, number], x: number, y: number, offset: number) {\n if (isNumber(size)) {\n return rectSize(ctx, size + 2 * offset, x, y);\n }\n return rectSizeArray(ctx, [size[0] + 2 * offset, size[1] + 2 * offset], x, y);\n }\n}\n\nexport default new RectSymbol();\n"]}
package/dist/index.js CHANGED
@@ -15569,28 +15569,36 @@
15569
15569
  }
15570
15570
  var close$1 = new CloseSymbol();
15571
15571
 
15572
- function rect(ctx, size, x, y) {
15572
+ function rectSizeArray(ctx, size, x, y) {
15573
15573
  ctx.rect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]);
15574
15574
  return false;
15575
15575
  }
15576
+ function rectSize(ctx, size, x, y) {
15577
+ const w = size;
15578
+ const h = size / 2;
15579
+ ctx.rect(x - w / 2, y - h / 2, w, h);
15580
+ return false;
15581
+ }
15576
15582
  class RectSymbol extends BaseSymbol {
15577
15583
  constructor() {
15578
15584
  super(...arguments);
15579
15585
  this.type = 'rect';
15580
- this.pathStr = 'M-0.5,-0.5h1v1h-1Z';
15586
+ this.pathStr = 'M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z';
15581
15587
  }
15582
15588
  draw(ctx, size, x, y) {
15583
- const rectSize = vutils.isNumber(size) ? [size, size] : size;
15584
- return rect(ctx, rectSize, x, y);
15589
+ if (vutils.isNumber(size)) {
15590
+ return rectSize(ctx, size, x, y);
15591
+ }
15592
+ return rectSizeArray(ctx, size, x, y);
15585
15593
  }
15586
15594
  drawOffset(ctx, size, x, y, offset) {
15587
- const rectSize = vutils.isNumber(size)
15588
- ? [size + 2 * offset, size + 2 * offset]
15589
- : [size[0] + 2 * offset, size[1] + 2 * offset];
15590
- return rect(ctx, rectSize, x, y);
15595
+ if (vutils.isNumber(size)) {
15596
+ return rectSize(ctx, size + 2 * offset, x, y);
15597
+ }
15598
+ return rectSizeArray(ctx, [size[0] + 2 * offset, size[1] + 2 * offset], x, y);
15591
15599
  }
15592
15600
  }
15593
- var rect$1 = new RectSymbol();
15601
+ var rect = new RectSymbol();
15594
15602
 
15595
15603
  const tempBounds = new vutils.AABBBounds();
15596
15604
  class CustomSymbolClass {
@@ -15680,7 +15688,7 @@
15680
15688
  arrow2Right$1,
15681
15689
  arrow2Up$1,
15682
15690
  arrow2Down$1,
15683
- rect$1,
15691
+ rect,
15684
15692
  lineV$1,
15685
15693
  lineH$1,
15686
15694
  close$1
@@ -15692,7 +15700,6 @@
15692
15700
  const builtInSymbolStrMap = {
15693
15701
  arrowLeft: 'M 0.25 -0.5 L -0.25 0 l 0.5 0.5',
15694
15702
  arrowRight: 'M -0.25 -0.5 l 0.5 0.5 l -0.5 0.5',
15695
- rect: 'M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z',
15696
15703
  rectRound: 'M 0.3 -0.5 C 0.41 -0.5 0.5 -0.41 0.5 -0.3 C 0.5 -0.3 0.5 0.3 0.5 0.3 C 0.5 0.41 0.41 0.5 0.3 0.5 C 0.3 0.5 -0.3 0.5 -0.3 0.5 C -0.41 0.5 -0.5 0.41 -0.5 0.3 C -0.5 0.3 -0.5 -0.3 -0.5 -0.3 C -0.5 -0.41 -0.41 -0.5 -0.3 -0.5 C -0.3 -0.5 0.3 -0.5 0.3 -0.5 Z',
15697
15704
  roundLine: 'M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z'
15698
15705
  };