@visactor/vrender-core 0.22.9 → 0.22.10-alpha.1

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 (68) hide show
  1. package/cjs/common/bezier-utils.js +1 -2
  2. package/cjs/common/canvas-utils.js +5 -5
  3. package/cjs/common/canvas-utils.js.map +1 -1
  4. package/cjs/common/matrix.js +1 -1
  5. package/cjs/common/morphing-utils.js +1 -1
  6. package/cjs/common/path-svg.js +1 -1
  7. package/cjs/common/polygon.js +2 -2
  8. package/cjs/common/rect-utils.js +1 -1
  9. package/cjs/common/render-area.js +2 -1
  10. package/cjs/common/render-command-list.js +1 -1
  11. package/cjs/common/render-curve.js +1 -1
  12. package/cjs/common/render-utils.js +1 -1
  13. package/cjs/common/seg-context.js +1 -1
  14. package/cjs/common/simplify.js +1 -1
  15. package/cjs/common/sort.js +1 -1
  16. package/cjs/common/split-path.js +1 -1
  17. package/cjs/core/application.js +1 -1
  18. package/cjs/core/camera.js +1 -1
  19. package/cjs/core/constants.js +1 -1
  20. package/cjs/core/core-modules.js +1 -1
  21. package/cjs/core/global-module.js +0 -2
  22. package/cjs/core/global.js +1 -1
  23. package/cjs/core/graphic-utils.js +1 -1
  24. package/cjs/core/index.js +1 -1
  25. package/cjs/core/layer-service.js +1 -1
  26. package/cjs/core/layer.js +1 -1
  27. package/cjs/core/light.js +1 -1
  28. package/cjs/core/stage.js +1 -1
  29. package/cjs/core/window.js +1 -1
  30. package/cjs/graphic/graphic.d.ts +2 -0
  31. package/cjs/graphic/graphic.js.map +1 -1
  32. package/cjs/graphic/symbol.js +2 -1
  33. package/cjs/graphic/symbol.js.map +1 -1
  34. package/dist/index.es.js +10 -6
  35. package/es/common/bezier-utils.js +1 -2
  36. package/es/common/canvas-utils.js +5 -5
  37. package/es/common/canvas-utils.js.map +1 -1
  38. package/es/common/matrix.js +1 -1
  39. package/es/common/morphing-utils.js +1 -1
  40. package/es/common/path-svg.js +1 -1
  41. package/es/common/polygon.js +1 -1
  42. package/es/common/rect-utils.js +1 -1
  43. package/es/common/render-area.js +2 -1
  44. package/es/common/render-command-list.js +1 -1
  45. package/es/common/render-curve.js +1 -1
  46. package/es/common/render-utils.js +1 -1
  47. package/es/common/seg-context.js +1 -1
  48. package/es/common/simplify.js +1 -1
  49. package/es/common/sort.js +1 -1
  50. package/es/common/split-path.js +1 -1
  51. package/es/core/application.js +1 -1
  52. package/es/core/camera.js +1 -1
  53. package/es/core/constants.js +1 -1
  54. package/es/core/core-modules.js +1 -1
  55. package/es/core/global-module.js +0 -2
  56. package/es/core/global.js +1 -1
  57. package/es/core/graphic-utils.js +1 -1
  58. package/es/core/index.js +1 -1
  59. package/es/core/layer-service.js +1 -1
  60. package/es/core/layer.js +1 -1
  61. package/es/core/light.js +1 -1
  62. package/es/core/stage.js +1 -1
  63. package/es/core/window.js +1 -1
  64. package/es/graphic/graphic.d.ts +2 -0
  65. package/es/graphic/graphic.js.map +1 -1
  66. package/es/graphic/symbol.js +2 -1
  67. package/es/graphic/symbol.js.map +1 -1
  68. package/package.json +1 -1
@@ -46,5 +46,4 @@ function quadLength(p0, p1, p2, iterationCount) {
46
46
 
47
47
  exports.snapLength = snapLength, exports.cubicLength = cubicLength, exports.cubicCalc = cubicCalc,
48
48
  exports.cubicPointAt = cubicPointAt, exports.quadCalc = quadCalc, exports.quadPointAt = quadPointAt,
49
- exports.quadLength = quadLength;
50
- //# sourceMappingURL=bezier-utils.js.map
49
+ exports.quadLength = quadLength;
@@ -14,7 +14,7 @@ function getScaledStroke(context, width, dpr) {
14
14
  }
15
15
 
16
16
  function createColor(context, c, params, offsetX = 0, offsetY = 0) {
17
- var _a, _b;
17
+ var _a, _b, _c, _d;
18
18
  if (!c || !0 === c) return "black";
19
19
  let result, color;
20
20
  if ((0, vutils_1.isArray)(c)) for (let i = 0; i < c.length && (color = c[i], !color); i++) ; else color = c;
@@ -24,9 +24,9 @@ function createColor(context, c, params, offsetX = 0, offsetY = 0) {
24
24
  let w = bounds.x2 - bounds.x1, h = bounds.y2 - bounds.y1, x = bounds.x1 - offsetX, y = bounds.y1 - offsetY;
25
25
  if (params.attribute) {
26
26
  const {scaleX: scaleX = 1, scaleY: scaleY = 1, angle: angle = 0} = params.attribute;
27
- w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY, (angle || 1 !== scaleX || 1 !== scaleY) && (x = 0,
28
- y = 0, w = null !== (_a = params.widthWithoutTransform) && void 0 !== _a ? _a : w,
29
- h = null !== (_b = params.heightWithoutTransform) && void 0 !== _b ? _b : h);
27
+ w /= scaleX, h /= scaleY, x /= scaleX, y /= scaleY, (angle || 1 !== scaleX || 1 !== scaleY) && (x = null !== (_a = params.x1WithoutTransform) && void 0 !== _a ? _a : 0,
28
+ y = null !== (_b = params.y1WithoutTransform) && void 0 !== _b ? _b : 0, w = null !== (_c = params.widthWithoutTransform) && void 0 !== _c ? _c : w,
29
+ h = null !== (_d = params.heightWithoutTransform) && void 0 !== _d ? _d : h);
30
30
  }
31
31
  "linear" === color.gradient ? result = createLinearGradient(context, color, x, y, w, h) : "conical" === color.gradient ? result = createConicGradient(context, color, x, y, w, h) : "radial" === color.gradient && (result = createRadialGradient(context, color, x, y, w, h));
32
32
  }
@@ -54,7 +54,7 @@ function createConicGradient(context, color, x, y, w, h) {
54
54
  const canvasGradient = context.createConicGradient(x + (null !== (_a = color.x) && void 0 !== _a ? _a : 0) * w, y + (null !== (_b = color.y) && void 0 !== _b ? _b : 0) * h, color.startAngle, color.endAngle);
55
55
  return color.stops.forEach((stop => {
56
56
  canvasGradient.addColorStop(stop.offset, stop.color);
57
- })), canvasGradient.GetPattern(w + x, h + y, undefined);
57
+ })), canvasGradient.GetPattern ? canvasGradient.GetPattern(w + x, h + y, undefined) : canvasGradient;
58
58
  }
59
59
 
60
60
  //# sourceMappingURL=canvas-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/canvas-utils.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AAC3C,+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AAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACzB,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,IAAI,UAAU,CAAC;IACf,OAAQ,cAAsB,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC;AACtE,CAAC","file":"canvas-utils.js","sourcesContent":["import type { IColor, IConicalGradient, ILinearGradient, IRadialGradient } from '../interface/color';\nimport type { IContext2d, ITransform } from '../interface';\nimport type { IBoundsLike } from '@visactor/vutils';\nimport { isArray } from '@visactor/vutils';\nimport { GradientParser } from './color-utils';\n\nexport function getScaledStroke(context: IContext2d, width: number, dpr: number) {\n let strokeWidth = width;\n const { a, b, c, d } = context.currentMatrix;\n const scaleX = Math.sign(a) * Math.sqrt(a * a + b * b);\n const scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);\n // 如果没有scaleX和scaleY,那么认为什么都不用绘制\n if (scaleX + scaleY === 0) {\n return 0;\n }\n strokeWidth = (strokeWidth / Math.abs(scaleX + scaleY)) * 2 * dpr;\n return strokeWidth;\n}\n\nexport function createColor(\n context: IContext2d,\n c: string | IColor | Array<string | IColor> | boolean,\n params: { AABBBounds?: IBoundsLike; attribute?: Partial<ITransform> },\n offsetX: number = 0,\n offsetY: number = 0\n): string | CanvasGradient {\n if (!c || c === true) {\n return 'black';\n }\n let result: string | CanvasGradient | undefined;\n let color: string | IColor;\n if (isArray(c)) {\n for (let i = 0; i < c.length; i++) {\n color = c[i];\n if (color) {\n break;\n }\n }\n } else {\n color = c;\n }\n color = GradientParser.Parse(color);\n if (typeof color === 'string') {\n return color;\n }\n // 如果是渐变色的话,需要根据bounds来计算渐变色的范围\n if (params.AABBBounds && (!params.attribute || params.attribute.scaleX !== 0 || params.attribute.scaleY !== 0)) {\n const bounds = params.AABBBounds;\n let w = bounds.x2 - bounds.x1;\n let h = bounds.y2 - bounds.y1;\n let x = bounds.x1 - offsetX;\n let y = bounds.y1 - offsetY;\n // 检测是否有angle、scale,如果有的话,说明context有transform。\n // 需要获取图元原始的bounds宽高,然后设置xy为0才行\n if (params.attribute) {\n const { scaleX = 1, scaleY = 1, angle = 0 } = params.attribute;\n w /= scaleX;\n h /= scaleY;\n x /= scaleX;\n y /= scaleY;\n if (angle || scaleX !== 1 || scaleY !== 1) {\n x = 0;\n y = 0;\n w = (params as any).widthWithoutTransform ?? w;\n h = (params as any).heightWithoutTransform ?? h;\n }\n }\n // TODO 不同scaleCenter有问题\n if (color.gradient === 'linear') {\n result = createLinearGradient(context, color, x, y, w, h);\n } else if (color.gradient === 'conical') {\n result = createConicGradient(context, color, x, y, w, h);\n } else if (color.gradient === 'radial') {\n result = createRadialGradient(context, color, x, y, w, h);\n }\n }\n return result || 'orange';\n}\n\nfunction createLinearGradient(context: IContext2d, color: ILinearGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createLinearGradient(\n x + (color.x0 ?? 0) * w,\n y + (color.y0 ?? 0) * h,\n x + (color.x1 ?? 1) * w,\n y + (color.y1 ?? 0) * h\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n return canvasGradient;\n}\n\nfunction createRadialGradient(context: IContext2d, color: IRadialGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createRadialGradient(\n x + (color.x0 ?? 0.5) * w,\n y + (color.y0 ?? 0.5) * h,\n Math.max(w, h) * (color.r0 ?? 0),\n x + (color.x1 ?? 0.5) * w,\n y + (color.y1 ?? 0.5) * h,\n Math.max(w, h) * (color.r1 ?? 0.5)\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n return canvasGradient;\n}\n\nfunction createConicGradient(context: IContext2d, color: IConicalGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createConicGradient(\n x + (color.x ?? 0) * w,\n y + (color.y ?? 0) * h,\n color.startAngle,\n color.endAngle\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n\n let deltaAngle;\n return (canvasGradient as any).GetPattern(w + x, h + y, deltaAngle);\n}\n"]}
1
+ {"version":3,"sources":["../src/common/canvas-utils.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AAC3C,+CAA+C;AAE/C,SAAgB,eAAe,CAAC,OAAmB,EAAE,KAAa,EAAE,GAAW;IAC7E,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAEvD,IAAI,MAAM,GAAG,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO,CAAC,CAAC;KACV;IACD,WAAW,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IAClE,OAAO,WAAW,CAAC;AACrB,CAAC;AAXD,0CAWC;AAED,SAAgB,WAAW,CACzB,OAAmB,EACnB,CAAqD,EACrD,MAAqE,EACrE,UAAkB,CAAC,EACnB,UAAkB,CAAC;;IAEnB,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;QACpB,OAAO,OAAO,CAAC;KAChB;IACD,IAAI,MAA2C,CAAC;IAChD,IAAI,KAAsB,CAAC;IAC3B,IAAI,IAAA,gBAAO,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AAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;;IACnH,MAAM,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAChD,CAAC,GAAG,CAAC,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,EACtB,CAAC,GAAG,CAAC,MAAA,KAAK,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,EACtB,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,CACf,CAAC;IACF,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACzB,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,IAAI,UAAU,CAAC;IACf,OAAQ,cAAsB,CAAC,UAAU;QACvC,CAAC,CAAE,cAAsB,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC;QAC9D,CAAC,CAAC,cAAc,CAAC;AACrB,CAAC","file":"canvas-utils.js","sourcesContent":["import type { IColor, IConicalGradient, ILinearGradient, IRadialGradient } from '../interface/color';\nimport type { IContext2d, ITransform } from '../interface';\nimport type { IBoundsLike } from '@visactor/vutils';\nimport { isArray } from '@visactor/vutils';\nimport { GradientParser } from './color-utils';\n\nexport function getScaledStroke(context: IContext2d, width: number, dpr: number) {\n let strokeWidth = width;\n const { a, b, c, d } = context.currentMatrix;\n const scaleX = Math.sign(a) * Math.sqrt(a * a + b * b);\n const scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);\n // 如果没有scaleX和scaleY,那么认为什么都不用绘制\n if (scaleX + scaleY === 0) {\n return 0;\n }\n strokeWidth = (strokeWidth / Math.abs(scaleX + scaleY)) * 2 * dpr;\n return strokeWidth;\n}\n\nexport function createColor(\n context: IContext2d,\n c: string | IColor | Array<string | IColor> | boolean,\n params: { AABBBounds?: IBoundsLike; attribute?: Partial<ITransform> },\n offsetX: number = 0,\n offsetY: number = 0\n): string | CanvasGradient {\n if (!c || c === true) {\n return 'black';\n }\n let result: string | CanvasGradient | undefined;\n let color: string | IColor;\n if (isArray(c)) {\n for (let i = 0; i < c.length; i++) {\n color = c[i];\n if (color) {\n break;\n }\n }\n } else {\n color = c;\n }\n color = GradientParser.Parse(color);\n if (typeof color === 'string') {\n return color;\n }\n // 如果是渐变色的话,需要根据bounds来计算渐变色的范围\n if (params.AABBBounds && (!params.attribute || params.attribute.scaleX !== 0 || params.attribute.scaleY !== 0)) {\n const bounds = params.AABBBounds;\n let w = bounds.x2 - bounds.x1;\n let h = bounds.y2 - bounds.y1;\n let x = bounds.x1 - offsetX;\n let y = bounds.y1 - offsetY;\n // 检测是否有angle、scale,如果有的话,说明context有transform。\n // 需要获取图元原始的bounds宽高,然后设置xy为0才行\n if (params.attribute) {\n const { scaleX = 1, scaleY = 1, angle = 0 } = params.attribute;\n w /= scaleX;\n h /= scaleY;\n x /= scaleX;\n y /= scaleY;\n if (angle || scaleX !== 1 || scaleY !== 1) {\n // symbol的时候锚点是在中间的,所以bounds不能按0算\n x = (params as any).x1WithoutTransform ?? 0;\n y = (params as any).y1WithoutTransform ?? 0;\n w = (params as any).widthWithoutTransform ?? w;\n h = (params as any).heightWithoutTransform ?? h;\n }\n }\n // TODO 不同scaleCenter有问题\n if (color.gradient === 'linear') {\n result = createLinearGradient(context, color, x, y, w, h);\n } else if (color.gradient === 'conical') {\n result = createConicGradient(context, color, x, y, w, h);\n } else if (color.gradient === 'radial') {\n result = createRadialGradient(context, color, x, y, w, h);\n }\n }\n return result || 'orange';\n}\n\nfunction createLinearGradient(context: IContext2d, color: ILinearGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createLinearGradient(\n x + (color.x0 ?? 0) * w,\n y + (color.y0 ?? 0) * h,\n x + (color.x1 ?? 1) * w,\n y + (color.y1 ?? 0) * h\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n return canvasGradient;\n}\n\nfunction createRadialGradient(context: IContext2d, color: IRadialGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createRadialGradient(\n x + (color.x0 ?? 0.5) * w,\n y + (color.y0 ?? 0.5) * h,\n Math.max(w, h) * (color.r0 ?? 0),\n x + (color.x1 ?? 0.5) * w,\n y + (color.y1 ?? 0.5) * h,\n Math.max(w, h) * (color.r1 ?? 0.5)\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n return canvasGradient;\n}\n\nfunction createConicGradient(context: IContext2d, color: IConicalGradient, x: number, y: number, w: number, h: number) {\n const canvasGradient = context.createConicGradient(\n x + (color.x ?? 0) * w,\n y + (color.y ?? 0) * h,\n color.startAngle,\n color.endAngle\n );\n color.stops.forEach(stop => {\n canvasGradient.addColorStop(stop.offset, stop.color);\n });\n\n let deltaAngle;\n return (canvasGradient as any).GetPattern\n ? (canvasGradient as any).GetPattern(w + x, h + y, deltaAngle)\n : canvasGradient;\n}\n"]}
@@ -129,4 +129,4 @@ exports.identityMat4 = identityMat4, exports.rotateX = rotateX, exports.rotateY
129
129
  exports.rotateZ = rotateZ, exports.translate = translate, exports.mat3Tomat4 = mat3Tomat4,
130
130
  exports.multiplyMat4Mat3 = multiplyMat4Mat3, exports.scaleMat4 = scaleMat4, exports.multiplyMat4Mat4 = multiplyMat4Mat4,
131
131
  exports.lookAt = lookAt, exports.ortho = ortho, exports.transformMat4 = transformMat4;
132
- //# sourceMappingURL=matrix.js.map
132
+ //# sourceMappingURL=matrix.js.map
@@ -292,4 +292,4 @@ function bezierCurversToPath(bezierCurves) {
292
292
 
293
293
  exports.pathToBezierCurves = pathToBezierCurves, exports.applyTransformOnBezierCurves = applyTransformOnBezierCurves,
294
294
  exports.bezierCurversToPath = bezierCurversToPath;
295
- //# sourceMappingURL=morphing-utils.js.map
295
+ //# sourceMappingURL=morphing-utils.js.map
@@ -61,4 +61,4 @@ exports.enumCommandMap = {
61
61
  Q: 7,
62
62
  R: 8
63
63
  }, exports.parseSvgPath = parseSvgPath;
64
- //# sourceMappingURL=path-svg.js.map
64
+ //# sourceMappingURL=path-svg.js.map
@@ -39,8 +39,8 @@ function getProportionPoint(point, segment, length, dx, dy) {
39
39
  };
40
40
  }
41
41
 
42
- //# sourceMappingURL=polygon.js.map
43
42
  Object.defineProperty(exports, "__esModule", {
44
43
  value: !0
45
44
  }), exports.drawRoundedPolygon = exports.drawPolygon = void 0, exports.drawPolygon = drawPolygon,
46
- exports.drawRoundedPolygon = drawRoundedPolygon;
45
+ exports.drawRoundedPolygon = drawRoundedPolygon;
46
+ //# sourceMappingURL=polygon.js.map
@@ -24,4 +24,4 @@ const vutils_1 = require("@visactor/vutils"), normalizeRectAttributes = attribut
24
24
  };
25
25
 
26
26
  exports.normalizeRectAttributes = normalizeRectAttributes;
27
- //# sourceMappingURL=rect-utils.js.map
27
+ //# sourceMappingURL=rect-utils.js.map
@@ -61,4 +61,5 @@ function drawAreaBlock(path, topList, bottomList, params) {
61
61
  path.closePath();
62
62
  }
63
63
 
64
- exports.drawAreaSegments = drawAreaSegments;
64
+ exports.drawAreaSegments = drawAreaSegments;
65
+ //# sourceMappingURL=render-area.js.map
@@ -14,4 +14,4 @@ function renderCommandList(commandList, context, x = 0, y = 0, sx = 1, sy = 1, z
14
14
  }
15
15
 
16
16
  exports.renderCommandList = renderCommandList;
17
- //# sourceMappingURL=render-command-list.js.map
17
+ //# sourceMappingURL=render-command-list.js.map
@@ -99,4 +99,4 @@ function drawIncrementalAreaSegments(path, lastSeg, segments, params) {
99
99
 
100
100
  exports.drawSegments = drawSegments, exports.drawIncrementalSegments = drawIncrementalSegments,
101
101
  exports.drawIncrementalAreaSegments = drawIncrementalAreaSegments;
102
- //# sourceMappingURL=render-curve.js.map
102
+ //# sourceMappingURL=render-curve.js.map
@@ -19,4 +19,4 @@ function drawSegItem(ctx, curve, endPercent, params) {
19
19
  }
20
20
 
21
21
  exports.drawSegItem = drawSegItem;
22
- //# sourceMappingURL=render-utils.js.map
22
+ //# sourceMappingURL=render-utils.js.map
@@ -95,4 +95,4 @@ class ReflectSegContext extends SegContext {
95
95
  }
96
96
 
97
97
  exports.ReflectSegContext = ReflectSegContext;
98
- //# sourceMappingURL=seg-context.js.map
98
+ //# sourceMappingURL=seg-context.js.map
@@ -36,4 +36,4 @@ function flatten_simplify(points, tolerance, highestQuality) {
36
36
  Object.defineProperty(exports, "__esModule", {
37
37
  value: !0
38
38
  }), exports.flatten_simplify = void 0, exports.flatten_simplify = flatten_simplify;
39
- //# sourceMappingURL=simplify.js.map
39
+ //# sourceMappingURL=simplify.js.map
@@ -101,4 +101,4 @@ Object.defineProperty(exports, "__esModule", {
101
101
  value: !0
102
102
  }), exports.findNextGraphic = exports.foreachAsync = exports.foreach = void 0, exports.foreach = foreach,
103
103
  exports.foreachAsync = foreachAsync, exports.findNextGraphic = findNextGraphic;
104
- //# sourceMappingURL=sort.js.map
104
+ //# sourceMappingURL=sort.js.map
@@ -269,4 +269,4 @@ const splitPath = (path, count) => {
269
269
  };
270
270
 
271
271
  exports.splitPath = splitPath;
272
- //# sourceMappingURL=split-path.js.map
272
+ //# sourceMappingURL=split-path.js.map
@@ -3,4 +3,4 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.ApplicationContribution = void 0, exports.ApplicationContribution = Symbol("ApplicationContribution");
6
- //# sourceMappingURL=application.js.map
6
+ //# sourceMappingURL=application.js.map
@@ -71,4 +71,4 @@ const registerOrthoCamera = () => {
71
71
  };
72
72
 
73
73
  exports.registerOrthoCamera = registerOrthoCamera;
74
- //# sourceMappingURL=camera.js.map
74
+ //# sourceMappingURL=camera.js.map
@@ -7,4 +7,4 @@ exports.TransformUtil = Symbol.for("TransformUtil"), exports.GraphicUtil = Symbo
7
7
  exports.LayerService = Symbol.for("LayerService"), exports.StaticLayerHandlerContribution = Symbol.for("StaticLayerHandlerContribution"),
8
8
  exports.DynamicLayerHandlerContribution = Symbol.for("DynamicLayerHandlerContribution"),
9
9
  exports.VirtualLayerHandlerContribution = Symbol.for("VirtualLayerHandlerContribution");
10
- //# sourceMappingURL=constants.js.map
10
+ //# sourceMappingURL=constants.js.map
@@ -12,4 +12,4 @@ exports.default = new inversify_lite_1.ContainerModule((bind => {
12
12
  bind(constants_1.TransformUtil).to(graphic_utils_1.DefaultTransformUtil).inSingletonScope(),
13
13
  bind(constants_1.LayerService).to(layer_service_1.DefaultLayerService).inSingletonScope();
14
14
  }));
15
- //# sourceMappingURL=core-modules.js.map
15
+ //# sourceMappingURL=core-modules.js.map
@@ -1,3 +1 @@
1
-
2
-
3
1
  //# sourceMappingURL=global-module.js.map
@@ -220,4 +220,4 @@ DefaultGlobal = __decorate([ (0, inversify_lite_1.injectable)(), __param(0, (0,
220
220
  inversify_lite_1.inject)(contribution_provider_1.ContributionProvider)), __param(0, (0,
221
221
  inversify_lite_1.named)(constants_1.EnvContribution)), __metadata("design:paramtypes", [ Object ]) ], DefaultGlobal),
222
222
  exports.DefaultGlobal = DefaultGlobal;
223
- //# sourceMappingURL=global.js.map
223
+ //# sourceMappingURL=global.js.map
@@ -172,4 +172,4 @@ let DefaultTransformUtil = class {
172
172
 
173
173
  DefaultTransformUtil = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", []) ], DefaultTransformUtil),
174
174
  exports.DefaultTransformUtil = DefaultTransformUtil;
175
- //# sourceMappingURL=graphic-utils.js.map
175
+ //# 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
@@ -80,4 +80,4 @@ let DefaultLayerService = DefaultLayerService_1 = class {
80
80
  DefaultLayerService.idprefix = "visactor_layer", DefaultLayerService.prefix_count = 0,
81
81
  DefaultLayerService = DefaultLayerService_1 = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", []) ], DefaultLayerService),
82
82
  exports.DefaultLayerService = DefaultLayerService;
83
- //# sourceMappingURL=layer-service.js.map
83
+ //# sourceMappingURL=layer-service.js.map
package/cjs/core/layer.js CHANGED
@@ -116,4 +116,4 @@ class Layer extends group_1.Group {
116
116
  }
117
117
 
118
118
  exports.Layer = Layer;
119
- //# sourceMappingURL=layer.js.map
119
+ //# sourceMappingURL=layer.js.map
package/cjs/core/light.js CHANGED
@@ -29,4 +29,4 @@ const registerDirectionalLight = () => {
29
29
  };
30
30
 
31
31
  exports.registerDirectionalLight = registerDirectionalLight;
32
- //# sourceMappingURL=light.js.map
32
+ //# sourceMappingURL=light.js.map
package/cjs/core/stage.js CHANGED
@@ -516,4 +516,4 @@ class Stage extends group_1.Group {
516
516
  }
517
517
 
518
518
  exports.Stage = Stage;
519
- //# sourceMappingURL=stage.js.map
519
+ //# sourceMappingURL=stage.js.map
@@ -153,4 +153,4 @@ let DefaultWindow = class {
153
153
 
154
154
  DefaultWindow = __decorate([ (0, inversify_lite_1.injectable)(), __metadata("design:paramtypes", []) ], DefaultWindow),
155
155
  exports.DefaultWindow = DefaultWindow;
156
- //# sourceMappingURL=window.js.map
156
+ //# sourceMappingURL=window.js.map
@@ -63,6 +63,8 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
63
63
  in3dMode?: boolean;
64
64
  widthWithoutTransform?: number;
65
65
  heightWithoutTransform?: number;
66
+ x1WithoutTransform?: number;
67
+ y1WithoutTransform?: number;
66
68
  protected _AABBBounds: IAABBBounds;
67
69
  get AABBBounds(): IAABBBounds;
68
70
  protected _OBBBounds?: IOBBBounds;