@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,221 +1,221 @@
1
- # Shapes Module
2
-
3
- > 40+ drawable primitives and the shape inheritance hierarchy.
4
-
5
- ## Overview
6
-
7
- The shapes module provides all visual primitives in GCanvas. Every shape inherits from a chain of base classes that add progressively more functionality.
8
-
9
- ## Quick Start
10
-
11
- ```js
12
- import { Circle, Rectangle, Star, Group } from 'gcanvas';
13
-
14
- // Create shapes
15
- const circle = new Circle(50, { x: 100, y: 100, color: 'red' });
16
- const rect = new Rectangle({ width: 80, height: 40, color: 'blue' });
17
-
18
- // Draw
19
- circle.draw();
20
- rect.draw();
21
-
22
- // Group shapes together
23
- const group = new Group({ x: 400, y: 300 });
24
- group.add(circle);
25
- group.add(rect);
26
- group.draw();
27
- ```
28
-
29
- ## Class Hierarchy
30
-
31
- ```
32
- Euclidian ─────────── Position & size
33
-
34
- Geometry2d ────────── Bounding boxes & constraints
35
-
36
- Traceable ─────────── Debug visualization
37
-
38
- Renderable ────────── Visibility, opacity, shadows
39
-
40
- Transformable ─────── Rotation & scaling
41
-
42
- Shape ─────────────── Fill & stroke styling
43
-
44
- ├── Circle
45
- ├── Rectangle
46
- ├── Star
47
- ├── Triangle
48
- ├── Polygon
49
- ├── ... (40+ shapes)
50
- └── Group (container)
51
- ```
52
-
53
- [View detailed hierarchy](./hierarchy.md)
54
-
55
- ## Base Classes
56
-
57
- | Class | Purpose | Documentation |
58
- |-------|---------|---------------|
59
- | [Euclidian](./base/euclidian.md) | Position (x, y) and size (width, height) | [Link](./base/euclidian.md) |
60
- | [Geometry2d](./base/geometry2d.md) | Bounding boxes and constraints | [Link](./base/geometry2d.md) |
61
- | [Renderable](./base/renderable.md) | Visibility, opacity, shadows | [Link](./base/renderable.md) |
62
- | [Transformable](./base/transformable.md) | Rotation and scaling | [Link](./base/transformable.md) |
63
- | [Shape](./base/shape.md) | Fill, stroke, line styling | [Link](./base/shape.md) |
64
-
65
- ## Available Shapes
66
-
67
- ### 2D Primitives
68
-
69
- | Shape | Description |
70
- |-------|-------------|
71
- | Circle | Basic circle with radius |
72
- | Rectangle | Centered rectangle |
73
- | RoundedRectangle | Rectangle with rounded corners |
74
- | Square | Square (convenience) |
75
- | Triangle | Three-sided polygon |
76
- | Line | Line segment |
77
- | Arc | Curved arc segment |
78
- | Polygon | N-sided polygon |
79
- | Hexagon | Six-sided shape |
80
-
81
- ### Complex Shapes
82
-
83
- | Shape | Description |
84
- |-------|-------------|
85
- | Star | Star with configurable points |
86
- | Heart | Heart shape |
87
- | Diamond | Diamond/rhombus |
88
- | Cross | Plus/cross shape |
89
- | Arrow | Arrow shape |
90
- | Pin | Map pin/marker |
91
- | Ring | Hollow ring/donut |
92
- | Cloud | Cloud-like shape |
93
- | PieSlice | Pie chart slice |
94
-
95
- ### 3D-Looking Shapes
96
-
97
- | Shape | Description |
98
- |-------|-------------|
99
- | Cube | Isometric cube with face colors |
100
- | Sphere | Sphere with shading |
101
- | Cylinder | Cylindrical shape |
102
- | Cone | Cone/pyramid |
103
- | Prism | Triangular prism |
104
-
105
- ### Special Shapes
106
-
107
- | Shape | Description |
108
- |-------|-------------|
109
- | TextShape | Rotatable, scalable text |
110
- | Image | Image rendering |
111
- | SVGShape | SVG path-based shapes |
112
- | BezierShape | Bezier curve shapes |
113
- | PatternRectangle | Pattern-filled rectangle |
114
- | StickFigure | Simple stick figure |
115
-
116
- ### Containers
117
-
118
- | Class | Description |
119
- |-------|-------------|
120
- | Group | Container for composing multiple shapes |
121
-
122
- ## Common Properties
123
-
124
- All shapes inherit these properties:
125
-
126
- ```js
127
- // From Euclidian
128
- shape.x // Center X position
129
- shape.y // Center Y position
130
- shape.width // Width
131
- shape.height // Height
132
-
133
- // From Geometry2d
134
- shape.minX // Minimum X constraint
135
- shape.maxX // Maximum X constraint
136
- shape.minY // Minimum Y constraint
137
- shape.maxY // Maximum Y constraint
138
- shape.crisp // Pixel-perfect alignment
139
-
140
- // From Renderable
141
- shape.visible // Show/hide
142
- shape.opacity // Transparency (0-1)
143
- shape.active // Receive updates
144
- shape.zIndex // Stacking order
145
- shape.shadowColor
146
- shape.shadowBlur
147
- shape.shadowOffsetX
148
- shape.shadowOffsetY
149
-
150
- // From Transformable
151
- shape.rotation // Rotation in degrees
152
- shape.scaleX // Horizontal scale
153
- shape.scaleY // Vertical scale
154
-
155
- // From Shape
156
- shape.color // Fill color
157
- shape.stroke // Stroke color
158
- shape.lineWidth // Stroke width
159
- shape.lineJoin // "miter", "round", "bevel"
160
- shape.lineCap // "butt", "round", "square"
161
- ```
162
-
163
- ## Usage Patterns
164
-
165
- ### Basic Drawing
166
-
167
- ```js
168
- const circle = new Circle(50, { x: 100, y: 100, color: 'red' });
169
- circle.draw();
170
- ```
171
-
172
- ### With Transforms
173
-
174
- ```js
175
- const rect = new Rectangle({
176
- width: 100,
177
- height: 50,
178
- color: '#4ecdc4',
179
- rotation: 45, // 45 degrees
180
- scaleX: 1.5,
181
- opacity: 0.8
182
- });
183
- rect.draw();
184
- ```
185
-
186
- ### Grouping Shapes
187
-
188
- ```js
189
- const group = new Group({ x: 400, y: 300 });
190
- group.add(new Circle(30, { color: 'red' }));
191
- group.add(new Rectangle({ y: 50, width: 60, height: 30, color: 'blue' }));
192
-
193
- // Transform entire group
194
- group.rotation = 15;
195
- group.draw();
196
- ```
197
-
198
- ### Animation
199
-
200
- ```js
201
- function animate() {
202
- Painter.clear();
203
-
204
- shape.rotation += 1;
205
- shape.x = 400 + Math.sin(Date.now() * 0.001) * 100;
206
-
207
- shape.draw();
208
- requestAnimationFrame(animate);
209
- }
210
- ```
211
-
212
- ## Related
213
-
214
- - [Rendering Pipeline](../../concepts/rendering-pipeline.md) - How shapes render
215
- - [Two-Layer Architecture](../../concepts/two-layer-architecture.md) - Shape vs Game layer
216
- - [Painter Module](../painter/README.md) - Low-level drawing API
217
-
218
- ## See Also
219
-
220
- - [Hello World](../../getting-started/hello-world.md)
221
- - [Shape Hierarchy](./hierarchy.md)
1
+ # Shapes Module
2
+
3
+ > 40+ drawable primitives and the shape inheritance hierarchy.
4
+
5
+ ## Overview
6
+
7
+ The shapes module provides all visual primitives in GCanvas. Every shape inherits from a chain of base classes that add progressively more functionality.
8
+
9
+ ## Quick Start
10
+
11
+ ```js
12
+ import { Circle, Rectangle, Star, Group } from '@guinetik/gcanvas';
13
+
14
+ // Create shapes
15
+ const circle = new Circle(50, { x: 100, y: 100, color: 'red' });
16
+ const rect = new Rectangle({ width: 80, height: 40, color: 'blue' });
17
+
18
+ // Draw
19
+ circle.draw();
20
+ rect.draw();
21
+
22
+ // Group shapes together
23
+ const group = new Group({ x: 400, y: 300 });
24
+ group.add(circle);
25
+ group.add(rect);
26
+ group.draw();
27
+ ```
28
+
29
+ ## Class Hierarchy
30
+
31
+ ```
32
+ Euclidian ─────────── Position & size
33
+
34
+ Geometry2d ────────── Bounding boxes & constraints
35
+
36
+ Traceable ─────────── Debug visualization
37
+
38
+ Renderable ────────── Visibility, opacity, shadows
39
+
40
+ Transformable ─────── Rotation & scaling
41
+
42
+ Shape ─────────────── Fill & stroke styling
43
+
44
+ ├── Circle
45
+ ├── Rectangle
46
+ ├── Star
47
+ ├── Triangle
48
+ ├── Polygon
49
+ ├── ... (40+ shapes)
50
+ └── Group (container)
51
+ ```
52
+
53
+ [View detailed hierarchy](./hierarchy.md)
54
+
55
+ ## Base Classes
56
+
57
+ | Class | Purpose | Documentation |
58
+ |-------|---------|---------------|
59
+ | [Euclidian](./base/euclidian.md) | Position (x, y) and size (width, height) | [Link](./base/euclidian.md) |
60
+ | [Geometry2d](./base/geometry2d.md) | Bounding boxes and constraints | [Link](./base/geometry2d.md) |
61
+ | [Renderable](./base/renderable.md) | Visibility, opacity, shadows | [Link](./base/renderable.md) |
62
+ | [Transformable](./base/transformable.md) | Rotation and scaling | [Link](./base/transformable.md) |
63
+ | [Shape](./base/shape.md) | Fill, stroke, line styling | [Link](./base/shape.md) |
64
+
65
+ ## Available Shapes
66
+
67
+ ### 2D Primitives
68
+
69
+ | Shape | Description |
70
+ |-------|-------------|
71
+ | Circle | Basic circle with radius |
72
+ | Rectangle | Centered rectangle |
73
+ | RoundedRectangle | Rectangle with rounded corners |
74
+ | Square | Square (convenience) |
75
+ | Triangle | Three-sided polygon |
76
+ | Line | Line segment |
77
+ | Arc | Curved arc segment |
78
+ | Polygon | N-sided polygon |
79
+ | Hexagon | Six-sided shape |
80
+
81
+ ### Complex Shapes
82
+
83
+ | Shape | Description |
84
+ |-------|-------------|
85
+ | Star | Star with configurable points |
86
+ | Heart | Heart shape |
87
+ | Diamond | Diamond/rhombus |
88
+ | Cross | Plus/cross shape |
89
+ | Arrow | Arrow shape |
90
+ | Pin | Map pin/marker |
91
+ | Ring | Hollow ring/donut |
92
+ | Cloud | Cloud-like shape |
93
+ | PieSlice | Pie chart slice |
94
+
95
+ ### 3D-Looking Shapes
96
+
97
+ | Shape | Description |
98
+ |-------|-------------|
99
+ | Cube | Isometric cube with face colors |
100
+ | Sphere | Sphere with shading |
101
+ | Cylinder | Cylindrical shape |
102
+ | Cone | Cone/pyramid |
103
+ | Prism | Triangular prism |
104
+
105
+ ### Special Shapes
106
+
107
+ | Shape | Description |
108
+ |-------|-------------|
109
+ | TextShape | Rotatable, scalable text |
110
+ | Image | Image rendering |
111
+ | SVGShape | SVG path-based shapes |
112
+ | BezierShape | Bezier curve shapes |
113
+ | PatternRectangle | Pattern-filled rectangle |
114
+ | StickFigure | Simple stick figure |
115
+
116
+ ### Containers
117
+
118
+ | Class | Description |
119
+ |-------|-------------|
120
+ | Group | Container for composing multiple shapes |
121
+
122
+ ## Common Properties
123
+
124
+ All shapes inherit these properties:
125
+
126
+ ```js
127
+ // From Euclidian
128
+ shape.x // Center X position
129
+ shape.y // Center Y position
130
+ shape.width // Width
131
+ shape.height // Height
132
+
133
+ // From Geometry2d
134
+ shape.minX // Minimum X constraint
135
+ shape.maxX // Maximum X constraint
136
+ shape.minY // Minimum Y constraint
137
+ shape.maxY // Maximum Y constraint
138
+ shape.crisp // Pixel-perfect alignment
139
+
140
+ // From Renderable
141
+ shape.visible // Show/hide
142
+ shape.opacity // Transparency (0-1)
143
+ shape.active // Receive updates
144
+ shape.zIndex // Stacking order
145
+ shape.shadowColor
146
+ shape.shadowBlur
147
+ shape.shadowOffsetX
148
+ shape.shadowOffsetY
149
+
150
+ // From Transformable
151
+ shape.rotation // Rotation in degrees
152
+ shape.scaleX // Horizontal scale
153
+ shape.scaleY // Vertical scale
154
+
155
+ // From Shape
156
+ shape.color // Fill color
157
+ shape.stroke // Stroke color
158
+ shape.lineWidth // Stroke width
159
+ shape.lineJoin // "miter", "round", "bevel"
160
+ shape.lineCap // "butt", "round", "square"
161
+ ```
162
+
163
+ ## Usage Patterns
164
+
165
+ ### Basic Drawing
166
+
167
+ ```js
168
+ const circle = new Circle(50, { x: 100, y: 100, color: 'red' });
169
+ circle.draw();
170
+ ```
171
+
172
+ ### With Transforms
173
+
174
+ ```js
175
+ const rect = new Rectangle({
176
+ width: 100,
177
+ height: 50,
178
+ color: '#4ecdc4',
179
+ rotation: 45, // 45 degrees
180
+ scaleX: 1.5,
181
+ opacity: 0.8
182
+ });
183
+ rect.draw();
184
+ ```
185
+
186
+ ### Grouping Shapes
187
+
188
+ ```js
189
+ const group = new Group({ x: 400, y: 300 });
190
+ group.add(new Circle(30, { color: 'red' }));
191
+ group.add(new Rectangle({ y: 50, width: 60, height: 30, color: 'blue' }));
192
+
193
+ // Transform entire group
194
+ group.rotation = 15;
195
+ group.draw();
196
+ ```
197
+
198
+ ### Animation
199
+
200
+ ```js
201
+ function animate() {
202
+ Painter.clear();
203
+
204
+ shape.rotation += 1;
205
+ shape.x = 400 + Math.sin(Date.now() * 0.001) * 100;
206
+
207
+ shape.draw();
208
+ requestAnimationFrame(animate);
209
+ }
210
+ ```
211
+
212
+ ## Related
213
+
214
+ - [Rendering Pipeline](../../concepts/rendering-pipeline.md) - How shapes render
215
+ - [Two-Layer Architecture](../../concepts/two-layer-architecture.md) - Shape vs Game layer
216
+ - [Painter Module](../painter/README.md) - Low-level drawing API
217
+
218
+ ## See Also
219
+
220
+ - [Hello World](../../getting-started/hello-world.md)
221
+ - [Shape Hierarchy](./hierarchy.md)