@visactor/vrender-components 0.14.9-alpha.1 → 0.14.9-alpha.4

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 (159) hide show
  1. package/cjs/axis/animate/group-transition.d.ts +2 -1
  2. package/cjs/axis/animate/group-transition.js +3 -3
  3. package/cjs/axis/animate/group-transition.js.map +1 -1
  4. package/cjs/axis/base.d.ts +5 -8
  5. package/cjs/axis/base.js +16 -32
  6. package/cjs/axis/base.js.map +1 -1
  7. package/cjs/axis/circle.d.ts +3 -23
  8. package/cjs/axis/circle.js +3 -84
  9. package/cjs/axis/circle.js.map +1 -1
  10. package/cjs/axis/config.d.ts +0 -17
  11. package/cjs/axis/config.js +0 -17
  12. package/cjs/axis/config.js.map +1 -1
  13. package/cjs/axis/grid/base.d.ts +24 -0
  14. package/cjs/axis/{grid.js → grid/base.js} +67 -20
  15. package/cjs/axis/grid/base.js.map +1 -0
  16. package/cjs/axis/grid/circle.d.ts +9 -0
  17. package/cjs/axis/grid/circle.js +92 -0
  18. package/cjs/axis/grid/circle.js.map +1 -0
  19. package/cjs/axis/grid/index.d.ts +3 -0
  20. package/cjs/axis/grid/index.js +22 -0
  21. package/cjs/axis/grid/index.js.map +1 -0
  22. package/cjs/axis/grid/line.d.ts +10 -0
  23. package/cjs/axis/grid/line.js +103 -0
  24. package/cjs/axis/grid/line.js.map +1 -0
  25. package/cjs/axis/grid/type.d.ts +63 -0
  26. package/cjs/axis/grid/type.js +6 -0
  27. package/cjs/axis/grid/type.js.map +1 -0
  28. package/cjs/axis/index.d.ts +0 -1
  29. package/cjs/axis/index.js +3 -3
  30. package/cjs/axis/index.js.map +1 -1
  31. package/cjs/axis/line.d.ts +3 -24
  32. package/cjs/axis/line.js +17 -118
  33. package/cjs/axis/line.js.map +1 -1
  34. package/cjs/axis/mixin/circle.d.ts +17 -0
  35. package/cjs/axis/mixin/circle.js +30 -0
  36. package/cjs/axis/mixin/circle.js.map +1 -0
  37. package/cjs/axis/mixin/line.d.ts +14 -0
  38. package/cjs/axis/mixin/line.js +32 -0
  39. package/cjs/axis/mixin/line.js.map +1 -0
  40. package/cjs/axis/type.d.ts +0 -55
  41. package/cjs/axis/type.js.map +1 -1
  42. package/cjs/core/base.d.ts +2 -1
  43. package/cjs/core/base.js +4 -2
  44. package/cjs/core/base.js.map +1 -1
  45. package/cjs/core/type.js +2 -1
  46. package/cjs/crosshair/base.js +1 -2
  47. package/cjs/index.d.ts +3 -1
  48. package/cjs/index.js +9 -8
  49. package/cjs/index.js.map +1 -1
  50. package/cjs/indicator/type.js +2 -1
  51. package/cjs/jsx/component-type.d.ts +4 -0
  52. package/cjs/jsx/component-type.js +13 -0
  53. package/cjs/jsx/component-type.js.map +1 -0
  54. package/cjs/jsx/index.d.ts +1 -0
  55. package/cjs/jsx/index.js +21 -0
  56. package/cjs/jsx/index.js.map +1 -0
  57. package/cjs/label/arc.js +5 -4
  58. package/cjs/label/arc.js.map +1 -1
  59. package/cjs/label/base.js +4 -2
  60. package/cjs/label/base.js.map +1 -1
  61. package/cjs/label/type.d.ts +4 -3
  62. package/cjs/label/type.js.map +1 -1
  63. package/cjs/legend/discrete/discrete.js +28 -27
  64. package/cjs/legend/discrete/discrete.js.map +1 -1
  65. package/cjs/link-path/index.js +1 -2
  66. package/cjs/link-path/link-path.js +2 -1
  67. package/cjs/marker/point.js +1 -1
  68. package/cjs/pager/pager.js +4 -2
  69. package/cjs/pager/pager.js.map +1 -1
  70. package/cjs/poptip/register.d.ts +1 -1
  71. package/cjs/poptip/register.js +8 -6
  72. package/cjs/poptip/register.js.map +1 -1
  73. package/cjs/util/matrix.d.ts +1 -1
  74. package/cjs/util/matrix.js.map +1 -1
  75. package/cjs/util/text.js +3 -3
  76. package/cjs/util/text.js.map +1 -1
  77. package/dist/index.js +684 -634
  78. package/dist/index.min.js +1 -1
  79. package/es/axis/animate/group-transition.d.ts +2 -1
  80. package/es/axis/animate/group-transition.js +3 -3
  81. package/es/axis/animate/group-transition.js.map +1 -1
  82. package/es/axis/base.d.ts +5 -8
  83. package/es/axis/base.js +15 -33
  84. package/es/axis/base.js.map +1 -1
  85. package/es/axis/circle.d.ts +3 -23
  86. package/es/axis/circle.js +4 -85
  87. package/es/axis/circle.js.map +1 -1
  88. package/es/axis/config.d.ts +0 -17
  89. package/es/axis/config.js +0 -17
  90. package/es/axis/config.js.map +1 -1
  91. package/es/axis/grid/base.d.ts +24 -0
  92. package/es/axis/{grid.js → grid/base.js} +69 -21
  93. package/es/axis/grid/base.js.map +1 -0
  94. package/es/axis/grid/circle.d.ts +9 -0
  95. package/es/axis/grid/circle.js +92 -0
  96. package/es/axis/grid/circle.js.map +1 -0
  97. package/es/axis/grid/index.d.ts +3 -0
  98. package/es/axis/grid/index.js +6 -0
  99. package/es/axis/grid/index.js.map +1 -0
  100. package/es/axis/grid/line.d.ts +10 -0
  101. package/es/axis/grid/line.js +102 -0
  102. package/es/axis/grid/line.js.map +1 -0
  103. package/es/axis/grid/type.d.ts +63 -0
  104. package/es/axis/grid/type.js +2 -0
  105. package/es/axis/grid/type.js.map +1 -0
  106. package/es/axis/index.d.ts +0 -1
  107. package/es/axis/index.js +0 -2
  108. package/es/axis/index.js.map +1 -1
  109. package/es/axis/line.d.ts +3 -24
  110. package/es/axis/line.js +9 -110
  111. package/es/axis/line.js.map +1 -1
  112. package/es/axis/mixin/circle.d.ts +17 -0
  113. package/es/axis/mixin/circle.js +25 -0
  114. package/es/axis/mixin/circle.js.map +1 -0
  115. package/es/axis/mixin/line.d.ts +14 -0
  116. package/es/axis/mixin/line.js +23 -0
  117. package/es/axis/mixin/line.js.map +1 -0
  118. package/es/axis/type.d.ts +0 -55
  119. package/es/axis/type.js.map +1 -1
  120. package/es/core/base.d.ts +2 -1
  121. package/es/core/base.js +3 -3
  122. package/es/core/base.js.map +1 -1
  123. package/es/core/type.js +2 -1
  124. package/es/crosshair/base.js +1 -2
  125. package/es/index.d.ts +3 -1
  126. package/es/index.js +5 -1
  127. package/es/index.js.map +1 -1
  128. package/es/indicator/type.js +2 -1
  129. package/es/jsx/component-type.d.ts +4 -0
  130. package/es/jsx/component-type.js +5 -0
  131. package/es/jsx/component-type.js.map +1 -0
  132. package/es/jsx/index.d.ts +1 -0
  133. package/es/jsx/index.js +2 -0
  134. package/es/jsx/index.js.map +1 -0
  135. package/es/label/arc.js +5 -4
  136. package/es/label/arc.js.map +1 -1
  137. package/es/label/base.js +4 -2
  138. package/es/label/base.js.map +1 -1
  139. package/es/label/type.d.ts +4 -3
  140. package/es/label/type.js.map +1 -1
  141. package/es/legend/discrete/discrete.js +26 -25
  142. package/es/legend/discrete/discrete.js.map +1 -1
  143. package/es/link-path/index.js +1 -2
  144. package/es/link-path/link-path.js +2 -1
  145. package/es/marker/point.js +1 -1
  146. package/es/pager/pager.js +4 -2
  147. package/es/pager/pager.js.map +1 -1
  148. package/es/poptip/register.d.ts +1 -1
  149. package/es/poptip/register.js +7 -6
  150. package/es/poptip/register.js.map +1 -1
  151. package/es/util/matrix.d.ts +1 -1
  152. package/es/util/matrix.js.map +1 -1
  153. package/es/util/text.js +3 -3
  154. package/es/util/text.js.map +1 -1
  155. package/package.json +2 -2
  156. package/cjs/axis/grid.d.ts +0 -9
  157. package/cjs/axis/grid.js.map +0 -1
  158. package/es/axis/grid.d.ts +0 -9
  159. package/es/axis/grid.js.map +0 -1
@@ -6,17 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
 
7
7
  const vrender_1 = require("@visactor/vrender"), inversify_1 = require("inversify"), vutils_1 = require("@visactor/vutils"), contribution_1 = require("./contribution"), poptip_plugin_1 = require("./poptip-plugin"), theme_1 = require("./theme");
8
8
 
9
- function loadPoptip(defaultPoptipTheme) {
10
- (0, vutils_1.merge)(theme_1.theme.poptip, defaultPoptipTheme), vrender_1.container.load(exports.popTipModule);
9
+ function loadPoptip() {
10
+ vrender_1.container.load(exports.popTipModule);
11
11
  }
12
12
 
13
13
  function setPoptipTheme(defaultPoptipTheme) {
14
14
  (0, vutils_1.merge)(theme_1.theme.poptip, theme_1.DEFAULT_THEME, defaultPoptipTheme);
15
15
  }
16
16
 
17
- exports.popTipModule = new inversify_1.ContainerModule((bind => {
18
- bind(contribution_1.PopTipRenderContribution).toSelf().inSingletonScope(), bind(vrender_1.InteractiveSubRenderContribution).toService(contribution_1.PopTipRenderContribution),
19
- bind(poptip_plugin_1.PopTipPlugin).toSelf().inSingletonScope(), bind(vrender_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipPlugin),
20
- bind(poptip_plugin_1.PopTipForClipedTextPlugin).toSelf().inSingletonScope(), bind(vrender_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipForClipedTextPlugin);
17
+ exports.popTipModule = new inversify_1.ContainerModule(((bind, unbind, isBound, rebind) => {
18
+ isBound(contribution_1.PopTipRenderContribution) || (bind(contribution_1.PopTipRenderContribution).toSelf().inSingletonScope(),
19
+ bind(vrender_1.InteractiveSubRenderContribution).toService(contribution_1.PopTipRenderContribution)),
20
+ isBound(poptip_plugin_1.PopTipPlugin) || (bind(poptip_plugin_1.PopTipPlugin).toSelf(),
21
+ bind(vrender_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipPlugin)), isBound(poptip_plugin_1.PopTipForClipedTextPlugin) || (bind(poptip_plugin_1.PopTipForClipedTextPlugin).toSelf(),
22
+ bind(vrender_1.AutoEnablePlugins).toService(poptip_plugin_1.PopTipForClipedTextPlugin));
21
23
  })), exports.loadPoptip = loadPoptip, exports.setPoptipTheme = setPoptipTheme;
22
24
  //# sourceMappingURL=register.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":";;;AAAA,+CAAmG;AACnG,yCAA4C;AAC5C,6CAAyC;AACzC,iDAA0D;AAC1D,mDAA0E;AAE1E,mCAA+C;AAElC,QAAA,YAAY,GAAG,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACrD,IAAI,CAAC,uCAAwB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC3D,IAAI,CAAC,0CAAgC,CAAC,CAAC,SAAS,CAAC,uCAAwB,CAAC,CAAC;IAE3E,IAAI,CAAC,4BAAY,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC/C,IAAI,CAAC,2BAAiB,CAAC,CAAC,SAAS,CAAC,4BAAY,CAAC,CAAC;IAEhD,IAAI,CAAC,yCAAyB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC5D,IAAI,CAAC,2BAAiB,CAAC,CAAC,SAAS,CAAC,yCAAyB,CAAC,CAAC;AAC/D,CAAC,CAAC,CAAC;AAEH,SAAgB,UAAU,CAAC,kBAAoC;IAC7D,IAAA,cAAK,EAAC,aAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACxC,mBAAS,CAAC,IAAI,CAAC,oBAAY,CAAC,CAAC;AAC/B,CAAC;AAHD,gCAGC;AAED,SAAgB,cAAc,CAAC,kBAAoC;IACjE,IAAA,cAAK,EAAC,aAAK,CAAC,MAAM,EAAE,qBAAa,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAFD,wCAEC","file":"register.js","sourcesContent":["import { container, InteractiveSubRenderContribution, AutoEnablePlugins } from '@visactor/vrender';\nimport { ContainerModule } from 'inversify';\nimport { merge } from '@visactor/vutils';\nimport { PopTipRenderContribution } from './contribution';\nimport { PopTipPlugin, PopTipForClipedTextPlugin } from './poptip-plugin';\nimport type { PopTipAttributes } from './type';\nimport { DEFAULT_THEME, theme } from './theme';\n\nexport const popTipModule = new ContainerModule(bind => {\n bind(PopTipRenderContribution).toSelf().inSingletonScope();\n bind(InteractiveSubRenderContribution).toService(PopTipRenderContribution);\n\n bind(PopTipPlugin).toSelf().inSingletonScope();\n bind(AutoEnablePlugins).toService(PopTipPlugin);\n\n bind(PopTipForClipedTextPlugin).toSelf().inSingletonScope();\n bind(AutoEnablePlugins).toService(PopTipForClipedTextPlugin);\n});\n\nexport function loadPoptip(defaultPoptipTheme: PopTipAttributes) {\n merge(theme.poptip, defaultPoptipTheme);\n container.load(popTipModule);\n}\n\nexport function setPoptipTheme(defaultPoptipTheme: PopTipAttributes) {\n merge(theme.poptip, DEFAULT_THEME, defaultPoptipTheme);\n}\n"]}
1
+ {"version":3,"sources":["../src/poptip/register.ts"],"names":[],"mappings":";;;AAAA,+CAAmG;AACnG,yCAA4C;AAC5C,6CAAyC;AACzC,iDAA0D;AAC1D,mDAA0E;AAE1E,mCAA+C;AAElC,QAAA,YAAY,GAAG,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAChF,IAAI,CAAC,OAAO,CAAC,uCAAwB,CAAC,EAAE;QACtC,IAAI,CAAC,uCAAwB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAC3D,IAAI,CAAC,0CAAgC,CAAC,CAAC,SAAS,CAAC,uCAAwB,CAAC,CAAC;KAC5E;IACD,IAAI,CAAC,OAAO,CAAC,4BAAY,CAAC,EAAE;QAC1B,IAAI,CAAC,4BAAY,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,2BAAiB,CAAC,CAAC,SAAS,CAAC,4BAAY,CAAC,CAAC;KACjD;IACD,IAAI,CAAC,OAAO,CAAC,yCAAyB,CAAC,EAAE;QACvC,IAAI,CAAC,yCAAyB,CAAC,CAAC,MAAM,EAAE,CAAC;QACzC,IAAI,CAAC,2BAAiB,CAAC,CAAC,SAAS,CAAC,yCAAyB,CAAC,CAAC;KAC9D;AACH,CAAC,CAAC,CAAC;AAEH,SAAgB,UAAU;IACxB,mBAAS,CAAC,IAAI,CAAC,oBAAY,CAAC,CAAC;AAC/B,CAAC;AAFD,gCAEC;AAED,SAAgB,cAAc,CAAC,kBAAoC;IACjE,IAAA,cAAK,EAAC,aAAK,CAAC,MAAM,EAAE,qBAAa,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAFD,wCAEC","file":"register.js","sourcesContent":["import { container, InteractiveSubRenderContribution, AutoEnablePlugins } from '@visactor/vrender';\nimport { ContainerModule } from 'inversify';\nimport { merge } from '@visactor/vutils';\nimport { PopTipRenderContribution } from './contribution';\nimport { PopTipPlugin, PopTipForClipedTextPlugin } from './poptip-plugin';\nimport type { PopTipAttributes } from './type';\nimport { DEFAULT_THEME, theme } from './theme';\n\nexport const popTipModule = new ContainerModule((bind, unbind, isBound, rebind) => {\n if (!isBound(PopTipRenderContribution)) {\n bind(PopTipRenderContribution).toSelf().inSingletonScope();\n bind(InteractiveSubRenderContribution).toService(PopTipRenderContribution);\n }\n if (!isBound(PopTipPlugin)) {\n bind(PopTipPlugin).toSelf();\n bind(AutoEnablePlugins).toService(PopTipPlugin);\n }\n if (!isBound(PopTipForClipedTextPlugin)) {\n bind(PopTipForClipedTextPlugin).toSelf();\n bind(AutoEnablePlugins).toService(PopTipForClipedTextPlugin);\n }\n});\n\nexport function loadPoptip() {\n container.load(popTipModule);\n}\n\nexport function setPoptipTheme(defaultPoptipTheme: PopTipAttributes) {\n merge(theme.poptip, DEFAULT_THEME, defaultPoptipTheme);\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  export type Vector2 = [number, number];
2
- export declare function scale(vector: Vector2, scale: number): number[];
2
+ export declare function scale(vector: Vector2, scale: number): [number, number];
3
3
  export declare function length(vector: Vector2): number;
4
4
  export declare function normalize(vector: Vector2): number[];
5
5
  export declare function angle(vector1: Vector2, vector2: Vector2): number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/util/matrix.ts"],"names":[],"mappings":";;;AAKA,SAAgB,KAAK,CAAC,MAAe,EAAE,KAAa;IAClD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAChD,CAAC;AAFD,sBAEC;AAKD,SAAgB,MAAM,CAAC,MAAe;IACpC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AAE,EAAY;IAClD,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAFD,8BAEC;AAQD,SAAgB,OAAO,CAAC,EAAoB,EAAE,EAAoB,EAAE,MAAe;IACjF,MAAM,GAAG,GAAG,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAC1B,MAAM,gBAAgB,GAAG,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,MAAM,EAAE;QACV,IAAI,gBAAgB,EAAE;YACpB,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;SAC1B;QACD,OAAO,GAAG,CAAC;KACZ;IAED,IAAI,gBAAgB,EAAE;QACpB,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC;AAdD,0BAcC","file":"matrix.js","sourcesContent":["export type Vector2 = [number, number];\n\n/**\n * Scales a vec2 by a scalar number\n */\nexport function scale(vector: Vector2, scale: number) {\n return [vector[0] * scale, vector[1] * scale];\n}\n\n/**\n * Calculates the length of a vec2\n */\nexport function length(vector: Vector2) {\n const [x, y] = vector;\n return Math.sqrt(x * x + y * y);\n}\n\n/**\n * Normalize a vec2\n */\nexport function normalize(vector: Vector2) {\n const [x, y] = vector;\n let len = x * x + y * y;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n return [vector[0] * len, vector[1] * len];\n}\n\n/**\n * Get the angle between two 2D vectors\n */\nexport function angle(vector1: Vector2, vector2: Vector2) {\n const [x1, y1] = vector1;\n const [x2, y2] = vector2;\n const mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));\n const cosine = mag && (x1 * x2 + y1 * y2) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n\n/**\n * 向量 v1 到 向量 v2 夹角的方向\n * @param {Array} v1 向量\n * @param {Array} v2 向量\n * @return {Boolean} >= 0 顺时针 < 0 逆时针\n */\nexport function direction(v1: number[], v2: number[]): number {\n return v1[0] * v2[1] - v2[0] * v1[1];\n}\n\n/**\n * 二维向量 v1 到 v2 的夹角\n * @param v1\n * @param v2\n * @param direct\n */\nexport function angleTo(v1: [number, number], v2: [number, number], direct: boolean): number {\n const ang = angle(v1, v2);\n const angleLargeThanPI = direction(v1, v2) >= 0;\n if (direct) {\n if (angleLargeThanPI) {\n return Math.PI * 2 - ang;\n }\n return ang;\n }\n\n if (angleLargeThanPI) {\n return ang;\n }\n return Math.PI * 2 - ang;\n}\n"]}
1
+ {"version":3,"sources":["../src/util/matrix.ts"],"names":[],"mappings":";;;AAKA,SAAgB,KAAK,CAAC,MAAe,EAAE,KAAa;IAClD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;AAChD,CAAC;AAFD,sBAEC;AAKD,SAAgB,MAAM,CAAC,MAAe;IACpC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;IACtB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC,CAAC;AAHD,wBAGC;AAKD,SAAgB,SAAS,CAAC,MAAe;IACvC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC;IACtB,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,GAAG,GAAG,CAAC,EAAE;QACX,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC1B;IACD,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM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;KACZ;IAED,IAAI,gBAAgB,EAAE;QACpB,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAC3B,CAAC;AAdD,0BAcC","file":"matrix.js","sourcesContent":["export type Vector2 = [number, number];\n\n/**\n * Scales a vec2 by a scalar number\n */\nexport function scale(vector: Vector2, scale: number): [number, number] {\n return [vector[0] * scale, vector[1] * scale];\n}\n\n/**\n * Calculates the length of a vec2\n */\nexport function length(vector: Vector2) {\n const [x, y] = vector;\n return Math.sqrt(x * x + y * y);\n}\n\n/**\n * Normalize a vec2\n */\nexport function normalize(vector: Vector2) {\n const [x, y] = vector;\n let len = x * x + y * y;\n if (len > 0) {\n len = 1 / Math.sqrt(len);\n }\n return [vector[0] * len, vector[1] * len];\n}\n\n/**\n * Get the angle between two 2D vectors\n */\nexport function angle(vector1: Vector2, vector2: Vector2) {\n const [x1, y1] = vector1;\n const [x2, y2] = vector2;\n const mag = Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2));\n const cosine = mag && (x1 * x2 + y1 * y2) / mag;\n return Math.acos(Math.min(Math.max(cosine, -1), 1));\n}\n\n/**\n * 向量 v1 到 向量 v2 夹角的方向\n * @param {Array} v1 向量\n * @param {Array} v2 向量\n * @return {Boolean} >= 0 顺时针 < 0 逆时针\n */\nexport function direction(v1: number[], v2: number[]): number {\n return v1[0] * v2[1] - v2[0] * v1[1];\n}\n\n/**\n * 二维向量 v1 到 v2 的夹角\n * @param v1\n * @param v2\n * @param direct\n */\nexport function angleTo(v1: [number, number], v2: [number, number], direct: boolean): number {\n const ang = angle(v1, v2);\n const angleLargeThanPI = direction(v1, v2) >= 0;\n if (direct) {\n if (angleLargeThanPI) {\n return Math.PI * 2 - ang;\n }\n return ang;\n }\n\n if (angleLargeThanPI) {\n return ang;\n }\n return Math.PI * 2 - ang;\n}\n"]}
package/cjs/util/text.js CHANGED
@@ -14,17 +14,17 @@ const vrender_1 = require("@visactor/vrender"), vutils_1 = require("@visactor/vu
14
14
  }, null != option ? option : {}), textSpec);
15
15
 
16
16
  function measureTextSize(text, textSpec) {
17
- var _a, _b;
17
+ var _a;
18
18
  if (!text) return {
19
19
  width: 0,
20
20
  height: 0
21
21
  };
22
22
  const bounds = (0, vrender_1.getTextBounds)({
23
23
  text: text,
24
- fontFamily: null !== (_a = textSpec.fontFamily) && void 0 !== _a ? _a : "",
24
+ fontFamily: textSpec.fontFamily,
25
25
  fontSize: textSpec.fontSize || 12,
26
26
  fontWeight: textSpec.fontWeight,
27
- textAlign: null !== (_b = textSpec.textAlign) && void 0 !== _b ? _b : "center",
27
+ textAlign: null !== (_a = textSpec.textAlign) && void 0 !== _a ? _a : "center",
28
28
  textBaseline: textSpec.textBaseline,
29
29
  ellipsis: !!textSpec.ellipsis,
30
30
  maxLineWidth: textSpec.maxLineWidth || 1 / 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":";;;AAEA,+CAAkD;AAGlD,6CAA+C;AAC/C,0CAA+E;AAExE,MAAM,eAAe,GAAG,CAC7B,QAAyC,EACzC,MAAoC,EACpC,cAAwB,EACY,EAAE;IACtC,OAAO,IAAI,oBAAW,iBAElB,iBAAiB,EAAE;YACjB,UAAU,EAAE,mCAAwB;YACpC,QAAQ,EAAE,iCAAsB;SACjC,EACD,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAa,EACzD,cAAc,EAAE,cAAc,GAAG,oBAAW,CAAC,iBAAiB,GAAG,oBAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE,IACzG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAEnB,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B;AAGF,SAAgB,eAAe,CAAC,IAA2C,EAAE,QAAwC;;IACnH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KAChC;IACD,MAAM,MAAM,GAAG,IAAA,uBAAa,EAAC;QAC3B,IAAI;QACJ,UAAU,EAAE,MAAA,QAAQ,CAAC,UAAU,mCAAI,EAAE;QACrC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;QACjC,UAAU,EAAE,QAAQ,CAAC,UAAiB;QACtC,SAAS,EAAE,MAAA,QAAQ,CAAC,SAAS,mCAAI,QAAQ;QACzC,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ;QAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,QAAQ;QAC/C,UAAU,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;KACpC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;AAC5D,CAAC;AAjBD,0CAiBC","file":"text.js","sourcesContent":["import type { ITextGraphicAttribute } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTextBounds } from '@visactor/vrender';\nimport type { ITextMeasureOption } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { TextMeasure } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(text: string | number | string[] | number[], textSpec: Partial<ITextGraphicAttribute>) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily ?? '',\n fontSize: textSpec.fontSize || 12,\n fontWeight: textSpec.fontWeight as any,\n textAlign: textSpec.textAlign ?? 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n"]}
1
+ {"version":3,"sources":["../src/util/text.ts"],"names":[],"mappings":";;;AAEA,+CAAkD;AAGlD,6CAA+C;AAC/C,0CAA+E;AAExE,MAAM,eAAe,GAAG,CAC7B,QAAyC,EACzC,MAAoC,EACpC,cAAwB,EACY,EAAE;IACtC,OAAO,IAAI,oBAAW,iBAElB,iBAAiB,EAAE;YACjB,UAAU,EAAE,mCAAwB;YACpC,QAAQ,EAAE,iCAAsB;SACjC,EACD,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAa,EACzD,cAAc,EAAE,cAAc,GAAG,oBAAW,CAAC,iBAAiB,GAAG,oBAAW,CAAC,iBAAiB,CAAC,WAAW,EAAE,IACzG,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAEnB,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B;AAGF,SAAgB,eAAe,CAAC,IAA2C,EAAE,QAAwC;;IACnH,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;KAChC;IACD,MAAM,MAAM,GAAG,IAAA,uBAAa,EAAC;QAC3B,IAAI;QACJ,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;QACjC,UAAU,EAAE,QAAQ,CAAC,UAAiB;QACtC,SAAS,EAAE,MAAA,QAAQ,CAAC,SAAS,mCAAI,QAAQ;QACzC,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ;QAC7B,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,QAAQ;QAC/C,UAAU,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;KACpC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;AAC5D,CAAC;AAjBD,0CAiBC","file":"text.js","sourcesContent":["import type { ITextGraphicAttribute } from '@visactor/vrender';\n// eslint-disable-next-line no-duplicate-imports\nimport { getTextBounds } from '@visactor/vrender';\nimport type { ITextMeasureOption } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { TextMeasure } from '@visactor/vutils';\nimport { DEFAULT_TEXT_FONT_FAMILY, DEFAULT_TEXT_FONT_SIZE } from '../constant';\n\nexport const initTextMeasure = (\n textSpec?: Partial<ITextGraphicAttribute>,\n option?: Partial<ITextMeasureOption>,\n useNaiveCanvas?: boolean\n): TextMeasure<ITextGraphicAttribute> => {\n return new TextMeasure<ITextGraphicAttribute>(\n {\n defaultFontParams: {\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fontSize: DEFAULT_TEXT_FONT_SIZE\n },\n getTextBounds: useNaiveCanvas ? undefined : getTextBounds,\n specialCharSet: '-/: .,@%\\'\"~' + TextMeasure.ALPHABET_CHAR_SET + TextMeasure.ALPHABET_CHAR_SET.toUpperCase(),\n ...(option ?? {})\n },\n textSpec\n );\n};\n\n// FIXME: 和上一个方法统一,使用 TextMeasure 类\nexport function measureTextSize(text: string | number | string[] | number[], textSpec: Partial<ITextGraphicAttribute>) {\n if (!text) {\n return { width: 0, height: 0 };\n }\n const bounds = getTextBounds({\n text,\n fontFamily: textSpec.fontFamily,\n fontSize: textSpec.fontSize || 12,\n fontWeight: textSpec.fontWeight as any,\n textAlign: textSpec.textAlign ?? 'center',\n textBaseline: textSpec.textBaseline,\n ellipsis: !!textSpec.ellipsis,\n maxLineWidth: textSpec.maxLineWidth || Infinity,\n lineHeight: textSpec.fontSize || 12\n });\n\n return { width: bounds.width(), height: bounds.height() };\n}\n"]}