@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.
- package/demos/fluid-simple.html +22 -0
- package/demos/fluid.html +37 -0
- package/demos/index.html +2 -0
- package/demos/js/blob.js +18 -5
- package/demos/js/fluid-simple.js +253 -0
- package/demos/js/fluid.js +527 -0
- package/demos/js/tde/accretiondisk.js +64 -11
- package/demos/js/tde/blackholescene.js +2 -2
- package/demos/js/tde/config.js +2 -2
- package/demos/js/tde/index.js +152 -27
- package/demos/js/tde/lensedstarfield.js +32 -25
- package/demos/js/tde/tdestar.js +78 -98
- package/demos/js/tde/tidalstream.js +23 -7
- package/docs/README.md +230 -222
- package/docs/api/FluidSystem.md +173 -0
- package/docs/concepts/architecture-overview.md +204 -204
- package/docs/concepts/rendering-pipeline.md +279 -279
- package/docs/concepts/two-layer-architecture.md +229 -229
- package/docs/fluid-dynamics.md +97 -0
- package/docs/getting-started/first-game.md +354 -354
- package/docs/getting-started/installation.md +175 -157
- package/docs/modules/collision/README.md +2 -2
- package/docs/modules/fluent/README.md +6 -6
- package/docs/modules/game/README.md +303 -303
- package/docs/modules/isometric-camera.md +2 -2
- package/docs/modules/isometric.md +1 -1
- package/docs/modules/painter/README.md +328 -328
- package/docs/modules/particle/README.md +3 -3
- package/docs/modules/shapes/README.md +221 -221
- package/docs/modules/shapes/base/euclidian.md +123 -123
- package/docs/modules/shapes/base/shape.md +262 -262
- package/docs/modules/shapes/base/transformable.md +243 -243
- package/docs/modules/state/README.md +2 -2
- package/docs/modules/util/README.md +1 -1
- package/docs/modules/util/camera3d.md +3 -3
- package/docs/modules/util/scene3d.md +1 -1
- package/package.json +3 -1
- package/readme.md +19 -5
- package/src/collision/collision.js +75 -0
- package/src/game/index.js +2 -1
- package/src/game/pipeline.js +3 -3
- package/src/game/systems/FluidSystem.js +835 -0
- package/src/game/systems/index.js +11 -0
- package/src/game/ui/button.js +39 -18
- package/src/game/ui/cursor.js +14 -0
- package/src/game/ui/fps.js +12 -4
- package/src/game/ui/index.js +2 -0
- package/src/game/ui/stepper.js +549 -0
- package/src/game/ui/theme.js +121 -0
- package/src/game/ui/togglebutton.js +9 -3
- package/src/game/ui/tooltip.js +11 -4
- package/src/math/fluid.js +507 -0
- package/src/math/index.js +2 -0
- package/src/mixins/anchor.js +17 -7
- package/src/motion/tweenetik.js +16 -0
- package/src/shapes/index.js +1 -0
- package/src/util/camera3d.js +218 -12
- package/types/fluent.d.ts +361 -0
- package/types/game.d.ts +303 -0
- package/types/index.d.ts +144 -5
- package/types/math.d.ts +361 -0
- package/types/motion.d.ts +271 -0
- package/types/particle.d.ts +373 -0
- package/types/shapes.d.ts +107 -9
- package/types/util.d.ts +353 -0
- package/types/webgl.d.ts +109 -0
- package/disk_example.png +0 -0
- package/tde.png +0 -0
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
# Euclidian
|
|
2
|
-
|
|
3
|
-
> The root class defining spatial properties for all visual objects.
|
|
4
|
-
|
|
5
|
-
**Module:** [shapes](../README.md) | **Extends:** `Loggable` | **Source:** `src/shapes/euclidian.js`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
Euclidian is the foundation of all drawable objects in GCanvas. It defines the fundamental spatial contract: a 2D position and size. Before something becomes a shape, a renderable, or a transformable object, it first **exists in space**.
|
|
10
|
-
|
|
11
|
-
This class is abstract and intended to be subclassed.
|
|
12
|
-
|
|
13
|
-
## Constructor
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
new Euclidian(options)
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Parameters
|
|
20
|
-
|
|
21
|
-
| Parameter | Type | Default | Description |
|
|
22
|
-
|-----------|------|---------|-------------|
|
|
23
|
-
| `options` | `Object` | `{}` | Configuration options |
|
|
24
|
-
|
|
25
|
-
### Options
|
|
26
|
-
|
|
27
|
-
| Option | Type | Default | Description |
|
|
28
|
-
|--------|------|---------|-------------|
|
|
29
|
-
| `x` | `number` | `0` | X position (center-based) |
|
|
30
|
-
| `y` | `number` | `0` | Y position (center-based) |
|
|
31
|
-
| `width` | `number` | `0` | Width in pixels |
|
|
32
|
-
| `height` | `number` | `0` | Height in pixels |
|
|
33
|
-
| `debug` | `boolean` | `false` | Enable debug visualization |
|
|
34
|
-
| `debugColor` | `string` | `"#0f0"` | Debug outline color |
|
|
35
|
-
|
|
36
|
-
## Properties
|
|
37
|
-
|
|
38
|
-
| Property | Type | Description |
|
|
39
|
-
|----------|------|-------------|
|
|
40
|
-
| `x` | `number` | X center position in canvas space |
|
|
41
|
-
| `y` | `number` | Y center position in canvas space |
|
|
42
|
-
| `width` | `number` | Width of the object (always ≥ 0) |
|
|
43
|
-
| `height` | `number` | Height of the object (always ≥ 0) |
|
|
44
|
-
| `debug` | `boolean` | Whether debug overlay is enabled |
|
|
45
|
-
| `debugColor` | `string` | Color of the debug box outline |
|
|
46
|
-
|
|
47
|
-
## Coordinate System
|
|
48
|
-
|
|
49
|
-
GCanvas uses a **center-based** coordinate system:
|
|
50
|
-
|
|
51
|
-
```
|
|
52
|
-
┌────────────────────────────────┐
|
|
53
|
-
│ │
|
|
54
|
-
│ (x, y) │
|
|
55
|
-
│ ●───────────────┐ │
|
|
56
|
-
│ │ │ │
|
|
57
|
-
│ │ width │ │
|
|
58
|
-
│ │ │ │
|
|
59
|
-
│ └───────────────┘ │
|
|
60
|
-
│ height │
|
|
61
|
-
│ │
|
|
62
|
-
└────────────────────────────────┘
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
The `(x, y)` point is the **center** of the object, not the top-left corner.
|
|
66
|
-
|
|
67
|
-
## Example
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
import { Euclidian } from 'gcanvas';
|
|
71
|
-
|
|
72
|
-
// Euclidian is abstract, but shows the basic spatial contract
|
|
73
|
-
const spatial = {
|
|
74
|
-
x: 100, // Center at x=100
|
|
75
|
-
y: 100, // Center at y=100
|
|
76
|
-
width: 50, // 50 pixels wide
|
|
77
|
-
height: 30 // 30 pixels tall
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
// Top-left corner would be at (75, 85)
|
|
81
|
-
// x - width/2 = 100 - 25 = 75
|
|
82
|
-
// y - height/2 = 100 - 15 = 85
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Property Validation
|
|
86
|
-
|
|
87
|
-
All properties are validated on set:
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
shape.x = 100; // Valid
|
|
91
|
-
shape.x = null; // Throws Error: "Invalid property value: x null"
|
|
92
|
-
shape.x = undefined; // Throws Error: "Invalid property value: x undefined"
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
Width and height are clamped to be non-negative:
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
shape.width = -10; // Sets width to 0
|
|
99
|
-
shape.height = -5; // Sets height to 0
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
## Inheritance
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
Loggable
|
|
106
|
-
└── Euclidian <── You are here
|
|
107
|
-
└── Geometry2d
|
|
108
|
-
└── Traceable
|
|
109
|
-
└── Renderable
|
|
110
|
-
└── Transformable
|
|
111
|
-
└── Shape
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Related
|
|
115
|
-
|
|
116
|
-
- [Geometry2d](./geometry2d.md) - Adds bounding boxes and constraints
|
|
117
|
-
- [Shape Hierarchy](../hierarchy.md) - Full inheritance diagram
|
|
118
|
-
- [Rendering Pipeline](../../../concepts/rendering-pipeline.md) - How shapes render
|
|
119
|
-
|
|
120
|
-
## See Also
|
|
121
|
-
|
|
122
|
-
- [Shapes Module](../README.md)
|
|
123
|
-
- [Renderable](./renderable.md)
|
|
1
|
+
# Euclidian
|
|
2
|
+
|
|
3
|
+
> The root class defining spatial properties for all visual objects.
|
|
4
|
+
|
|
5
|
+
**Module:** [shapes](../README.md) | **Extends:** `Loggable` | **Source:** `src/shapes/euclidian.js`
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Euclidian is the foundation of all drawable objects in GCanvas. It defines the fundamental spatial contract: a 2D position and size. Before something becomes a shape, a renderable, or a transformable object, it first **exists in space**.
|
|
10
|
+
|
|
11
|
+
This class is abstract and intended to be subclassed.
|
|
12
|
+
|
|
13
|
+
## Constructor
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
new Euclidian(options)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Parameters
|
|
20
|
+
|
|
21
|
+
| Parameter | Type | Default | Description |
|
|
22
|
+
|-----------|------|---------|-------------|
|
|
23
|
+
| `options` | `Object` | `{}` | Configuration options |
|
|
24
|
+
|
|
25
|
+
### Options
|
|
26
|
+
|
|
27
|
+
| Option | Type | Default | Description |
|
|
28
|
+
|--------|------|---------|-------------|
|
|
29
|
+
| `x` | `number` | `0` | X position (center-based) |
|
|
30
|
+
| `y` | `number` | `0` | Y position (center-based) |
|
|
31
|
+
| `width` | `number` | `0` | Width in pixels |
|
|
32
|
+
| `height` | `number` | `0` | Height in pixels |
|
|
33
|
+
| `debug` | `boolean` | `false` | Enable debug visualization |
|
|
34
|
+
| `debugColor` | `string` | `"#0f0"` | Debug outline color |
|
|
35
|
+
|
|
36
|
+
## Properties
|
|
37
|
+
|
|
38
|
+
| Property | Type | Description |
|
|
39
|
+
|----------|------|-------------|
|
|
40
|
+
| `x` | `number` | X center position in canvas space |
|
|
41
|
+
| `y` | `number` | Y center position in canvas space |
|
|
42
|
+
| `width` | `number` | Width of the object (always ≥ 0) |
|
|
43
|
+
| `height` | `number` | Height of the object (always ≥ 0) |
|
|
44
|
+
| `debug` | `boolean` | Whether debug overlay is enabled |
|
|
45
|
+
| `debugColor` | `string` | Color of the debug box outline |
|
|
46
|
+
|
|
47
|
+
## Coordinate System
|
|
48
|
+
|
|
49
|
+
GCanvas uses a **center-based** coordinate system:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
┌────────────────────────────────┐
|
|
53
|
+
│ │
|
|
54
|
+
│ (x, y) │
|
|
55
|
+
│ ●───────────────┐ │
|
|
56
|
+
│ │ │ │
|
|
57
|
+
│ │ width │ │
|
|
58
|
+
│ │ │ │
|
|
59
|
+
│ └───────────────┘ │
|
|
60
|
+
│ height │
|
|
61
|
+
│ │
|
|
62
|
+
└────────────────────────────────┘
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The `(x, y)` point is the **center** of the object, not the top-left corner.
|
|
66
|
+
|
|
67
|
+
## Example
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import { Euclidian } from '@guinetik/gcanvas';
|
|
71
|
+
|
|
72
|
+
// Euclidian is abstract, but shows the basic spatial contract
|
|
73
|
+
const spatial = {
|
|
74
|
+
x: 100, // Center at x=100
|
|
75
|
+
y: 100, // Center at y=100
|
|
76
|
+
width: 50, // 50 pixels wide
|
|
77
|
+
height: 30 // 30 pixels tall
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Top-left corner would be at (75, 85)
|
|
81
|
+
// x - width/2 = 100 - 25 = 75
|
|
82
|
+
// y - height/2 = 100 - 15 = 85
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Property Validation
|
|
86
|
+
|
|
87
|
+
All properties are validated on set:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
shape.x = 100; // Valid
|
|
91
|
+
shape.x = null; // Throws Error: "Invalid property value: x null"
|
|
92
|
+
shape.x = undefined; // Throws Error: "Invalid property value: x undefined"
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Width and height are clamped to be non-negative:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
shape.width = -10; // Sets width to 0
|
|
99
|
+
shape.height = -5; // Sets height to 0
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Inheritance
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Loggable
|
|
106
|
+
└── Euclidian <── You are here
|
|
107
|
+
└── Geometry2d
|
|
108
|
+
└── Traceable
|
|
109
|
+
└── Renderable
|
|
110
|
+
└── Transformable
|
|
111
|
+
└── Shape
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Related
|
|
115
|
+
|
|
116
|
+
- [Geometry2d](./geometry2d.md) - Adds bounding boxes and constraints
|
|
117
|
+
- [Shape Hierarchy](../hierarchy.md) - Full inheritance diagram
|
|
118
|
+
- [Rendering Pipeline](../../../concepts/rendering-pipeline.md) - How shapes render
|
|
119
|
+
|
|
120
|
+
## See Also
|
|
121
|
+
|
|
122
|
+
- [Shapes Module](../README.md)
|
|
123
|
+
- [Renderable](./renderable.md)
|