@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
@@ -1,157 +1,175 @@
1
- # Installation
2
-
3
- > How to set up GCanvas in your project.
4
-
5
- ## Prerequisites
6
-
7
- - Node.js 18+ (for development)
8
- - Modern browser with ES6 support
9
-
10
- ## Option 1: Clone Repository
11
-
12
- The recommended way to get started:
13
-
14
- ```bash
15
- git clone https://github.com/guinetik/gcanvas.git
16
- cd gcanvas
17
- npm install
18
- ```
19
-
20
- ### Run Development Server
21
-
22
- ```bash
23
- npm run dev
24
- ```
25
-
26
- This starts Vite's dev server with hot reload. Open `http://localhost:5173` to see the demos.
27
-
28
- ### Build the Library
29
-
30
- ```bash
31
- npm run build
32
- ```
33
-
34
- Outputs to `dist/`:
35
- - `gcanvas.es.js` - ES Module
36
- - `gcanvas.es.min.js` - ES Module (minified)
37
- - `gcanvas.umd.js` - UMD bundle
38
- - `gcanvas.umd.min.js` - UMD bundle (minified)
39
-
40
- ## Option 2: NPM (Coming Soon)
41
-
42
- ```bash
43
- npm install gcanvas
44
- ```
45
-
46
- Then import in your project:
47
-
48
- ```js
49
- import { Game, Circle, Rectangle } from 'gcanvas';
50
- ```
51
-
52
- ## Option 3: Direct Script Include
53
-
54
- ### ES Module
55
-
56
- ```html
57
- <script type="module">
58
- import { Circle, Painter } from './dist/gcanvas.es.min.js';
59
-
60
- const canvas = document.getElementById('canvas');
61
- Painter.init(canvas.getContext('2d'));
62
-
63
- const circle = new Circle(50, { x: 100, y: 100, color: 'red' });
64
- circle.draw();
65
- </script>
66
- ```
67
-
68
- ### UMD Bundle
69
-
70
- ```html
71
- <script src="./dist/gcanvas.umd.min.js"></script>
72
- <script>
73
- const { Circle, Painter } = GCanvas;
74
-
75
- const canvas = document.getElementById('canvas');
76
- Painter.init(canvas.getContext('2d'));
77
-
78
- const circle = new GCanvas.Circle(50, { x: 100, y: 100, color: 'red' });
79
- circle.draw();
80
- </script>
81
- ```
82
-
83
- ## Project Structure
84
-
85
- ```
86
- gcanvas/
87
- ├── src/ # Source code
88
- │ ├── shapes/ # Shape classes
89
- │ ├── game/ # Game loop, objects
90
- │ ├── painter/ # Canvas abstraction
91
- │ ├── motion/ # Animation
92
- │ ├── io/ # Input handling
93
- │ └── index.js # Main entry point
94
- ├── demos/ # Demo applications
95
- ├── dist/ # Built library
96
- └── docs/ # Documentation
97
- ```
98
-
99
- ## NPM Scripts
100
-
101
- | Script | Description |
102
- |--------|-------------|
103
- | `npm run dev` | Start development server |
104
- | `npm run build` | Build library |
105
- | `npm run build:demo` | Build demos for deployment |
106
- | `npm run docs` | Generate JSDoc documentation |
107
- | `npm run test` | Run tests |
108
-
109
- ## TypeScript Support
110
-
111
- TypeScript definitions are coming soon. For now, the library is written in JavaScript with JSDoc annotations.
112
-
113
- ## Browser Support
114
-
115
- GCanvas works in all modern browsers:
116
-
117
- - Chrome 60+
118
- - Firefox 55+
119
- - Safari 11+
120
- - Edge 79+
121
-
122
- ## Next Steps
123
-
124
- - [Hello World](./hello-world.md) - Draw your first shape
125
- - [First Game](./first-game.md) - Create an interactive game
126
- - [Architecture Overview](../concepts/architecture-overview.md) - Understand the design
127
-
128
- ## Troubleshooting
129
-
130
- ### Canvas not found
131
-
132
- Make sure your canvas element has an ID and the script runs after DOM is ready:
133
-
134
- ```html
135
- <canvas id="game"></canvas>
136
- <script type="module">
137
- // Script runs after DOM is parsed when using type="module"
138
- const canvas = document.getElementById('game');
139
- </script>
140
- ```
141
-
142
- ### Module not found
143
-
144
- When using ES modules, ensure paths are correct:
145
-
146
- ```js
147
- // Relative path from your script
148
- import { Circle } from './dist/gcanvas.es.min.js';
149
-
150
- // Or absolute path
151
- import { Circle } from '/dist/gcanvas.es.min.js';
152
- ```
153
-
154
- ## Related
155
-
156
- - [Hello World](./hello-world.md)
157
- - [Architecture Overview](../concepts/architecture-overview.md)
1
+ # Installation
2
+
3
+ > How to set up GCanvas in your project.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js 18+ (for development)
8
+ - Modern browser with ES6 support
9
+
10
+ ## Option 1: Clone Repository
11
+
12
+ The recommended way to get started:
13
+
14
+ ```bash
15
+ git clone https://github.com/guinetik/gcanvas.git
16
+ cd gcanvas
17
+ npm install
18
+ ```
19
+
20
+ ### Run Development Server
21
+
22
+ ```bash
23
+ npm run dev
24
+ ```
25
+
26
+ This starts Vite's dev server with hot reload. Open `http://localhost:5173` to see the demos.
27
+
28
+ ### Build the Library
29
+
30
+ ```bash
31
+ npm run build
32
+ ```
33
+
34
+ Outputs to `dist/`:
35
+ - `gcanvas.es.js` - ES Module
36
+ - `gcanvas.es.min.js` - ES Module (minified)
37
+ - `gcanvas.umd.js` - UMD bundle
38
+ - `gcanvas.umd.min.js` - UMD bundle (minified)
39
+
40
+ ## Option 2: NPM
41
+
42
+ ```bash
43
+ npm install @guinetik/gcanvas
44
+ ```
45
+
46
+ Then import in your project:
47
+
48
+ ```js
49
+ import { Game, Circle, Rectangle } from '@guinetik/gcanvas';
50
+ ```
51
+
52
+ ## Option 3: Direct Script Include
53
+
54
+ ### ES Module
55
+
56
+ ```html
57
+ <script type="module">
58
+ import { Circle, Painter } from './dist/gcanvas.es.min.js';
59
+
60
+ const canvas = document.getElementById('canvas');
61
+ Painter.init(canvas.getContext('2d'));
62
+
63
+ const circle = new Circle(50, { x: 100, y: 100, color: 'red' });
64
+ circle.draw();
65
+ </script>
66
+ ```
67
+
68
+ ### UMD Bundle
69
+
70
+ ```html
71
+ <script src="./dist/gcanvas.umd.min.js"></script>
72
+ <script>
73
+ const { Circle, Painter } = GCanvas;
74
+
75
+ const canvas = document.getElementById('canvas');
76
+ Painter.init(canvas.getContext('2d'));
77
+
78
+ const circle = new GCanvas.Circle(50, { x: 100, y: 100, color: 'red' });
79
+ circle.draw();
80
+ </script>
81
+ ```
82
+
83
+ ## Project Structure
84
+
85
+ ```
86
+ gcanvas/
87
+ ├── src/ # Source code
88
+ │ ├── shapes/ # Shape classes
89
+ │ ├── game/ # Game loop, objects
90
+ │ ├── painter/ # Canvas abstraction
91
+ │ ├── motion/ # Animation
92
+ │ ├── io/ # Input handling
93
+ │ └── index.js # Main entry point
94
+ ├── demos/ # Demo applications
95
+ ├── dist/ # Built library
96
+ └── docs/ # Documentation
97
+ ```
98
+
99
+ ## NPM Scripts
100
+
101
+ | Script | Description |
102
+ |--------|-------------|
103
+ | `npm run dev` | Start development server |
104
+ | `npm run build` | Build library |
105
+ | `npm run build:demo` | Build demos for deployment |
106
+ | `npm run docs` | Generate JSDoc documentation |
107
+ | `npm run test` | Run tests |
108
+
109
+ ## TypeScript Support
110
+
111
+ GCanvas includes full TypeScript definitions. After installing, you get complete type support:
112
+
113
+ ```typescript
114
+ import { Game, Circle, Camera3D, ParticleSystem } from '@guinetik/gcanvas';
115
+
116
+ // Full IntelliSense and type checking
117
+ const game = new Game(document.getElementById('canvas') as HTMLCanvasElement);
118
+ const circle = new Circle(50, { x: 100, y: 100, fill: 'red' });
119
+ ```
120
+
121
+ The types require ES2015+ target in your `tsconfig.json`:
122
+
123
+ ```json
124
+ {
125
+ "compilerOptions": {
126
+ "lib": ["es2015", "dom"]
127
+ }
128
+ }
129
+ ```
130
+
131
+ ## Browser Support
132
+
133
+ GCanvas works in all modern browsers:
134
+
135
+ - Chrome 60+
136
+ - Firefox 55+
137
+ - Safari 11+
138
+ - Edge 79+
139
+
140
+ ## Next Steps
141
+
142
+ - [Hello World](./hello-world.md) - Draw your first shape
143
+ - [First Game](./first-game.md) - Create an interactive game
144
+ - [Architecture Overview](../concepts/architecture-overview.md) - Understand the design
145
+
146
+ ## Troubleshooting
147
+
148
+ ### Canvas not found
149
+
150
+ Make sure your canvas element has an ID and the script runs after DOM is ready:
151
+
152
+ ```html
153
+ <canvas id="game"></canvas>
154
+ <script type="module">
155
+ // Script runs after DOM is parsed when using type="module"
156
+ const canvas = document.getElementById('game');
157
+ </script>
158
+ ```
159
+
160
+ ### Module not found
161
+
162
+ When using ES modules, ensure paths are correct:
163
+
164
+ ```js
165
+ // Relative path from your script
166
+ import { Circle } from './dist/gcanvas.es.min.js';
167
+
168
+ // Or absolute path
169
+ import { Circle } from '/dist/gcanvas.es.min.js';
170
+ ```
171
+
172
+ ## Related
173
+
174
+ - [Hello World](./hello-world.md)
175
+ - [Architecture Overview](../concepts/architecture-overview.md)
@@ -9,7 +9,7 @@ The collision module provides both low-level collision detection algorithms and
9
9
  ## Quick Start
10
10
 
11
11
  ```js
12
- import { Collision, CollisionSystem } from 'gcanvas';
12
+ import { Collision, CollisionSystem } from '@guinetik/gcanvas';
13
13
 
14
14
  // Low-level: Direct collision checks
15
15
  const playerBounds = player.getBounds();
@@ -352,7 +352,7 @@ player.alive = false; // Skipped
352
352
  A Space Invaders-style collision setup:
353
353
 
354
354
  ```js
355
- import { Game, CollisionSystem, Collision } from 'gcanvas';
355
+ import { Game, CollisionSystem, Collision } from '@guinetik/gcanvas';
356
356
 
357
357
  class SpaceGame extends Game {
358
358
  init() {
@@ -10,7 +10,7 @@ The Fluent module provides a builder-pattern API layer on top of GCanvas's objec
10
10
 
11
11
  **Traditional approach:**
12
12
  ```js
13
- import { Game, Scene, GameObject, Circle } from 'gcanvas';
13
+ import { Game, Scene, GameObject, Circle } from '@guinetik/gcanvas';
14
14
 
15
15
  const canvas = document.getElementById('game');
16
16
  const game = new Game(canvas);
@@ -32,7 +32,7 @@ game.start();
32
32
 
33
33
  **Fluent approach:**
34
34
  ```js
35
- import { gcanvas } from 'gcanvas';
35
+ import { gcanvas } from '@guinetik/gcanvas';
36
36
 
37
37
  gcanvas({ bg: 'black' })
38
38
  .scene('game')
@@ -53,7 +53,7 @@ gcanvas({ bg: 'black' })
53
53
  ## Quick Start
54
54
 
55
55
  ```js
56
- import { gcanvas } from 'gcanvas';
56
+ import { gcanvas } from '@guinetik/gcanvas';
57
57
 
58
58
  // Create a game with a pulsing circle
59
59
  gcanvas({ bg: '#1a1a2e' })
@@ -73,7 +73,7 @@ gcanvas({ bg: '#1a1a2e' })
73
73
  The main entry point for the full fluent API.
74
74
 
75
75
  ```js
76
- import { gcanvas } from 'gcanvas';
76
+ import { gcanvas } from '@guinetik/gcanvas';
77
77
 
78
78
  const game = gcanvas({
79
79
  canvas: document.getElementById('game'), // Optional: use existing canvas
@@ -94,7 +94,7 @@ const game = gcanvas({
94
94
  Ultra-simple mode for quick creative coding prototypes.
95
95
 
96
96
  ```js
97
- import { sketch } from 'gcanvas';
97
+ import { sketch } from '@guinetik/gcanvas';
98
98
 
99
99
  sketch(800, 600, '#1a1a1a')
100
100
  .circle(400, 300, 50, 'lime')
@@ -967,7 +967,7 @@ export const uiModule = (g) => g
967
967
  .text('SCORE: 0', { font: '20px monospace', fill: 'white' });
968
968
 
969
969
  // main.js
970
- import { gcanvas } from 'gcanvas';
970
+ import { gcanvas } from '@guinetik/gcanvas';
971
971
  import { playerModule } from './scenes/player';
972
972
  import { enemiesModule } from './scenes/enemies';
973
973
  import { uiModule } from './scenes/ui';