@2112-lab/central-plant 0.1.4 → 0.1.6

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 (88) hide show
  1. package/dist/bundle/index.js +33146 -1
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
  8. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
  12. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
  13. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
  14. package/dist/cjs/src/analysis/analysis.js +560 -1
  15. package/dist/cjs/src/analysis/testing.js +958 -1
  16. package/dist/cjs/src/core/centralPlant.js +1149 -1
  17. package/dist/cjs/src/core/debugLogger.js +175 -1
  18. package/dist/cjs/src/core/mathUtils.js +574 -1
  19. package/dist/cjs/src/core/nameUtils.js +93 -1
  20. package/dist/cjs/src/data/export.js +716 -1
  21. package/dist/cjs/src/data/import.js +380 -1
  22. package/dist/cjs/src/data/numerics.js +522 -1
  23. package/dist/cjs/src/helpers/sceneHelper.js +572 -1
  24. package/dist/cjs/src/index.js +69 -1
  25. package/dist/cjs/src/managers/components/animationManager.js +123 -1
  26. package/dist/cjs/src/managers/components/componentManager.js +332 -1
  27. package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
  28. package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
  29. package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
  30. package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
  31. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
  32. package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
  33. package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
  34. package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
  35. package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
  36. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
  37. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
  38. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
  39. package/dist/cjs/src/managers/system/disposalManager.js +444 -1
  40. package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
  41. package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
  42. package/dist/cjs/src/rendering/modelPreloader.js +369 -1
  43. package/dist/cjs/src/rendering/rendering2D.js +631 -1
  44. package/dist/cjs/src/rendering/rendering3D.js +685 -1
  45. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
  46. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
  47. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
  49. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
  50. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
  51. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
  52. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
  53. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
  54. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
  55. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
  56. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
  57. package/dist/esm/src/analysis/analysis.js +536 -1
  58. package/dist/esm/src/analysis/testing.js +954 -1
  59. package/dist/esm/src/core/centralPlant.js +1144 -1
  60. package/dist/esm/src/core/debugLogger.js +167 -1
  61. package/dist/esm/src/core/mathUtils.js +570 -1
  62. package/dist/esm/src/core/nameUtils.js +87 -1
  63. package/dist/esm/src/data/export.js +712 -1
  64. package/dist/esm/src/data/import.js +356 -1
  65. package/dist/esm/src/data/numerics.js +518 -1
  66. package/dist/esm/src/helpers/sceneHelper.js +547 -1
  67. package/dist/esm/src/index.js +35 -1
  68. package/dist/esm/src/managers/components/animationManager.js +119 -1
  69. package/dist/esm/src/managers/components/componentManager.js +328 -1
  70. package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
  71. package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
  72. package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
  73. package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
  74. package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
  75. package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
  76. package/dist/esm/src/managers/environment/environmentManager.js +690 -1
  77. package/dist/esm/src/managers/environment/textureConfig.js +202 -1
  78. package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
  79. package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
  80. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
  81. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
  82. package/dist/esm/src/managers/system/disposalManager.js +440 -1
  83. package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
  84. package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
  85. package/dist/esm/src/rendering/modelPreloader.js +364 -1
  86. package/dist/esm/src/rendering/rendering2D.js +627 -1
  87. package/dist/esm/src/rendering/rendering3D.js +661 -1
  88. package/package.json +1 -1
@@ -1 +1,627 @@
1
- import{createClass as t,classCallCheck as i,defineProperty as n}from"../../_virtual/_rollupPluginBabelHelpers.js";var r=function(){return t(function t(r){var e=this;i(this,t),n(this,"draw",{line:function(t,i,n,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(s),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.lineTo(n,r),e.ctx.stroke(),e.restore())},rect:function(t,i,n,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(s),s.fillStyle&&e.ctx.fillRect(t,i,n,r),s.strokeStyle&&e.ctx.strokeRect(t,i,n,r),e.restore())},circle:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),e.ctx.beginPath(),e.ctx.arc(t,i,n,0,2*Math.PI),r.fillStyle&&e.ctx.fill(),r.strokeStyle&&e.ctx.stroke(),e.restore())},ellipse:function(t,i,n,r){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};e.ctx&&(e.save(),e.setStyles(o),e.ctx.beginPath(),e.ctx.ellipse(t,i,n,r,s,0,2*Math.PI),o.fillStyle&&e.ctx.fill(),o.strokeStyle&&e.ctx.stroke(),e.restore())},polygon:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.ctx&&!(t.length<3)){e.save(),e.setStyles(i),e.ctx.beginPath(),e.ctx.moveTo(t[0][0],t[0][1]);for(var n=1;n<t.length;n++)e.ctx.lineTo(t[n][0],t[n][1]);e.ctx.closePath(),i.fillStyle&&e.ctx.fill(),i.strokeStyle&&e.ctx.stroke(),e.restore()}},bezierCurve:function(t,i,n,r,s,o,u,a){var l=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{};e.ctx&&(e.save(),e.setStyles(l),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.bezierCurveTo(n,r,s,o,u,a),e.ctx.stroke(),e.restore())},text:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),r.fillStyle&&e.ctx.fillText(t,i,n),r.strokeStyle&&e.ctx.strokeText(t,i,n),e.restore())},image:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;e.ctx&&t&&(r&&s?e.ctx.drawImage(t,i,n,r,s):e.ctx.drawImage(t,i,n))}}),n(this,"transform",{translate:function(t,i){e.ctx&&e.ctx.translate(t,i)},rotate:function(t){e.ctx&&e.ctx.rotate(t)},scale:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;e.ctx&&e.ctx.scale(t,i)},transform:function(t,i,n,r,s,o){e.ctx&&e.ctx.transform(t,i,n,r,s,o)},setTransform:function(t,i,n,r,s,o){e.ctx&&e.ctx.setTransform(t,i,n,r,s,o)},resetTransform:function(){e.ctx&&e.ctx.resetTransform()}}),n(this,"gradient",{linear:function(t,i,n,r,s){if(!e.ctx)return null;var o=e.ctx.createLinearGradient(t,i,n,r);return s.forEach(function(t){o.addColorStop(t.offset,t.color)}),o},radial:function(t,i,n,r,s,o,u){if(!e.ctx)return null;var a=e.ctx.createRadialGradient(t,i,n,r,s,o);return u.forEach(function(t){a.addColorStop(t.offset,t.color)}),a}}),n(this,"pattern",{fromImage:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null},fromCanvas:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null}}),n(this,"path",{begin:function(){e.ctx&&e.ctx.beginPath()},close:function(){e.ctx&&e.ctx.closePath()},moveTo:function(t,i){e.ctx&&e.ctx.moveTo(t,i)},lineTo:function(t,i){e.ctx&&e.ctx.lineTo(t,i)},arc:function(t,i,n,r,s){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];e.ctx&&e.ctx.arc(t,i,n,r,s,o)},quadraticCurveTo:function(t,i,n,r){e.ctx&&e.ctx.quadraticCurveTo(t,i,n,r)},bezierCurveTo:function(t,i,n,r,s,o){e.ctx&&e.ctx.bezierCurveTo(t,i,n,r,s,o)},fill:function(){e.ctx&&e.ctx.fill()},stroke:function(){e.ctx&&e.ctx.stroke()},clip:function(){e.ctx&&e.ctx.clip()}}),n(this,"measure",{textWidth:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return 0;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t).width;return e.ctx.font=n,r}return e.ctx.measureText(t).width},textMetrics:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return null;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t);return e.ctx.font=n,r}return e.ctx.measureText(t)}}),n(this,"export",{toDataURL:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?e.canvas.toDataURL(t,i):""},toBlob:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?new Promise(function(n){e.canvas.toBlob(n,t,i)}):Promise.resolve(null)}}),this.canvas=r,this.ctx=null==r?void 0:r.getContext("2d"),this.width=(null==r?void 0:r.width)||800,this.height=(null==r?void 0:r.height)||600,this.pixelRatio=window.devicePixelRatio||1,this.state={transforms:[],styles:[]},this.setupCanvas()},[{key:"setupCanvas",value:function(){this.canvas&&this.ctx&&(this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.scale(this.pixelRatio,this.pixelRatio),this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px")}},{key:"clear",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.ctx&&(t?(this.ctx.fillStyle=t,this.ctx.fillRect(0,0,this.width,this.height)):this.ctx.clearRect(0,0,this.width,this.height))}},{key:"save",value:function(){this.ctx&&(this.ctx.save(),this.state.transforms.push(this.ctx.getTransform()),this.state.styles.push({fillStyle:this.ctx.fillStyle,strokeStyle:this.ctx.strokeStyle,lineWidth:this.ctx.lineWidth,font:this.ctx.font,textAlign:this.ctx.textAlign,textBaseline:this.ctx.textBaseline}))}},{key:"restore",value:function(){this.ctx&&(this.ctx.restore(),this.state.transforms.pop(),this.state.styles.pop())}},{key:"setStyles",value:function(t){var i=this;this.ctx&&Object.keys(t).forEach(function(n){void 0!==i.ctx[n]&&(i.ctx[n]=t[n])})}},{key:"resize",value:function(t,i){this.width=t,this.height=i,this.setupCanvas()}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height,pixelRatio:this.pixelRatio}}},{key:"dispose",value:function(){this.state.transforms=[],this.state.styles=[],this.canvas=null,this.ctx=null}}])}();export{r as Rendering2D};
1
+ import { createClass as _createClass, classCallCheck as _classCallCheck, defineProperty as _defineProperty } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+
3
+ /**
4
+ * Rendering2D
5
+ * Handles 2D rendering operations, canvas drawing, and 2D graphics utilities
6
+ */
7
+
8
+ var Rendering2D = /*#__PURE__*/function () {
9
+ function Rendering2D(_canvas) {
10
+ var _this = this;
11
+ _classCallCheck(this, Rendering2D);
12
+ /**
13
+ * Drawing primitives
14
+ */
15
+ _defineProperty(this, "draw", {
16
+ /**
17
+ * Draw a line
18
+ * @param {number} x1 - Start X
19
+ * @param {number} y1 - Start Y
20
+ * @param {number} x2 - End X
21
+ * @param {number} y2 - End Y
22
+ * @param {Object} style - Line style
23
+ */
24
+ line: function line(x1, y1, x2, y2) {
25
+ var style = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
26
+ if (!_this.ctx) return;
27
+ _this.save();
28
+ _this.setStyles(style);
29
+ _this.ctx.beginPath();
30
+ _this.ctx.moveTo(x1, y1);
31
+ _this.ctx.lineTo(x2, y2);
32
+ _this.ctx.stroke();
33
+ _this.restore();
34
+ },
35
+ /**
36
+ * Draw a rectangle
37
+ * @param {number} x - X position
38
+ * @param {number} y - Y position
39
+ * @param {number} width - Width
40
+ * @param {number} height - Height
41
+ * @param {Object} style - Rectangle style
42
+ */
43
+ rect: function rect(x, y, width, height) {
44
+ var style = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
45
+ if (!_this.ctx) return;
46
+ _this.save();
47
+ _this.setStyles(style);
48
+ if (style.fillStyle) {
49
+ _this.ctx.fillRect(x, y, width, height);
50
+ }
51
+ if (style.strokeStyle) {
52
+ _this.ctx.strokeRect(x, y, width, height);
53
+ }
54
+ _this.restore();
55
+ },
56
+ /**
57
+ * Draw a circle
58
+ * @param {number} x - Center X
59
+ * @param {number} y - Center Y
60
+ * @param {number} radius - Radius
61
+ * @param {Object} style - Circle style
62
+ */
63
+ circle: function circle(x, y, radius) {
64
+ var style = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
65
+ if (!_this.ctx) return;
66
+ _this.save();
67
+ _this.setStyles(style);
68
+ _this.ctx.beginPath();
69
+ _this.ctx.arc(x, y, radius, 0, 2 * Math.PI);
70
+ if (style.fillStyle) {
71
+ _this.ctx.fill();
72
+ }
73
+ if (style.strokeStyle) {
74
+ _this.ctx.stroke();
75
+ }
76
+ _this.restore();
77
+ },
78
+ /**
79
+ * Draw an ellipse
80
+ * @param {number} x - Center X
81
+ * @param {number} y - Center Y
82
+ * @param {number} radiusX - X radius
83
+ * @param {number} radiusY - Y radius
84
+ * @param {number} rotation - Rotation in radians
85
+ * @param {Object} style - Ellipse style
86
+ */
87
+ ellipse: function ellipse(x, y, radiusX, radiusY) {
88
+ var rotation = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
89
+ var style = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
90
+ if (!_this.ctx) return;
91
+ _this.save();
92
+ _this.setStyles(style);
93
+ _this.ctx.beginPath();
94
+ _this.ctx.ellipse(x, y, radiusX, radiusY, rotation, 0, 2 * Math.PI);
95
+ if (style.fillStyle) {
96
+ _this.ctx.fill();
97
+ }
98
+ if (style.strokeStyle) {
99
+ _this.ctx.stroke();
100
+ }
101
+ _this.restore();
102
+ },
103
+ /**
104
+ * Draw a polygon
105
+ * @param {Array} points - Array of [x, y] points
106
+ * @param {Object} style - Polygon style
107
+ */
108
+ polygon: function polygon(points) {
109
+ var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
110
+ if (!_this.ctx || points.length < 3) return;
111
+ _this.save();
112
+ _this.setStyles(style);
113
+ _this.ctx.beginPath();
114
+ _this.ctx.moveTo(points[0][0], points[0][1]);
115
+ for (var i = 1; i < points.length; i++) {
116
+ _this.ctx.lineTo(points[i][0], points[i][1]);
117
+ }
118
+ _this.ctx.closePath();
119
+ if (style.fillStyle) {
120
+ _this.ctx.fill();
121
+ }
122
+ if (style.strokeStyle) {
123
+ _this.ctx.stroke();
124
+ }
125
+ _this.restore();
126
+ },
127
+ /**
128
+ * Draw a bezier curve
129
+ * @param {number} x1 - Start X
130
+ * @param {number} y1 - Start Y
131
+ * @param {number} cp1x - Control point 1 X
132
+ * @param {number} cp1y - Control point 1 Y
133
+ * @param {number} cp2x - Control point 2 X
134
+ * @param {number} cp2y - Control point 2 Y
135
+ * @param {number} x2 - End X
136
+ * @param {number} y2 - End Y
137
+ * @param {Object} style - Curve style
138
+ */
139
+ bezierCurve: function bezierCurve(x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2) {
140
+ var style = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : {};
141
+ if (!_this.ctx) return;
142
+ _this.save();
143
+ _this.setStyles(style);
144
+ _this.ctx.beginPath();
145
+ _this.ctx.moveTo(x1, y1);
146
+ _this.ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2);
147
+ _this.ctx.stroke();
148
+ _this.restore();
149
+ },
150
+ /**
151
+ * Draw text
152
+ * @param {string} text - Text to draw
153
+ * @param {number} x - X position
154
+ * @param {number} y - Y position
155
+ * @param {Object} style - Text style
156
+ */
157
+ text: function text(_text, x, y) {
158
+ var style = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
159
+ if (!_this.ctx) return;
160
+ _this.save();
161
+ _this.setStyles(style);
162
+ if (style.fillStyle) {
163
+ _this.ctx.fillText(_text, x, y);
164
+ }
165
+ if (style.strokeStyle) {
166
+ _this.ctx.strokeText(_text, x, y);
167
+ }
168
+ _this.restore();
169
+ },
170
+ /**
171
+ * Draw an image
172
+ * @param {HTMLImageElement} image - Image to draw
173
+ * @param {number} x - X position
174
+ * @param {number} y - Y position
175
+ * @param {number} width - Width (optional)
176
+ * @param {number} height - Height (optional)
177
+ */
178
+ image: function image(_image, x, y) {
179
+ var width = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
180
+ var height = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
181
+ if (!_this.ctx || !_image) return;
182
+ if (width && height) {
183
+ _this.ctx.drawImage(_image, x, y, width, height);
184
+ } else {
185
+ _this.ctx.drawImage(_image, x, y);
186
+ }
187
+ }
188
+ });
189
+ /**
190
+ * Transform operations
191
+ */
192
+ _defineProperty(this, "transform", {
193
+ /**
194
+ * Translate coordinate system
195
+ * @param {number} x - X offset
196
+ * @param {number} y - Y offset
197
+ */
198
+ translate: function translate(x, y) {
199
+ if (!_this.ctx) return;
200
+ _this.ctx.translate(x, y);
201
+ },
202
+ /**
203
+ * Rotate coordinate system
204
+ * @param {number} angle - Rotation angle in radians
205
+ */
206
+ rotate: function rotate(angle) {
207
+ if (!_this.ctx) return;
208
+ _this.ctx.rotate(angle);
209
+ },
210
+ /**
211
+ * Scale coordinate system
212
+ * @param {number} x - X scale factor
213
+ * @param {number} y - Y scale factor
214
+ */
215
+ scale: function scale(x) {
216
+ var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
217
+ if (!_this.ctx) return;
218
+ _this.ctx.scale(x, y);
219
+ },
220
+ /**
221
+ * Apply transformation matrix
222
+ * @param {number} a - Horizontal scaling
223
+ * @param {number} b - Horizontal skewing
224
+ * @param {number} c - Vertical skewing
225
+ * @param {number} d - Vertical scaling
226
+ * @param {number} e - Horizontal translation
227
+ * @param {number} f - Vertical translation
228
+ */
229
+ transform: function transform(a, b, c, d, e, f) {
230
+ if (!_this.ctx) return;
231
+ _this.ctx.transform(a, b, c, d, e, f);
232
+ },
233
+ /**
234
+ * Set transformation matrix
235
+ * @param {number} a - Horizontal scaling
236
+ * @param {number} b - Horizontal skewing
237
+ * @param {number} c - Vertical skewing
238
+ * @param {number} d - Vertical scaling
239
+ * @param {number} e - Horizontal translation
240
+ * @param {number} f - Vertical translation
241
+ */
242
+ setTransform: function setTransform(a, b, c, d, e, f) {
243
+ if (!_this.ctx) return;
244
+ _this.ctx.setTransform(a, b, c, d, e, f);
245
+ },
246
+ /**
247
+ * Reset transformation matrix to identity
248
+ */
249
+ resetTransform: function resetTransform() {
250
+ if (!_this.ctx) return;
251
+ _this.ctx.resetTransform();
252
+ }
253
+ });
254
+ /**
255
+ * Gradient utilities
256
+ */
257
+ _defineProperty(this, "gradient", {
258
+ /**
259
+ * Create linear gradient
260
+ * @param {number} x1 - Start X
261
+ * @param {number} y1 - Start Y
262
+ * @param {number} x2 - End X
263
+ * @param {number} y2 - End Y
264
+ * @param {Array} colorStops - Array of {offset, color} objects
265
+ * @returns {CanvasGradient} Linear gradient
266
+ */
267
+ linear: function linear(x1, y1, x2, y2, colorStops) {
268
+ if (!_this.ctx) return null;
269
+ var gradient = _this.ctx.createLinearGradient(x1, y1, x2, y2);
270
+ colorStops.forEach(function (stop) {
271
+ gradient.addColorStop(stop.offset, stop.color);
272
+ });
273
+ return gradient;
274
+ },
275
+ /**
276
+ * Create radial gradient
277
+ * @param {number} x1 - Inner circle center X
278
+ * @param {number} y1 - Inner circle center Y
279
+ * @param {number} r1 - Inner circle radius
280
+ * @param {number} x2 - Outer circle center X
281
+ * @param {number} y2 - Outer circle center Y
282
+ * @param {number} r2 - Outer circle radius
283
+ * @param {Array} colorStops - Array of {offset, color} objects
284
+ * @returns {CanvasGradient} Radial gradient
285
+ */
286
+ radial: function radial(x1, y1, r1, x2, y2, r2, colorStops) {
287
+ if (!_this.ctx) return null;
288
+ var gradient = _this.ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);
289
+ colorStops.forEach(function (stop) {
290
+ gradient.addColorStop(stop.offset, stop.color);
291
+ });
292
+ return gradient;
293
+ }
294
+ });
295
+ /**
296
+ * Pattern utilities
297
+ */
298
+ _defineProperty(this, "pattern", {
299
+ /**
300
+ * Create pattern from image
301
+ * @param {HTMLImageElement} image - Source image
302
+ * @param {string} repetition - 'repeat', 'repeat-x', 'repeat-y', 'no-repeat'
303
+ * @returns {CanvasPattern} Pattern
304
+ */
305
+ fromImage: function fromImage(image) {
306
+ var repetition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'repeat';
307
+ if (!_this.ctx || !image) return null;
308
+ return _this.ctx.createPattern(image, repetition);
309
+ },
310
+ /**
311
+ * Create pattern from canvas
312
+ * @param {HTMLCanvasElement} canvas - Source canvas
313
+ * @param {string} repetition - 'repeat', 'repeat-x', 'repeat-y', 'no-repeat'
314
+ * @returns {CanvasPattern} Pattern
315
+ */
316
+ fromCanvas: function fromCanvas(canvas) {
317
+ var repetition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'repeat';
318
+ if (!_this.ctx || !canvas) return null;
319
+ return _this.ctx.createPattern(canvas, repetition);
320
+ }
321
+ });
322
+ /**
323
+ * Path utilities
324
+ */
325
+ _defineProperty(this, "path", {
326
+ /**
327
+ * Begin new path
328
+ */
329
+ begin: function begin() {
330
+ if (!_this.ctx) return;
331
+ _this.ctx.beginPath();
332
+ },
333
+ /**
334
+ * Close current path
335
+ */
336
+ close: function close() {
337
+ if (!_this.ctx) return;
338
+ _this.ctx.closePath();
339
+ },
340
+ /**
341
+ * Move to point
342
+ * @param {number} x - X coordinate
343
+ * @param {number} y - Y coordinate
344
+ */
345
+ moveTo: function moveTo(x, y) {
346
+ if (!_this.ctx) return;
347
+ _this.ctx.moveTo(x, y);
348
+ },
349
+ /**
350
+ * Line to point
351
+ * @param {number} x - X coordinate
352
+ * @param {number} y - Y coordinate
353
+ */
354
+ lineTo: function lineTo(x, y) {
355
+ if (!_this.ctx) return;
356
+ _this.ctx.lineTo(x, y);
357
+ },
358
+ /**
359
+ * Arc to point
360
+ * @param {number} x - Center X
361
+ * @param {number} y - Center Y
362
+ * @param {number} radius - Arc radius
363
+ * @param {number} startAngle - Start angle in radians
364
+ * @param {number} endAngle - End angle in radians
365
+ * @param {boolean} counterclockwise - Arc direction
366
+ */
367
+ arc: function arc(x, y, radius, startAngle, endAngle) {
368
+ var counterclockwise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
369
+ if (!_this.ctx) return;
370
+ _this.ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise);
371
+ },
372
+ /**
373
+ * Quadratic curve to point
374
+ * @param {number} cpx - Control point X
375
+ * @param {number} cpy - Control point Y
376
+ * @param {number} x - End X
377
+ * @param {number} y - End Y
378
+ */
379
+ quadraticCurveTo: function quadraticCurveTo(cpx, cpy, x, y) {
380
+ if (!_this.ctx) return;
381
+ _this.ctx.quadraticCurveTo(cpx, cpy, x, y);
382
+ },
383
+ /**
384
+ * Bezier curve to point
385
+ * @param {number} cp1x - Control point 1 X
386
+ * @param {number} cp1y - Control point 1 Y
387
+ * @param {number} cp2x - Control point 2 X
388
+ * @param {number} cp2y - Control point 2 Y
389
+ * @param {number} x - End X
390
+ * @param {number} y - End Y
391
+ */
392
+ bezierCurveTo: function bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
393
+ if (!_this.ctx) return;
394
+ _this.ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
395
+ },
396
+ /**
397
+ * Fill current path
398
+ */
399
+ fill: function fill() {
400
+ if (!_this.ctx) return;
401
+ _this.ctx.fill();
402
+ },
403
+ /**
404
+ * Stroke current path
405
+ */
406
+ stroke: function stroke() {
407
+ if (!_this.ctx) return;
408
+ _this.ctx.stroke();
409
+ },
410
+ /**
411
+ * Clip to current path
412
+ */
413
+ clip: function clip() {
414
+ if (!_this.ctx) return;
415
+ _this.ctx.clip();
416
+ }
417
+ });
418
+ /**
419
+ * Measurement utilities
420
+ */
421
+ _defineProperty(this, "measure", {
422
+ /**
423
+ * Measure text width
424
+ * @param {string} text - Text to measure
425
+ * @param {string} font - Font specification
426
+ * @returns {number} Text width in pixels
427
+ */
428
+ textWidth: function textWidth(text) {
429
+ var font = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
430
+ if (!_this.ctx) return 0;
431
+ if (font) {
432
+ var oldFont = _this.ctx.font;
433
+ _this.ctx.font = font;
434
+ var width = _this.ctx.measureText(text).width;
435
+ _this.ctx.font = oldFont;
436
+ return width;
437
+ }
438
+ return _this.ctx.measureText(text).width;
439
+ },
440
+ /**
441
+ * Get text metrics
442
+ * @param {string} text - Text to measure
443
+ * @param {string} font - Font specification
444
+ * @returns {TextMetrics} Text metrics object
445
+ */
446
+ textMetrics: function textMetrics(text) {
447
+ var font = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
448
+ if (!_this.ctx) return null;
449
+ if (font) {
450
+ var oldFont = _this.ctx.font;
451
+ _this.ctx.font = font;
452
+ var metrics = _this.ctx.measureText(text);
453
+ _this.ctx.font = oldFont;
454
+ return metrics;
455
+ }
456
+ return _this.ctx.measureText(text);
457
+ }
458
+ });
459
+ /**
460
+ * Export utilities
461
+ */
462
+ _defineProperty(this, "export", {
463
+ /**
464
+ * Get canvas as data URL
465
+ * @param {string} type - Image type ('image/png', 'image/jpeg', etc.)
466
+ * @param {number} quality - Quality for lossy formats (0-1)
467
+ * @returns {string} Data URL
468
+ */
469
+ toDataURL: function toDataURL() {
470
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image/png';
471
+ var quality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.92;
472
+ if (!_this.canvas) return '';
473
+ return _this.canvas.toDataURL(type, quality);
474
+ },
475
+ /**
476
+ * Get canvas as blob
477
+ * @param {string} type - Image type
478
+ * @param {number} quality - Quality for lossy formats
479
+ * @returns {Promise<Blob>} Canvas blob
480
+ */
481
+ toBlob: function toBlob() {
482
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image/png';
483
+ var quality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.92;
484
+ if (!_this.canvas) return Promise.resolve(null);
485
+ return new Promise(function (resolve) {
486
+ _this.canvas.toBlob(resolve, type, quality);
487
+ });
488
+ }
489
+ });
490
+ this.canvas = _canvas;
491
+ this.ctx = _canvas === null || _canvas === void 0 ? void 0 : _canvas.getContext('2d');
492
+ this.width = (_canvas === null || _canvas === void 0 ? void 0 : _canvas.width) || 800;
493
+ this.height = (_canvas === null || _canvas === void 0 ? void 0 : _canvas.height) || 600;
494
+ this.pixelRatio = window.devicePixelRatio || 1;
495
+ this.state = {
496
+ transforms: [],
497
+ styles: []
498
+ };
499
+ this.setupCanvas();
500
+ }
501
+
502
+ /**
503
+ * Setup canvas for high DPI displays
504
+ */
505
+ return _createClass(Rendering2D, [{
506
+ key: "setupCanvas",
507
+ value: function setupCanvas() {
508
+ if (!this.canvas || !this.ctx) return;
509
+
510
+ // Set actual size in memory (scaled for DPI)
511
+ this.canvas.width = this.width * this.pixelRatio;
512
+ this.canvas.height = this.height * this.pixelRatio;
513
+
514
+ // Scale the drawing context back to logical size
515
+ this.ctx.scale(this.pixelRatio, this.pixelRatio);
516
+
517
+ // Set display size (CSS pixels)
518
+ this.canvas.style.width = this.width + 'px';
519
+ this.canvas.style.height = this.height + 'px';
520
+ }
521
+
522
+ /**
523
+ * Clear the entire canvas
524
+ * @param {string} color - Optional background color
525
+ */
526
+ }, {
527
+ key: "clear",
528
+ value: function clear() {
529
+ var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
530
+ if (!this.ctx) return;
531
+ if (color) {
532
+ this.ctx.fillStyle = color;
533
+ this.ctx.fillRect(0, 0, this.width, this.height);
534
+ } else {
535
+ this.ctx.clearRect(0, 0, this.width, this.height);
536
+ }
537
+ }
538
+
539
+ /**
540
+ * Save current drawing state
541
+ */
542
+ }, {
543
+ key: "save",
544
+ value: function save() {
545
+ if (!this.ctx) return;
546
+ this.ctx.save();
547
+ this.state.transforms.push(this.ctx.getTransform());
548
+ this.state.styles.push({
549
+ fillStyle: this.ctx.fillStyle,
550
+ strokeStyle: this.ctx.strokeStyle,
551
+ lineWidth: this.ctx.lineWidth,
552
+ font: this.ctx.font,
553
+ textAlign: this.ctx.textAlign,
554
+ textBaseline: this.ctx.textBaseline
555
+ });
556
+ }
557
+
558
+ /**
559
+ * Restore previous drawing state
560
+ */
561
+ }, {
562
+ key: "restore",
563
+ value: function restore() {
564
+ if (!this.ctx) return;
565
+ this.ctx.restore();
566
+ this.state.transforms.pop();
567
+ this.state.styles.pop();
568
+ }
569
+
570
+ /**
571
+ * Set drawing styles
572
+ * @param {Object} styles - Style properties
573
+ */
574
+ }, {
575
+ key: "setStyles",
576
+ value: function setStyles(styles) {
577
+ var _this2 = this;
578
+ if (!this.ctx) return;
579
+ Object.keys(styles).forEach(function (key) {
580
+ if (_this2.ctx[key] !== undefined) {
581
+ _this2.ctx[key] = styles[key];
582
+ }
583
+ });
584
+ }
585
+ }, {
586
+ key: "resize",
587
+ value:
588
+ /**
589
+ * Resize canvas
590
+ * @param {number} width - New width
591
+ * @param {number} height - New height
592
+ */
593
+ function resize(width, height) {
594
+ this.width = width;
595
+ this.height = height;
596
+ this.setupCanvas();
597
+ }
598
+
599
+ /**
600
+ * Get canvas dimensions
601
+ * @returns {Object} Canvas dimensions
602
+ */
603
+ }, {
604
+ key: "getDimensions",
605
+ value: function getDimensions() {
606
+ return {
607
+ width: this.width,
608
+ height: this.height,
609
+ pixelRatio: this.pixelRatio
610
+ };
611
+ }
612
+
613
+ /**
614
+ * Dispose of rendering manager
615
+ */
616
+ }, {
617
+ key: "dispose",
618
+ value: function dispose() {
619
+ this.state.transforms = [];
620
+ this.state.styles = [];
621
+ this.canvas = null;
622
+ this.ctx = null;
623
+ }
624
+ }]);
625
+ }();
626
+
627
+ export { Rendering2D };