@guinetik/gcanvas 1.0.2 → 1.0.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 (217) hide show
  1. package/dist/gcanvas.es.js +25656 -0
  2. package/dist/gcanvas.es.min.js +1 -0
  3. package/dist/gcanvas.umd.js +1 -0
  4. package/dist/gcanvas.umd.min.js +1 -0
  5. package/package.json +23 -6
  6. package/src/game/objects/index.js +1 -0
  7. package/src/game/objects/spritesheet.js +260 -0
  8. package/src/game/ui/theme.js +6 -0
  9. package/src/io/keys.js +9 -1
  10. package/src/math/boolean.js +481 -0
  11. package/src/math/index.js +1 -0
  12. package/.github/workflows/release.yaml +0 -70
  13. package/.jshintrc +0 -4
  14. package/.vscode/settings.json +0 -22
  15. package/CLAUDE.md +0 -310
  16. package/blackhole.jpg +0 -0
  17. package/demo.png +0 -0
  18. package/demos/CNAME +0 -1
  19. package/demos/animations.html +0 -31
  20. package/demos/basic.html +0 -38
  21. package/demos/baskara.html +0 -31
  22. package/demos/bezier.html +0 -35
  23. package/demos/beziersignature.html +0 -29
  24. package/demos/blackhole.html +0 -28
  25. package/demos/blob.html +0 -35
  26. package/demos/coordinates.html +0 -698
  27. package/demos/cube3d.html +0 -23
  28. package/demos/demos.css +0 -303
  29. package/demos/dino.html +0 -42
  30. package/demos/easing.html +0 -28
  31. package/demos/events.html +0 -195
  32. package/demos/fluent.html +0 -647
  33. package/demos/fluid-simple.html +0 -22
  34. package/demos/fluid.html +0 -37
  35. package/demos/fractals.html +0 -36
  36. package/demos/gameobjects.html +0 -626
  37. package/demos/genart.html +0 -26
  38. package/demos/gendream.html +0 -26
  39. package/demos/group.html +0 -36
  40. package/demos/home.html +0 -587
  41. package/demos/index.html +0 -376
  42. package/demos/isometric.html +0 -34
  43. package/demos/js/animations.js +0 -452
  44. package/demos/js/basic.js +0 -204
  45. package/demos/js/baskara.js +0 -751
  46. package/demos/js/bezier.js +0 -692
  47. package/demos/js/beziersignature.js +0 -241
  48. package/demos/js/blackhole/accretiondisk.obj.js +0 -379
  49. package/demos/js/blackhole/blackhole.obj.js +0 -318
  50. package/demos/js/blackhole/index.js +0 -409
  51. package/demos/js/blackhole/particle.js +0 -56
  52. package/demos/js/blackhole/starfield.obj.js +0 -218
  53. package/demos/js/blob.js +0 -2276
  54. package/demos/js/coordinates.js +0 -840
  55. package/demos/js/cube3d.js +0 -789
  56. package/demos/js/dino.js +0 -1420
  57. package/demos/js/easing.js +0 -477
  58. package/demos/js/fluent.js +0 -183
  59. package/demos/js/fluid-simple.js +0 -253
  60. package/demos/js/fluid.js +0 -527
  61. package/demos/js/fractals.js +0 -931
  62. package/demos/js/fractalworker.js +0 -93
  63. package/demos/js/gameobjects.js +0 -176
  64. package/demos/js/genart.js +0 -268
  65. package/demos/js/gendream.js +0 -209
  66. package/demos/js/group.js +0 -140
  67. package/demos/js/info-toggle.js +0 -25
  68. package/demos/js/isometric.js +0 -863
  69. package/demos/js/kerr.js +0 -1556
  70. package/demos/js/lavalamp.js +0 -590
  71. package/demos/js/layout.js +0 -354
  72. package/demos/js/mondrian.js +0 -285
  73. package/demos/js/opacity.js +0 -275
  74. package/demos/js/painter.js +0 -484
  75. package/demos/js/particles-showcase.js +0 -514
  76. package/demos/js/particles.js +0 -299
  77. package/demos/js/patterns.js +0 -397
  78. package/demos/js/penrose/artifact.js +0 -69
  79. package/demos/js/penrose/blackhole.js +0 -121
  80. package/demos/js/penrose/constants.js +0 -73
  81. package/demos/js/penrose/game.js +0 -943
  82. package/demos/js/penrose/lore.js +0 -278
  83. package/demos/js/penrose/penrosescene.js +0 -892
  84. package/demos/js/penrose/ship.js +0 -216
  85. package/demos/js/penrose/sounds.js +0 -211
  86. package/demos/js/penrose/voidparticle.js +0 -55
  87. package/demos/js/penrose/voidscene.js +0 -258
  88. package/demos/js/penrose/voidship.js +0 -144
  89. package/demos/js/penrose/wormhole.js +0 -46
  90. package/demos/js/pipeline.js +0 -555
  91. package/demos/js/plane3d.js +0 -256
  92. package/demos/js/platformer.js +0 -1579
  93. package/demos/js/scene.js +0 -304
  94. package/demos/js/scenes.js +0 -320
  95. package/demos/js/schrodinger.js +0 -410
  96. package/demos/js/schwarzschild.js +0 -1023
  97. package/demos/js/shapes.js +0 -628
  98. package/demos/js/space/alien.js +0 -171
  99. package/demos/js/space/boom.js +0 -98
  100. package/demos/js/space/boss.js +0 -353
  101. package/demos/js/space/buff.js +0 -73
  102. package/demos/js/space/bullet.js +0 -102
  103. package/demos/js/space/constants.js +0 -85
  104. package/demos/js/space/game.js +0 -1884
  105. package/demos/js/space/hud.js +0 -112
  106. package/demos/js/space/laserbeam.js +0 -179
  107. package/demos/js/space/lightning.js +0 -277
  108. package/demos/js/space/minion.js +0 -192
  109. package/demos/js/space/missile.js +0 -212
  110. package/demos/js/space/player.js +0 -430
  111. package/demos/js/space/powerup.js +0 -90
  112. package/demos/js/space/starfield.js +0 -58
  113. package/demos/js/space/starpower.js +0 -90
  114. package/demos/js/spacetime.js +0 -559
  115. package/demos/js/sphere3d.js +0 -229
  116. package/demos/js/sprite.js +0 -473
  117. package/demos/js/svgtween.js +0 -204
  118. package/demos/js/tde/accretiondisk.js +0 -471
  119. package/demos/js/tde/blackhole.js +0 -219
  120. package/demos/js/tde/blackholescene.js +0 -209
  121. package/demos/js/tde/config.js +0 -59
  122. package/demos/js/tde/index.js +0 -820
  123. package/demos/js/tde/jets.js +0 -290
  124. package/demos/js/tde/lensedstarfield.js +0 -154
  125. package/demos/js/tde/tdestar.js +0 -297
  126. package/demos/js/tde/tidalstream.js +0 -372
  127. package/demos/js/tde_old/blackhole.obj.js +0 -354
  128. package/demos/js/tde_old/debris.obj.js +0 -791
  129. package/demos/js/tde_old/flare.obj.js +0 -239
  130. package/demos/js/tde_old/index.js +0 -448
  131. package/demos/js/tde_old/star.obj.js +0 -812
  132. package/demos/js/tiles.js +0 -312
  133. package/demos/js/tweendemo.js +0 -79
  134. package/demos/js/visibility.js +0 -102
  135. package/demos/kerr.html +0 -28
  136. package/demos/lavalamp.html +0 -27
  137. package/demos/layouts.html +0 -37
  138. package/demos/logo.svg +0 -4
  139. package/demos/loop.html +0 -84
  140. package/demos/mondrian.html +0 -32
  141. package/demos/og_image.png +0 -0
  142. package/demos/opacity.html +0 -36
  143. package/demos/painter.html +0 -39
  144. package/demos/particles-showcase.html +0 -28
  145. package/demos/particles.html +0 -24
  146. package/demos/patterns.html +0 -33
  147. package/demos/penrose-game.html +0 -31
  148. package/demos/pipeline.html +0 -737
  149. package/demos/plane3d.html +0 -24
  150. package/demos/platformer.html +0 -43
  151. package/demos/scene.html +0 -33
  152. package/demos/scenes.html +0 -96
  153. package/demos/schrodinger.html +0 -27
  154. package/demos/schwarzschild.html +0 -27
  155. package/demos/shapes.html +0 -16
  156. package/demos/space.html +0 -85
  157. package/demos/spacetime.html +0 -27
  158. package/demos/sphere3d.html +0 -24
  159. package/demos/sprite.html +0 -18
  160. package/demos/svgtween.html +0 -29
  161. package/demos/tde.html +0 -28
  162. package/demos/tiles.html +0 -28
  163. package/demos/transforms.html +0 -400
  164. package/demos/tween.html +0 -45
  165. package/demos/visibility.html +0 -33
  166. package/docs/README.md +0 -230
  167. package/docs/api/FluidSystem.md +0 -173
  168. package/docs/concepts/architecture-overview.md +0 -204
  169. package/docs/concepts/coordinate-system.md +0 -384
  170. package/docs/concepts/lifecycle.md +0 -255
  171. package/docs/concepts/rendering-pipeline.md +0 -279
  172. package/docs/concepts/shapes-vs-gameobjects.md +0 -187
  173. package/docs/concepts/tde-zorder.md +0 -106
  174. package/docs/concepts/two-layer-architecture.md +0 -229
  175. package/docs/fluid-dynamics.md +0 -99
  176. package/docs/getting-started/first-game.md +0 -354
  177. package/docs/getting-started/hello-world.md +0 -269
  178. package/docs/getting-started/installation.md +0 -175
  179. package/docs/modules/collision/README.md +0 -453
  180. package/docs/modules/fluent/README.md +0 -1075
  181. package/docs/modules/game/README.md +0 -303
  182. package/docs/modules/isometric-camera.md +0 -210
  183. package/docs/modules/isometric.md +0 -275
  184. package/docs/modules/painter/README.md +0 -328
  185. package/docs/modules/particle/README.md +0 -559
  186. package/docs/modules/shapes/README.md +0 -221
  187. package/docs/modules/shapes/base/euclidian.md +0 -123
  188. package/docs/modules/shapes/base/geometry2d.md +0 -204
  189. package/docs/modules/shapes/base/renderable.md +0 -215
  190. package/docs/modules/shapes/base/shape.md +0 -262
  191. package/docs/modules/shapes/base/transformable.md +0 -243
  192. package/docs/modules/shapes/hierarchy.md +0 -218
  193. package/docs/modules/state/README.md +0 -577
  194. package/docs/modules/util/README.md +0 -99
  195. package/docs/modules/util/camera3d.md +0 -412
  196. package/docs/modules/util/scene3d.md +0 -395
  197. package/index.html +0 -17
  198. package/jsdoc.json +0 -50
  199. package/scripts/build-demo.js +0 -69
  200. package/scripts/bundle4llm.js +0 -276
  201. package/scripts/clearconsole.js +0 -48
  202. package/test/math/orbital.test.js +0 -61
  203. package/test/math/tensor.test.js +0 -114
  204. package/test/particle/emitter.test.js +0 -204
  205. package/test/particle/particle-system.test.js +0 -310
  206. package/test/particle/particle.test.js +0 -116
  207. package/test/particle/updaters.test.js +0 -386
  208. package/test/setup.js +0 -120
  209. package/test/shapes/euclidian.test.js +0 -44
  210. package/test/shapes/geometry.test.js +0 -86
  211. package/test/shapes/group.test.js +0 -86
  212. package/test/shapes/rectangle.test.js +0 -64
  213. package/test/shapes/transform.test.js +0 -379
  214. package/test/util/camera3d.test.js +0 -428
  215. package/test/util/scene3d.test.js +0 -352
  216. package/vite.config.js +0 -50
  217. package/vitest.config.js +0 -13
@@ -1,400 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Transform API Demo</title>
8
- <link rel="stylesheet" href="demos.css" />
9
- <script src="./js/info-toggle.js"></script>
10
- <style>
11
- #debug-toggle {
12
- position: absolute;
13
- bottom: 20px;
14
- left: 20px;
15
- z-index: 100;
16
- padding: 10px 20px;
17
- font-family: monospace;
18
- font-size: 14px;
19
- background: #333;
20
- color: #ff00ff;
21
- border: 2px solid #ff00ff;
22
- cursor: pointer;
23
- transition: all 0.2s ease;
24
- }
25
- #debug-toggle:hover {
26
- background: #ff00ff;
27
- color: #000;
28
- }
29
- #debug-toggle.active {
30
- background: #ff00ff;
31
- color: #000;
32
- }
33
- </style>
34
- </head>
35
-
36
- <body>
37
- <div id="info" class="light">
38
- <strong>Transform API Demo</strong> — The <code>Transform</code> API provides a consistent, chainable interface for modifying shape properties.
39
- Use <code>shape.transform.x(100).y(200).rotation(45).scale(0.8)</code> for fluent chaining,
40
- <code>shape.transform.set({ x: 100, rotation: 45 })</code> for batch updates, or
41
- <code>shape.transform.translateBy(10, 20)</code> for relative transforms.
42
- Click to randomize colors.
43
- </div>
44
- <button id="debug-toggle">Toggle Debug</button>
45
- <canvas id="game"></canvas>
46
-
47
- <script type="module">
48
- import {
49
- Game,
50
- Scene,
51
- GameObject,
52
- FPSCounter,
53
- Rectangle,
54
- Circle,
55
- Star,
56
- Triangle,
57
- TextShape,
58
- Group,
59
- Transform,
60
- Painter,
61
- Easing
62
- } from "../src/index";
63
-
64
- // Track all shapes for debug toggle
65
- const allShapes = [];
66
-
67
- /**
68
- * TransformDemo Game
69
- * Showcases the new Transform API with animated shapes
70
- */
71
- class TransformDemoGame extends Game {
72
- constructor(canvas) {
73
- super(canvas);
74
- this.enableFluidSize();
75
- this.backgroundColor = "black";
76
- }
77
-
78
- onResize() {
79
- if (this.scene) {
80
- this.scene.width = this.width - 20;
81
- this.scene.height = this.height - 20;
82
- }
83
- }
84
-
85
- init() {
86
- super.init();
87
- // Main scene
88
- this.scene = new Scene(this, {
89
- width: this.width - 20,
90
- height: this.height - 20,
91
- debug: false,
92
- anchor: "center"
93
- });
94
-
95
- this.pipeline.add(this.scene);
96
-
97
- // Add demos
98
- this.scene.add(new FluentAPIDemo(this));
99
- this.scene.add(new GroupTransformDemo(this));
100
- this.scene.add(new BatchUpdateDemo(this));
101
- this.scene.add(new RelativeTransformDemo(this));
102
-
103
- // FPS counter
104
- this.pipeline.add(new FPSCounter(this, { anchor: "bottom-right" }));
105
- }
106
- }
107
-
108
- /**
109
- * Demo 1: Fluent API Chaining
110
- * Shows basic chained transform calls
111
- */
112
- class FluentAPIDemo extends GameObject {
113
- constructor(game) {
114
- super(game);
115
-
116
- // Create a rectangle using the new Transform API
117
- this.rect = new Rectangle({
118
- width: 80,
119
- height: 60,
120
- color: "#e94560",
121
- stroke: "#fff",
122
- lineWidth: 2,
123
- debug: false,
124
- debugColor: "#ff00ff"
125
- });
126
- allShapes.push(this.rect);
127
-
128
- // Use fluent API to set initial position
129
- this.rect.transform
130
- .x(-200)
131
- .y(-120);
132
-
133
- // Label
134
- this.label = new TextShape("Fluent API", {
135
- x: -200,
136
- y: -170,
137
- font: "bold 14px monospace",
138
- color: "#fff",
139
- align: "center"
140
- });
141
-
142
- this.elapsed = 0;
143
- }
144
-
145
- update(dt) {
146
- super.update(dt);
147
- this.elapsed += dt;
148
-
149
- // Animate using the transform API
150
- this.rect.transform
151
- .rotation(this.elapsed * 45)
152
- .scaleX(0.8 + Math.sin(this.elapsed * 2) * 0.3)
153
- .scaleY(0.8 + Math.cos(this.elapsed * 2) * 0.3);
154
- }
155
-
156
- draw() {
157
- super.draw();
158
- this.rect.render();
159
- this.label.render();
160
- }
161
- }
162
-
163
- /**
164
- * Demo 2: Group Transform Operations
165
- * Shows group-wide transform operations
166
- */
167
- class GroupTransformDemo extends GameObject {
168
- constructor(game) {
169
- super(game);
170
-
171
- // Create a group with multiple shapes
172
- this.group = new Group({ debug: false, debugColor: "#ff00ff" });
173
- allShapes.push(this.group);
174
-
175
- // Add shapes to group using transform API
176
- for (let i = 0; i < 3; i++) {
177
- const circle = new Circle(15 + i * 5, {
178
- color: Painter.colors.randomColorHSL(),
179
- stroke: "#fff",
180
- lineWidth: 1,
181
- debug: false,
182
- debugColor: "#ff00ff"
183
- });
184
- allShapes.push(circle);
185
- // Position using transform
186
- circle.transform.position(i * 40 - 40, 0);
187
- this.group.add(circle);
188
- }
189
-
190
- // Position the group
191
- this.group.transform.position(0, -120);
192
-
193
- // Label
194
- this.label = new TextShape("Group Transforms", {
195
- x: 0,
196
- y: -170,
197
- font: "bold 14px monospace",
198
- color: "#fff",
199
- align: "center"
200
- });
201
-
202
- this.elapsed = 0;
203
- }
204
-
205
- update(dt) {
206
- super.update(dt);
207
- this.elapsed += dt;
208
-
209
- // Animate group transform
210
- this.group.transform
211
- .rotation(this.elapsed * 30)
212
- .scale(0.9 + Math.sin(this.elapsed * 1.5) * 0.2);
213
-
214
- // Animate individual children using forEachTransform
215
- this.group.forEachTransform((t, child, i) => {
216
- // Each child rotates at different speed
217
- t.rotation(-this.elapsed * (60 + i * 30));
218
- });
219
- }
220
-
221
- draw() {
222
- super.draw();
223
- this.group.render();
224
- this.label.render();
225
- }
226
- }
227
-
228
- /**
229
- * Demo 3: Batch Updates
230
- * Shows using set() for multiple properties at once
231
- */
232
- class BatchUpdateDemo extends GameObject {
233
- constructor(game) {
234
- super(game);
235
-
236
- this.star = new Star(30, 5, 0.5, {
237
- color: "#ffc107",
238
- stroke: "#fff",
239
- lineWidth: 2,
240
- debug: false,
241
- debugColor: "#ff00ff"
242
- });
243
- allShapes.push(this.star);
244
-
245
- // Use batch set for initial state
246
- this.star.transform.set({
247
- x: 200,
248
- y: -120,
249
- rotation: 0,
250
- scaleX: 1,
251
- scaleY: 1
252
- });
253
-
254
- // Label
255
- this.label = new TextShape("Batch set()", {
256
- x: 200,
257
- y: -170,
258
- font: "bold 14px monospace",
259
- color: "#fff",
260
- align: "center"
261
- });
262
-
263
- this.elapsed = 0;
264
- }
265
-
266
- update(dt) {
267
- super.update(dt);
268
- this.elapsed += dt;
269
-
270
- // Use batch update for animation
271
- const pulse = Math.sin(this.elapsed * 3);
272
- const wobble = Math.sin(this.elapsed * 5) * 5;
273
-
274
- this.star.transform.set({
275
- rotation: this.elapsed * 60,
276
- scaleX: 1 + pulse * 0.3,
277
- scaleY: 1 - pulse * 0.3
278
- });
279
-
280
- // Also translate using relative method
281
- this.star.transform.x(200 + wobble);
282
- }
283
-
284
- draw() {
285
- super.draw();
286
- this.star.render();
287
- this.label.render();
288
- }
289
- }
290
-
291
- /**
292
- * Demo 4: Animated Transforms
293
- * Shows position, rotation, and scale animations
294
- */
295
- class RelativeTransformDemo extends GameObject {
296
- constructor(game) {
297
- super(game);
298
-
299
- // Create shapes for demonstrating animated transforms
300
- this.shapes = [];
301
- const positions = [
302
- { x: -200, y: 80 },
303
- { x: 0, y: 80 },
304
- { x: 200, y: 80 }
305
- ];
306
-
307
- const types = [
308
- { name: "position", shape: new Rectangle({ width: 50, height: 50, color: "#00d9ff", stroke: "#fff", lineWidth: 2, debug: false, debugColor: "#ff00ff" }) },
309
- { name: "rotation", shape: new Triangle(40, { color: "#ff6b6b", stroke: "#fff", lineWidth: 2, debug: false, debugColor: "#ff00ff" }) },
310
- { name: "scale", shape: new Circle(25, { color: "#7bed9f", stroke: "#fff", lineWidth: 2, debug: false, debugColor: "#ff00ff" }) }
311
- ];
312
-
313
- types.forEach((type, i) => {
314
- allShapes.push(type.shape);
315
- type.shape.transform.position(positions[i].x, positions[i].y);
316
- type.label = new TextShape(type.name + "()", {
317
- x: positions[i].x,
318
- y: 30,
319
- font: "bold 14px monospace",
320
- color: "#fff",
321
- align: "center"
322
- });
323
- type.baseX = positions[i].x;
324
- type.baseY = positions[i].y;
325
- this.shapes.push(type);
326
- });
327
-
328
- this.elapsed = 0;
329
- this.lastUpdate = 0;
330
- }
331
-
332
- update(dt) {
333
- super.update(dt);
334
- this.elapsed += dt;
335
-
336
- // position demo - oscillate position
337
- const tx = Math.sin(this.elapsed * 2) * 30;
338
- const ty = Math.cos(this.elapsed * 3) * 15;
339
- this.shapes[0].shape.transform.position(this.shapes[0].baseX + tx, this.shapes[0].baseY + ty);
340
-
341
- // rotation demo - continuous rotation
342
- this.shapes[1].shape.transform.rotation(this.elapsed * 90);
343
-
344
- // scale demo - pulsing scale
345
- const scale = 0.7 + Math.abs(Math.sin(this.elapsed * 2)) * 0.6;
346
- this.shapes[2].shape.transform.scale(scale);
347
- }
348
-
349
- draw() {
350
- super.draw();
351
- this.shapes.forEach(s => {
352
- s.shape.render();
353
- s.label.render();
354
- });
355
- }
356
- }
357
-
358
- // Start the game
359
- window.addEventListener("load", () => {
360
- const canvas = document.getElementById("game");
361
- const game = new TransformDemoGame(canvas);
362
- game.start();
363
-
364
- // Debug toggle button
365
- let debugEnabled = false;
366
- const debugBtn = document.getElementById("debug-toggle");
367
-
368
- debugBtn.addEventListener("click", () => {
369
- debugEnabled = !debugEnabled;
370
- debugBtn.classList.toggle("active", debugEnabled);
371
- debugBtn.textContent = debugEnabled ? "Debug: ON" : "Toggle Debug";
372
-
373
- // Toggle debug on all shapes
374
- allShapes.forEach(shape => {
375
- shape._debug = debugEnabled;
376
- });
377
- });
378
-
379
- // Randomize colors on click
380
- canvas.addEventListener("click", () => {
381
- game.scene.children.forEach(child => {
382
- if (child.rect) child.rect.color = Painter.colors.randomColorHSL();
383
- if (child.star) child.star.color = Painter.colors.randomColorHSL();
384
- if (child.group) {
385
- child.group.children.forEach(c => {
386
- c.color = Painter.colors.randomColorHSL();
387
- });
388
- }
389
- if (child.shapes) {
390
- child.shapes.forEach(s => {
391
- s.shape.color = Painter.colors.randomColorHSL();
392
- });
393
- }
394
- });
395
- });
396
- });
397
- </script>
398
- </body>
399
-
400
- </html>
package/demos/tween.html DELETED
@@ -1,45 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Tween</title>
8
- <link rel="stylesheet" href="demos.css" />
9
- <script src="./js/info-toggle.js"></script>
10
- </head>
11
-
12
- <body>
13
- <div id="info">
14
- <strong>Tween Demo</strong> - A box animated over time. The library features two motion-related classes:
15
- <span style="color:#CCC">
16
- <li><code>Tween</code> - Contains motion primitives, lerps and easing functions.</li>
17
- <li><code>Tweenetik</code> - A shorcut class that leverates Tween to interpolate object properties over time</li>
18
- <pre>
19
- Tweenetik.to(
20
- mySprite, // an object or sprite
21
- { scaleX: scale, scaleY: scale}, // the properties & end-values
22
- 2.0, // duration in seconds
23
- Easing.easeOutBounce, // easing function
24
- {
25
- delay: 0.5, // optional 0.5s delay
26
- onStart: () => console.log("Tween started!"),
27
- onComplete: () => console.log("Tween done!"),
28
- onUpdate: () => console.log("Updated frame"),
29
- }
30
- );</pre>
31
- </span>
32
- </div>
33
- <canvas id="game"></canvas>
34
- <script type="module">
35
- import { MyGame } from './js/tweendemo.js';
36
-
37
- window.addEventListener("load", () => {
38
- const canvas = document.getElementById("game");
39
- const game = new MyGame(canvas);
40
- game.start();
41
- });
42
- </script>
43
- </body>
44
-
45
- </html>
@@ -1,33 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>Opacity</title>
8
- <link rel="stylesheet" href="demos.css" />
9
- <script src="./js/info-toggle.js"></script>
10
- </head>
11
-
12
- <body>
13
- <div id="info">
14
- <strong>Visibility Toggle Demo</strong> - Shows how game objects can be dynamically shown or hidden.
15
- <span style="color:#CCC">
16
- <li><code>Transformable</code> — The base class providing the <code>visible</code> property.</li>
17
- <li><code>Pipeline Integration</code> — The pipeline skips invisible objects during rendering.</li>
18
- <li><code>Dynamic Toggling</code> — Click the button to toggle visibility of a random square.</li>
19
- </span>
20
- </div>
21
- <canvas id="game"></canvas>
22
- <script type="module">
23
- import { MyGame } from './js/visibility.js';
24
-
25
- window.addEventListener("load", () => {
26
- const canvas = document.getElementById("game");
27
- const game = new MyGame(canvas);
28
- game.start();
29
- });
30
- </script>
31
- </body>
32
-
33
- </html>
package/docs/README.md DELETED
@@ -1,230 +0,0 @@
1
- # GCanvas Documentation
2
-
3
- > A minimalist 2D canvas rendering library built for learning, expression, and creative coding.
4
-
5
- GCanvas is a modular 2D rendering and game framework built on top of the HTML5 Canvas API. Inspired by the simplicity of p5.js and the composability of game engines.
6
-
7
- ## Quick Navigation
8
-
9
- | Section | Description |
10
- |---------|-------------|
11
- | [Getting Started](./getting-started/installation.md) | Installation and first steps |
12
- | [Concepts](./concepts/architecture-overview.md) | Core architecture and design |
13
- | [Shapes Module](./modules/shapes/README.md) | Drawing primitives and hierarchy |
14
- | [Game Module](./modules/game/README.md) | Game loop and GameObjects |
15
- | [Particle Module](./modules/particle/README.md) | High-performance particle systems |
16
- | [Util Module](./modules/util/README.md) | Camera3D, Scene3D, layouts |
17
- | [Collision Module](./modules/collision/README.md) | Collision detection and management |
18
- | [State Module](./modules/state/README.md) | State machines for entities and games |
19
- | [Painter Module](./modules/painter/README.md) | Low-level canvas API |
20
-
21
- ## Architecture Overview
22
-
23
- ```
24
- ┌─────────────────────────────────────────────────────────────┐
25
- │ GCanvas │
26
- ├─────────────────────────────────────────────────────────────┤
27
- │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
28
- │ │ Shapes │ │ Game │ │ Painter │ │
29
- │ │ (Drawing) │ │ (Lifecycle) │ │ (Canvas API) │ │
30
- │ └─────────────┘ └─────────────┘ └─────────────────────┘ │
31
- ├─────────────────────────────────────────────────────────────┤
32
- │ ┌───────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
33
- │ │ Collision │ │ State │ │ Motion │ │ IO │ ... │
34
- │ │ (Physics) │ │ (FSM) │ │ (Anim) │ │ (Input) │ │
35
- │ └───────────┘ └─────────┘ └─────────┘ └─────────┘ │
36
- └─────────────────────────────────────────────────────────────┘
37
- ```
38
-
39
- GCanvas is organized into **12 core modules**:
40
-
41
- | Module | Purpose |
42
- |--------|---------|
43
- | **[shapes](./modules/shapes/README.md)** | 40+ drawable primitives and shape classes |
44
- | **[game](./modules/game/README.md)** | Core game loop, Pipeline, GameObjects, Scenes |
45
- | **[particle](./modules/particle/README.md)** | High-performance particle systems with pooling |
46
- | **[collision](./modules/collision/README.md)** | Collision detection algorithms and group management |
47
- | **[state](./modules/state/README.md)** | State machines with lifecycle callbacks |
48
- | **[painter](./modules/painter/README.md)** | Low-level canvas drawing API |
49
- | **[util](./modules/util/README.md)** | Camera3D, Scene3D, Layout, Position utilities |
50
- | **motion** | Animation with Tweenetik and Motion patterns |
51
- | **io** | Input handling (Mouse, Keyboard, Touch, Events) |
52
- | **math** | Random, Noise, Fractals, Patterns |
53
- | **mixins** | Draggable, Anchor behaviors |
54
- | **logger** | Debug logging system |
55
-
56
- ## Two-Layer Architecture
57
-
58
- GCanvas provides two complementary ways to work:
59
-
60
- ### Shape Layer (Declarative Drawing)
61
-
62
- For static visuals and simple graphics. Use shapes directly without a game loop:
63
-
64
- ```js
65
- import { Circle, Rectangle, Painter } from '@guinetik/gcanvas';
66
-
67
- Painter.init(ctx);
68
-
69
- const circle = new Circle(100, { x: 200, y: 150, color: 'red' });
70
- circle.draw();
71
- ```
72
-
73
- ### Game Layer (Interactive Entities)
74
-
75
- For games, simulations, and interactive applications:
76
-
77
- ```js
78
- import { Game, Scene, GameObject, Circle } from '@guinetik/gcanvas';
79
-
80
- class Player extends GameObject {
81
- constructor(game) {
82
- super(game);
83
- this.shape = new Circle(40, { color: 'blue' });
84
- this.enableInteractivity(this.shape);
85
- }
86
-
87
- update(dt) {
88
- // Game logic here
89
- }
90
-
91
- render() {
92
- this.shape.draw();
93
- }
94
- }
95
- ```
96
-
97
- [Learn more about the Two-Layer Architecture](./concepts/two-layer-architecture.md)
98
-
99
- ## The Rendering Pipeline
100
-
101
- Every visual element inherits from a chain of base classes:
102
-
103
- ```
104
- Euclidian ─── Position (x, y) and size (width, height)
105
-
106
- Geometry2d ─── Bounding boxes and constraints
107
-
108
- Traceable ─── Debug visualization
109
-
110
- Renderable ─── Visibility, opacity, shadows
111
-
112
- Transformable ─── Rotation and scaling
113
-
114
- Shape ─── Fill color, stroke, line styling
115
-
116
- [Circle, Rectangle, Star, Cube, ...] ─── Concrete implementations
117
- ```
118
-
119
- [Learn more about the Rendering Pipeline](./concepts/rendering-pipeline.md)
120
-
121
- ## Quick Start
122
-
123
- ### Installation
124
-
125
- **NPM (Recommended):**
126
-
127
- ```bash
128
- npm install @guinetik/gcanvas
129
- ```
130
-
131
- **Or clone the repository:**
132
-
133
- ```bash
134
- git clone https://github.com/guinetik/gcanvas.git
135
- cd gcanvas
136
- npm install
137
- npm run dev
138
- ```
139
-
140
- ### Hello World
141
-
142
- ```html
143
- <canvas id="game"></canvas>
144
- <script type="module">
145
- import { Game, Scene, Rectangle, TextShape, Group } from '@guinetik/gcanvas';
146
-
147
- class HelloWorld extends Game {
148
- init() {
149
- this.enableFluidSize();
150
- this.backgroundColor = 'black';
151
-
152
- const box = new Rectangle(200, 80, {
153
- color: '#111',
154
- stroke: '#0f0',
155
- lineWidth: 2
156
- });
157
-
158
- const label = new TextShape('Hello World!', {
159
- font: '18px monospace',
160
- color: '#0f0',
161
- align: 'center',
162
- baseline: 'middle'
163
- });
164
-
165
- const group = new Group({ x: this.width / 2, y: this.height / 2 });
166
- group.add(box);
167
- group.add(label);
168
-
169
- const scene = new Scene(this);
170
- scene.add(group);
171
- this.pipeline.add(scene);
172
- }
173
- }
174
-
175
- const game = new HelloWorld(document.getElementById('game'));
176
- game.start();
177
- </script>
178
- ```
179
-
180
- [Full getting started guide](./getting-started/hello-world.md)
181
-
182
- ## Features
183
-
184
- - **40+ Shape Primitives** - Circle, Rectangle, Star, Polygon, Heart, and more
185
- - **2.5D Shapes** - Cube, Cylinder, Sphere, Cone, Prism with pseudo-3D rendering
186
- - **Groups** - Composite shapes with collective transforms
187
- - **Transforms** - Rotation, scale, opacity, constraints
188
- - **Painter API** - Direct canvas control when needed
189
- - **GameObjects** - Interactive entities with lifecycle methods
190
- - **Scenes & Scene3D** - Hierarchical organization with optional 3D projection
191
- - **Camera3D** - Pseudo-3D projection with mouse-controlled rotation
192
- - **Particle Systems** - High-performance particles with object pooling and composable updaters
193
- - **Collision Detection** - AABB, circles, lines, sweep tests, and group management
194
- - **State Machines** - FSM with enter/update/exit lifecycle, timed transitions
195
- - **UI Components** - Button, ToggleButton, Cursor, Layout managers
196
- - **Motion System** - Stateless animation patterns (orbit, bounce, spiral...)
197
- - **Tweenetik** - Property-based tweening with easing
198
- - **Event System** - Mouse, touch, keyboard with unified input
199
- - **Zero Dependencies** - Pure JavaScript, works everywhere
200
-
201
- ## Demo
202
-
203
- See GCanvas in action: [gcanvas.guinetik.com](https://gcanvas.guinetik.com)
204
-
205
- Or run locally:
206
-
207
- ```bash
208
- npm run dev
209
- ```
210
-
211
- ## API Documentation
212
-
213
- - [Shapes Module](./modules/shapes/README.md) - All drawable primitives
214
- - [Game Module](./modules/game/README.md) - Game loop and objects
215
- - [Particle Module](./modules/particle/README.md) - Particle systems
216
- - [Util Module](./modules/util/README.md) - Camera3D, Scene3D, layouts
217
- - [Collision Module](./modules/collision/README.md) - Collision detection
218
- - [State Module](./modules/state/README.md) - State machines
219
- - [Painter Module](./modules/painter/README.md) - Canvas abstraction
220
-
221
- ## Learn More
222
-
223
- - [Architecture Overview](./concepts/architecture-overview.md)
224
- - [Rendering Pipeline](./concepts/rendering-pipeline.md)
225
- - [Game Lifecycle](./concepts/lifecycle.md)
226
- - [Installation Guide](./getting-started/installation.md)
227
-
228
- ---
229
-
230
- **Source:** [github.com/guinetik/gcanvas](https://github.com/guinetik/gcanvas)