@guinetik/gcanvas 1.0.0 → 1.0.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/demos/fluid-simple.html +22 -0
  2. package/demos/fluid.html +37 -0
  3. package/demos/index.html +2 -0
  4. package/demos/js/blob.js +18 -5
  5. package/demos/js/fluid-simple.js +253 -0
  6. package/demos/js/fluid.js +527 -0
  7. package/demos/js/tde/accretiondisk.js +64 -11
  8. package/demos/js/tde/blackholescene.js +2 -2
  9. package/demos/js/tde/config.js +2 -2
  10. package/demos/js/tde/index.js +152 -27
  11. package/demos/js/tde/lensedstarfield.js +32 -25
  12. package/demos/js/tde/tdestar.js +78 -98
  13. package/demos/js/tde/tidalstream.js +23 -7
  14. package/docs/README.md +230 -222
  15. package/docs/api/FluidSystem.md +173 -0
  16. package/docs/concepts/architecture-overview.md +204 -204
  17. package/docs/concepts/rendering-pipeline.md +279 -279
  18. package/docs/concepts/two-layer-architecture.md +229 -229
  19. package/docs/fluid-dynamics.md +97 -0
  20. package/docs/getting-started/first-game.md +354 -354
  21. package/docs/getting-started/installation.md +175 -157
  22. package/docs/modules/collision/README.md +2 -2
  23. package/docs/modules/fluent/README.md +6 -6
  24. package/docs/modules/game/README.md +303 -303
  25. package/docs/modules/isometric-camera.md +2 -2
  26. package/docs/modules/isometric.md +1 -1
  27. package/docs/modules/painter/README.md +328 -328
  28. package/docs/modules/particle/README.md +3 -3
  29. package/docs/modules/shapes/README.md +221 -221
  30. package/docs/modules/shapes/base/euclidian.md +123 -123
  31. package/docs/modules/shapes/base/shape.md +262 -262
  32. package/docs/modules/shapes/base/transformable.md +243 -243
  33. package/docs/modules/state/README.md +2 -2
  34. package/docs/modules/util/README.md +1 -1
  35. package/docs/modules/util/camera3d.md +3 -3
  36. package/docs/modules/util/scene3d.md +1 -1
  37. package/package.json +3 -1
  38. package/readme.md +19 -5
  39. package/src/collision/collision.js +75 -0
  40. package/src/game/index.js +2 -1
  41. package/src/game/pipeline.js +3 -3
  42. package/src/game/systems/FluidSystem.js +835 -0
  43. package/src/game/systems/index.js +11 -0
  44. package/src/game/ui/button.js +39 -18
  45. package/src/game/ui/cursor.js +14 -0
  46. package/src/game/ui/fps.js +12 -4
  47. package/src/game/ui/index.js +2 -0
  48. package/src/game/ui/stepper.js +549 -0
  49. package/src/game/ui/theme.js +121 -0
  50. package/src/game/ui/togglebutton.js +9 -3
  51. package/src/game/ui/tooltip.js +11 -4
  52. package/src/math/fluid.js +507 -0
  53. package/src/math/index.js +2 -0
  54. package/src/mixins/anchor.js +17 -7
  55. package/src/motion/tweenetik.js +16 -0
  56. package/src/shapes/index.js +1 -0
  57. package/src/util/camera3d.js +218 -12
  58. package/types/fluent.d.ts +361 -0
  59. package/types/game.d.ts +303 -0
  60. package/types/index.d.ts +144 -5
  61. package/types/math.d.ts +361 -0
  62. package/types/motion.d.ts +271 -0
  63. package/types/particle.d.ts +373 -0
  64. package/types/shapes.d.ts +107 -9
  65. package/types/util.d.ts +353 -0
  66. package/types/webgl.d.ts +109 -0
  67. package/disk_example.png +0 -0
  68. package/tde.png +0 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Game Systems Module
3
+ *
4
+ * Higher-level systems that integrate multiple components
5
+ * for complex simulations and behaviors.
6
+ *
7
+ * @module game/systems
8
+ */
9
+
10
+ export { FluidSystem } from "./FluidSystem.js";
11
+
@@ -4,10 +4,16 @@
4
4
  * A basic UI Button GameObject that combines a Rectangle shape
5
5
  * and a Text label using a Group. It supports hover and press
6
6
  * states, and fires an optional onClick callback when clicked.
7
+ *
8
+ * Theme: Terminal × Vercel aesthetic
9
+ * - Dark transparent backgrounds
10
+ * - Neon green accents (#0f0)
11
+ * - Inverted colors on hover
7
12
  ***************************************************************/
8
13
 
9
14
  import { Group, Rectangle, TextShape, Shape } from "../../shapes";
10
15
  import { GameObject } from "../objects/go";
16
+ import { UI_THEME } from "./theme.js";
11
17
 
12
18
  /**
13
19
  * Button - A clickable UI element as a GameObject.
@@ -56,15 +62,15 @@ export class Button extends GameObject {
56
62
  * @param {Function} [options.onRelease=null] - Callback to invoke upon button release.
57
63
  * @param {string} [options.anchor] - Optional anchor for positioning (e.g. "top-left").
58
64
  * @param {number} [options.padding] - Extra padding if using anchor.
59
- * @param {string} [options.colorDefaultBg="#eee"] - Background color in default state.
60
- * @param {string} [options.colorDefaultStroke="#999"] - Stroke color in default state.
61
- * @param {string} [options.colorDefaultText="#333"] - Text color in default state.
62
- * @param {string} [options.colorHoverBg="#222"] - Background color in hover state.
63
- * @param {string} [options.colorHoverStroke="#16F529"] - Stroke color in hover state.
64
- * @param {string} [options.colorHoverText="#16F529"] - Text color in hover state.
65
- * @param {string} [options.colorPressedBg="#111"] - Background color in pressed state.
66
- * @param {string} [options.colorPressedStroke="#00aaff"] - Stroke color in pressed state.
67
- * @param {string} [options.colorPressedText="#00aaff"] - Text color in pressed state.
65
+ * @param {string} [options.colorDefaultBg="rgba(0,0,0,0.85)"] - Background color in default state.
66
+ * @param {string} [options.colorDefaultStroke="rgba(0,255,0,0.4)"] - Stroke color in default state.
67
+ * @param {string} [options.colorDefaultText="#0f0"] - Text color in default state.
68
+ * @param {string} [options.colorHoverBg="#0f0"] - Background color in hover state (inverted).
69
+ * @param {string} [options.colorHoverStroke="#0f0"] - Stroke color in hover state.
70
+ * @param {string} [options.colorHoverText="#000"] - Text color in hover state (inverted).
71
+ * @param {string} [options.colorPressedBg="#0c0"] - Background color in pressed state.
72
+ * @param {string} [options.colorPressedStroke="#0f0"] - Stroke color in pressed state.
73
+ * @param {string} [options.colorPressedText="#000"] - Text color in pressed state.
68
74
  * @param {...any} rest - Additional properties passed to the superclass.
69
75
  */
70
76
  constructor(game, options = {}) {
@@ -89,15 +95,16 @@ export class Button extends GameObject {
89
95
  onPressed = null,
90
96
  onRelease = null,
91
97
  padding = 10,
92
- colorDefaultBg = "#eee",
93
- colorDefaultStroke = "#999",
94
- colorDefaultText = "#333",
95
- colorHoverBg = "#222",
96
- colorHoverStroke = "#16F529",
97
- colorHoverText = "#16F529",
98
- colorPressedBg = "#111",
99
- colorPressedStroke = "#00aaff",
100
- colorPressedText = "#00aaff",
98
+ // Terminal × Vercel theme: dark bg, green accents, inverted hover
99
+ colorDefaultBg = UI_THEME.button.default.bg,
100
+ colorDefaultStroke = UI_THEME.button.default.stroke,
101
+ colorDefaultText = UI_THEME.button.default.text,
102
+ colorHoverBg = UI_THEME.button.hover.bg,
103
+ colorHoverStroke = UI_THEME.button.hover.stroke,
104
+ colorHoverText = UI_THEME.button.hover.text,
105
+ colorPressedBg = UI_THEME.button.pressed.bg,
106
+ colorPressedStroke = UI_THEME.button.pressed.stroke,
107
+ colorPressedText = UI_THEME.button.pressed.text,
101
108
  } = options;
102
109
 
103
110
  // Basic position and sizing
@@ -386,6 +393,20 @@ export class Button extends GameObject {
386
393
  this._boundsDirty = true;
387
394
  }
388
395
 
396
+ /**
397
+ * Get the bounding box of this Button for hit testing.
398
+ * Required for the event system to work properly.
399
+ * @returns {{x: number, y: number, width: number, height: number}} Bounds object
400
+ */
401
+ getBounds() {
402
+ return {
403
+ x: this.x,
404
+ y: this.y,
405
+ width: this.width,
406
+ height: this.height,
407
+ };
408
+ }
409
+
389
410
  /**
390
411
  * Render the Button each frame by drawing the underlying Group.
391
412
  */
@@ -6,6 +6,20 @@ import { GameObject } from "../objects/go.js";
6
6
  * A GameObject that replaces the native mouse pointer with a custom shape.
7
7
  * - Provide a normal shape (e.g. small Circle or custom icon).
8
8
  * - Optionally provide a pressed shape to show while the mouse/touch is down.
9
+ *
10
+ * Theme: Terminal × Vercel aesthetic
11
+ * For best results, use shapes with terminal green (#0f0) outlines:
12
+ *
13
+ * ```js
14
+ * const normalCursor = new Circle(0, 0, 8, {
15
+ * stroke: "#0f0",
16
+ * lineWidth: 2
17
+ * });
18
+ * const pressedCursor = new Circle(0, 0, 6, {
19
+ * fill: "#0f0"
20
+ * });
21
+ * const cursor = new Cursor(game, normalCursor, pressedCursor);
22
+ * ```
9
23
  *
10
24
  * Usage:
11
25
  * const cursor = new Cursor(game, normalShape, pressedShape);
@@ -1,7 +1,13 @@
1
1
  import { Text } from "../objects";
2
+ import { UI_THEME } from "./theme.js";
2
3
 
3
4
  /**
4
5
  * FPSCounter - A simple text object displaying frames per second
6
+ *
7
+ * Theme: Terminal × Vercel aesthetic
8
+ * - Neon green monospace text
9
+ * - Subtle flicker effect on update
10
+ *
5
11
  * @extends Text
6
12
  */
7
13
  export class FPSCounter extends Text {
@@ -9,17 +15,19 @@ export class FPSCounter extends Text {
9
15
  * Create an FPS counter
10
16
  * @param {Game} game - The main game instance
11
17
  * @param {Object} [options={}] - Configuration options
18
+ * @param {string} [options.color="#0f0"] - Text color (default: terminal green)
19
+ * @param {string} [options.font="11px monospace"] - Font style
12
20
  */
13
21
  constructor(game, options = {}) {
14
- // Spread the user options but provide defaults for FPS counter
22
+ // Terminal × Vercel theme: green monospace text
15
23
  super(game, "0 FPS", {
16
24
  x: 0,
17
25
  y: 0,
18
- font: "12px monospace",
19
- color: "#0f0", // Default to green
26
+ font: UI_THEME.fonts.small,
27
+ color: UI_THEME.colors.neonGreen,
20
28
  align: "center",
21
29
  baseline: "middle",
22
- debug:false,
30
+ debug: false,
23
31
  ...options, // This will override defaults with user provided values
24
32
  });
25
33
 
@@ -3,3 +3,5 @@ export { Cursor } from "./cursor.js";
3
3
  export { ToggleButton } from "./togglebutton.js";
4
4
  export { Tooltip } from "./tooltip.js";
5
5
  export { FPSCounter } from "./fps.js";
6
+ export { Stepper } from "./stepper.js";
7
+ export { UI_THEME } from "./theme.js";