@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,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
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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';
|