@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,262 +1,262 @@
|
|
|
1
|
-
# Shape
|
|
2
|
-
|
|
3
|
-
> Fill color, stroke, and line styling for drawable primitives.
|
|
4
|
-
|
|
5
|
-
**Module:** [shapes](../README.md) | **Extends:** [Transformable](./transformable.md) | **Source:** `src/shapes/shape.js`
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
Shape is the base class for all drawable geometric primitives. It's the first class in the hierarchy to express **canvas styling intent**:
|
|
10
|
-
|
|
11
|
-
- Fill & stroke colors
|
|
12
|
-
- Line width & join styles
|
|
13
|
-
- Line cap styles
|
|
14
|
-
|
|
15
|
-
Shape does not define geometry — that's up to subclasses like Circle, Rectangle, etc.
|
|
16
|
-
|
|
17
|
-
## Constructor
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
new Shape(options)
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### Options
|
|
24
|
-
|
|
25
|
-
| Option | Type | Default | Description |
|
|
26
|
-
|--------|------|---------|-------------|
|
|
27
|
-
| `color` | `string \| null` | `null` | Fill color (CSS color) |
|
|
28
|
-
| `stroke` | `string \| null` | `null` | Stroke color (CSS color) |
|
|
29
|
-
| `lineWidth` | `number` | `1` | Stroke width in pixels |
|
|
30
|
-
| `lineJoin` | `string` | `"miter"` | Line join style |
|
|
31
|
-
| `lineCap` | `string` | `"butt"` | Line cap style |
|
|
32
|
-
| `miterLimit` | `number` | `10` | Maximum miter length |
|
|
33
|
-
|
|
34
|
-
Plus all options from [Transformable](./transformable.md).
|
|
35
|
-
|
|
36
|
-
## Properties
|
|
37
|
-
|
|
38
|
-
### Inherited
|
|
39
|
-
|
|
40
|
-
From Euclidian: `x`, `y`, `width`, `height`, `debug`, `debugColor`
|
|
41
|
-
|
|
42
|
-
From Geometry2d: `minX`, `maxX`, `minY`, `maxY`, `crisp`
|
|
43
|
-
|
|
44
|
-
From Renderable: `visible`, `opacity`, `active`, `zIndex`, `shadowColor`, `shadowBlur`, `shadowOffsetX`, `shadowOffsetY`
|
|
45
|
-
|
|
46
|
-
From Transformable: `rotation`, `scaleX`, `scaleY`
|
|
47
|
-
|
|
48
|
-
### Own Properties
|
|
49
|
-
|
|
50
|
-
| Property | Type | Description |
|
|
51
|
-
|----------|------|-------------|
|
|
52
|
-
| `color` | `string \| null` | Fill color (CSS color string) |
|
|
53
|
-
| `stroke` | `string \| null` | Stroke color (CSS color string) |
|
|
54
|
-
| `lineWidth` | `number` | Width of stroke in pixels |
|
|
55
|
-
| `lineJoin` | `"miter" \| "round" \| "bevel"` | Line join style |
|
|
56
|
-
| `lineCap` | `"butt" \| "round" \| "square"` | Line cap style |
|
|
57
|
-
| `miterLimit` | `number` | Maximum miter length before bevel |
|
|
58
|
-
|
|
59
|
-
## Fill and Stroke
|
|
60
|
-
|
|
61
|
-
```js
|
|
62
|
-
// Fill only
|
|
63
|
-
const filled = new Circle(50, {
|
|
64
|
-
color: 'red'
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Stroke only
|
|
68
|
-
const outlined = new Circle(50, {
|
|
69
|
-
stroke: 'blue',
|
|
70
|
-
lineWidth: 2
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// Both fill and stroke
|
|
74
|
-
const both = new Circle(50, {
|
|
75
|
-
color: 'red',
|
|
76
|
-
stroke: 'black',
|
|
77
|
-
lineWidth: 2
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Color Formats
|
|
82
|
-
|
|
83
|
-
Any valid CSS color string:
|
|
84
|
-
|
|
85
|
-
```js
|
|
86
|
-
shape.color = 'red'; // Named color
|
|
87
|
-
shape.color = '#ff0000'; // Hex
|
|
88
|
-
shape.color = '#f00'; // Short hex
|
|
89
|
-
shape.color = 'rgb(255, 0, 0)'; // RGB
|
|
90
|
-
shape.color = 'rgba(255, 0, 0, 0.5)'; // RGBA
|
|
91
|
-
shape.color = 'hsl(0, 100%, 50%)'; // HSL
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Line Join Styles
|
|
95
|
-
|
|
96
|
-
Controls how lines meet at corners:
|
|
97
|
-
|
|
98
|
-
```js
|
|
99
|
-
shape.lineJoin = 'miter'; // Sharp corners (default)
|
|
100
|
-
shape.lineJoin = 'round'; // Rounded corners
|
|
101
|
-
shape.lineJoin = 'bevel'; // Beveled corners
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
```
|
|
105
|
-
miter round bevel
|
|
106
|
-
╱ ╱ ╱
|
|
107
|
-
╱ ╱ ╱
|
|
108
|
-
──┼── ──╲── ──┘──
|
|
109
|
-
╲ ╲ ╲
|
|
110
|
-
╲ ╲ ╲
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Line Cap Styles
|
|
114
|
-
|
|
115
|
-
Controls how line endpoints look:
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
shape.lineCap = 'butt'; // Flat end at endpoint (default)
|
|
119
|
-
shape.lineCap = 'round'; // Rounded end
|
|
120
|
-
shape.lineCap = 'square'; // Square end extending past endpoint
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
```
|
|
124
|
-
butt round square
|
|
125
|
-
│ │ │
|
|
126
|
-
───┤ ───● ───┤
|
|
127
|
-
│ │ │
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## Miter Limit
|
|
131
|
-
|
|
132
|
-
When `lineJoin` is `"miter"`, very sharp angles can create very long miter points. `miterLimit` caps this:
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
shape.lineJoin = 'miter';
|
|
136
|
-
shape.miterLimit = 10; // Default, reasonable for most cases
|
|
137
|
-
shape.miterLimit = 2; // Shorter miters, more beveling
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Subclassing
|
|
141
|
-
|
|
142
|
-
Shape is abstract. Subclasses implement `draw()`:
|
|
143
|
-
|
|
144
|
-
```js
|
|
145
|
-
import { Shape, Painter } from 'gcanvas';
|
|
146
|
-
|
|
147
|
-
class CustomShape extends Shape {
|
|
148
|
-
constructor(options = {}) {
|
|
149
|
-
super(options);
|
|
150
|
-
// Custom initialization
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
draw() {
|
|
154
|
-
super.draw(); // Apply transforms
|
|
155
|
-
|
|
156
|
-
// Use this.color, this.stroke, this.lineWidth, etc.
|
|
157
|
-
if (this.color) {
|
|
158
|
-
Painter.colors.fill(this.color);
|
|
159
|
-
// Custom fill drawing
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (this.stroke) {
|
|
163
|
-
Painter.colors.stroke(this.stroke, this.lineWidth);
|
|
164
|
-
// Custom stroke drawing
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## Concrete Shape Classes
|
|
171
|
-
|
|
172
|
-
These classes extend Shape:
|
|
173
|
-
|
|
174
|
-
| Class | Description |
|
|
175
|
-
|-------|-------------|
|
|
176
|
-
| `Circle` | Circle with radius |
|
|
177
|
-
| `Rectangle` | Centered rectangle |
|
|
178
|
-
| `Triangle` | Three-sided polygon |
|
|
179
|
-
| `Star` | Star with n points |
|
|
180
|
-
| `Polygon` | N-sided polygon |
|
|
181
|
-
| `Line` | Line segment |
|
|
182
|
-
| `Arc` | Curved arc |
|
|
183
|
-
| `Heart` | Heart shape |
|
|
184
|
-
| `Diamond` | Diamond/rhombus |
|
|
185
|
-
| ... | And many more |
|
|
186
|
-
|
|
187
|
-
## Example
|
|
188
|
-
|
|
189
|
-
```js
|
|
190
|
-
import { Rectangle, Painter } from 'gcanvas';
|
|
191
|
-
|
|
192
|
-
const rect = new Rectangle({
|
|
193
|
-
x: 200,
|
|
194
|
-
y: 150,
|
|
195
|
-
width: 100,
|
|
196
|
-
height: 60,
|
|
197
|
-
color: '#4ecdc4',
|
|
198
|
-
stroke: '#2a9d8f',
|
|
199
|
-
lineWidth: 3,
|
|
200
|
-
lineJoin: 'round'
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
rect.draw();
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
## Complete Property Example
|
|
207
|
-
|
|
208
|
-
```js
|
|
209
|
-
const shape = new Circle(50, {
|
|
210
|
-
// Position (Euclidian)
|
|
211
|
-
x: 400,
|
|
212
|
-
y: 300,
|
|
213
|
-
|
|
214
|
-
// Constraints (Geometry2d)
|
|
215
|
-
minX: 50,
|
|
216
|
-
maxX: 750,
|
|
217
|
-
|
|
218
|
-
// Visibility (Renderable)
|
|
219
|
-
visible: true,
|
|
220
|
-
opacity: 0.9,
|
|
221
|
-
shadowColor: 'rgba(0,0,0,0.3)',
|
|
222
|
-
shadowBlur: 10,
|
|
223
|
-
shadowOffsetX: 5,
|
|
224
|
-
shadowOffsetY: 5,
|
|
225
|
-
|
|
226
|
-
// Transforms (Transformable)
|
|
227
|
-
rotation: 0,
|
|
228
|
-
scaleX: 1,
|
|
229
|
-
scaleY: 1,
|
|
230
|
-
|
|
231
|
-
// Styling (Shape)
|
|
232
|
-
color: '#ff6b6b',
|
|
233
|
-
stroke: '#c92a2a',
|
|
234
|
-
lineWidth: 2,
|
|
235
|
-
lineJoin: 'round',
|
|
236
|
-
lineCap: 'round'
|
|
237
|
-
});
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
## Inheritance
|
|
241
|
-
|
|
242
|
-
```
|
|
243
|
-
Transformable
|
|
244
|
-
└── Shape <── You are here
|
|
245
|
-
├── Circle
|
|
246
|
-
├── Rectangle
|
|
247
|
-
├── Triangle
|
|
248
|
-
├── Star
|
|
249
|
-
├── Polygon
|
|
250
|
-
└── ... (40+ shapes)
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
## Related
|
|
254
|
-
|
|
255
|
-
- [Transformable](./transformable.md) - Parent class
|
|
256
|
-
- [Shape Hierarchy](../hierarchy.md) - Full inheritance diagram
|
|
257
|
-
- [Shapes Module](../README.md) - All available shapes
|
|
258
|
-
|
|
259
|
-
## See Also
|
|
260
|
-
|
|
261
|
-
- [Rendering Pipeline](../../../concepts/rendering-pipeline.md)
|
|
262
|
-
- [Hello World](../../../getting-started/hello-world.md)
|
|
1
|
+
# Shape
|
|
2
|
+
|
|
3
|
+
> Fill color, stroke, and line styling for drawable primitives.
|
|
4
|
+
|
|
5
|
+
**Module:** [shapes](../README.md) | **Extends:** [Transformable](./transformable.md) | **Source:** `src/shapes/shape.js`
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
Shape is the base class for all drawable geometric primitives. It's the first class in the hierarchy to express **canvas styling intent**:
|
|
10
|
+
|
|
11
|
+
- Fill & stroke colors
|
|
12
|
+
- Line width & join styles
|
|
13
|
+
- Line cap styles
|
|
14
|
+
|
|
15
|
+
Shape does not define geometry — that's up to subclasses like Circle, Rectangle, etc.
|
|
16
|
+
|
|
17
|
+
## Constructor
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
new Shape(options)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Options
|
|
24
|
+
|
|
25
|
+
| Option | Type | Default | Description |
|
|
26
|
+
|--------|------|---------|-------------|
|
|
27
|
+
| `color` | `string \| null` | `null` | Fill color (CSS color) |
|
|
28
|
+
| `stroke` | `string \| null` | `null` | Stroke color (CSS color) |
|
|
29
|
+
| `lineWidth` | `number` | `1` | Stroke width in pixels |
|
|
30
|
+
| `lineJoin` | `string` | `"miter"` | Line join style |
|
|
31
|
+
| `lineCap` | `string` | `"butt"` | Line cap style |
|
|
32
|
+
| `miterLimit` | `number` | `10` | Maximum miter length |
|
|
33
|
+
|
|
34
|
+
Plus all options from [Transformable](./transformable.md).
|
|
35
|
+
|
|
36
|
+
## Properties
|
|
37
|
+
|
|
38
|
+
### Inherited
|
|
39
|
+
|
|
40
|
+
From Euclidian: `x`, `y`, `width`, `height`, `debug`, `debugColor`
|
|
41
|
+
|
|
42
|
+
From Geometry2d: `minX`, `maxX`, `minY`, `maxY`, `crisp`
|
|
43
|
+
|
|
44
|
+
From Renderable: `visible`, `opacity`, `active`, `zIndex`, `shadowColor`, `shadowBlur`, `shadowOffsetX`, `shadowOffsetY`
|
|
45
|
+
|
|
46
|
+
From Transformable: `rotation`, `scaleX`, `scaleY`
|
|
47
|
+
|
|
48
|
+
### Own Properties
|
|
49
|
+
|
|
50
|
+
| Property | Type | Description |
|
|
51
|
+
|----------|------|-------------|
|
|
52
|
+
| `color` | `string \| null` | Fill color (CSS color string) |
|
|
53
|
+
| `stroke` | `string \| null` | Stroke color (CSS color string) |
|
|
54
|
+
| `lineWidth` | `number` | Width of stroke in pixels |
|
|
55
|
+
| `lineJoin` | `"miter" \| "round" \| "bevel"` | Line join style |
|
|
56
|
+
| `lineCap` | `"butt" \| "round" \| "square"` | Line cap style |
|
|
57
|
+
| `miterLimit` | `number` | Maximum miter length before bevel |
|
|
58
|
+
|
|
59
|
+
## Fill and Stroke
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
// Fill only
|
|
63
|
+
const filled = new Circle(50, {
|
|
64
|
+
color: 'red'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Stroke only
|
|
68
|
+
const outlined = new Circle(50, {
|
|
69
|
+
stroke: 'blue',
|
|
70
|
+
lineWidth: 2
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Both fill and stroke
|
|
74
|
+
const both = new Circle(50, {
|
|
75
|
+
color: 'red',
|
|
76
|
+
stroke: 'black',
|
|
77
|
+
lineWidth: 2
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Color Formats
|
|
82
|
+
|
|
83
|
+
Any valid CSS color string:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
shape.color = 'red'; // Named color
|
|
87
|
+
shape.color = '#ff0000'; // Hex
|
|
88
|
+
shape.color = '#f00'; // Short hex
|
|
89
|
+
shape.color = 'rgb(255, 0, 0)'; // RGB
|
|
90
|
+
shape.color = 'rgba(255, 0, 0, 0.5)'; // RGBA
|
|
91
|
+
shape.color = 'hsl(0, 100%, 50%)'; // HSL
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Line Join Styles
|
|
95
|
+
|
|
96
|
+
Controls how lines meet at corners:
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
shape.lineJoin = 'miter'; // Sharp corners (default)
|
|
100
|
+
shape.lineJoin = 'round'; // Rounded corners
|
|
101
|
+
shape.lineJoin = 'bevel'; // Beveled corners
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
miter round bevel
|
|
106
|
+
╱ ╱ ╱
|
|
107
|
+
╱ ╱ ╱
|
|
108
|
+
──┼── ──╲── ──┘──
|
|
109
|
+
╲ ╲ ╲
|
|
110
|
+
╲ ╲ ╲
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Line Cap Styles
|
|
114
|
+
|
|
115
|
+
Controls how line endpoints look:
|
|
116
|
+
|
|
117
|
+
```js
|
|
118
|
+
shape.lineCap = 'butt'; // Flat end at endpoint (default)
|
|
119
|
+
shape.lineCap = 'round'; // Rounded end
|
|
120
|
+
shape.lineCap = 'square'; // Square end extending past endpoint
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
butt round square
|
|
125
|
+
│ │ │
|
|
126
|
+
───┤ ───● ───┤
|
|
127
|
+
│ │ │
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Miter Limit
|
|
131
|
+
|
|
132
|
+
When `lineJoin` is `"miter"`, very sharp angles can create very long miter points. `miterLimit` caps this:
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
shape.lineJoin = 'miter';
|
|
136
|
+
shape.miterLimit = 10; // Default, reasonable for most cases
|
|
137
|
+
shape.miterLimit = 2; // Shorter miters, more beveling
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Subclassing
|
|
141
|
+
|
|
142
|
+
Shape is abstract. Subclasses implement `draw()`:
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
import { Shape, Painter } from '@guinetik/gcanvas';
|
|
146
|
+
|
|
147
|
+
class CustomShape extends Shape {
|
|
148
|
+
constructor(options = {}) {
|
|
149
|
+
super(options);
|
|
150
|
+
// Custom initialization
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
draw() {
|
|
154
|
+
super.draw(); // Apply transforms
|
|
155
|
+
|
|
156
|
+
// Use this.color, this.stroke, this.lineWidth, etc.
|
|
157
|
+
if (this.color) {
|
|
158
|
+
Painter.colors.fill(this.color);
|
|
159
|
+
// Custom fill drawing
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (this.stroke) {
|
|
163
|
+
Painter.colors.stroke(this.stroke, this.lineWidth);
|
|
164
|
+
// Custom stroke drawing
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Concrete Shape Classes
|
|
171
|
+
|
|
172
|
+
These classes extend Shape:
|
|
173
|
+
|
|
174
|
+
| Class | Description |
|
|
175
|
+
|-------|-------------|
|
|
176
|
+
| `Circle` | Circle with radius |
|
|
177
|
+
| `Rectangle` | Centered rectangle |
|
|
178
|
+
| `Triangle` | Three-sided polygon |
|
|
179
|
+
| `Star` | Star with n points |
|
|
180
|
+
| `Polygon` | N-sided polygon |
|
|
181
|
+
| `Line` | Line segment |
|
|
182
|
+
| `Arc` | Curved arc |
|
|
183
|
+
| `Heart` | Heart shape |
|
|
184
|
+
| `Diamond` | Diamond/rhombus |
|
|
185
|
+
| ... | And many more |
|
|
186
|
+
|
|
187
|
+
## Example
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
import { Rectangle, Painter } from '@guinetik/gcanvas';
|
|
191
|
+
|
|
192
|
+
const rect = new Rectangle({
|
|
193
|
+
x: 200,
|
|
194
|
+
y: 150,
|
|
195
|
+
width: 100,
|
|
196
|
+
height: 60,
|
|
197
|
+
color: '#4ecdc4',
|
|
198
|
+
stroke: '#2a9d8f',
|
|
199
|
+
lineWidth: 3,
|
|
200
|
+
lineJoin: 'round'
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
rect.draw();
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Complete Property Example
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
const shape = new Circle(50, {
|
|
210
|
+
// Position (Euclidian)
|
|
211
|
+
x: 400,
|
|
212
|
+
y: 300,
|
|
213
|
+
|
|
214
|
+
// Constraints (Geometry2d)
|
|
215
|
+
minX: 50,
|
|
216
|
+
maxX: 750,
|
|
217
|
+
|
|
218
|
+
// Visibility (Renderable)
|
|
219
|
+
visible: true,
|
|
220
|
+
opacity: 0.9,
|
|
221
|
+
shadowColor: 'rgba(0,0,0,0.3)',
|
|
222
|
+
shadowBlur: 10,
|
|
223
|
+
shadowOffsetX: 5,
|
|
224
|
+
shadowOffsetY: 5,
|
|
225
|
+
|
|
226
|
+
// Transforms (Transformable)
|
|
227
|
+
rotation: 0,
|
|
228
|
+
scaleX: 1,
|
|
229
|
+
scaleY: 1,
|
|
230
|
+
|
|
231
|
+
// Styling (Shape)
|
|
232
|
+
color: '#ff6b6b',
|
|
233
|
+
stroke: '#c92a2a',
|
|
234
|
+
lineWidth: 2,
|
|
235
|
+
lineJoin: 'round',
|
|
236
|
+
lineCap: 'round'
|
|
237
|
+
});
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Inheritance
|
|
241
|
+
|
|
242
|
+
```
|
|
243
|
+
Transformable
|
|
244
|
+
└── Shape <── You are here
|
|
245
|
+
├── Circle
|
|
246
|
+
├── Rectangle
|
|
247
|
+
├── Triangle
|
|
248
|
+
├── Star
|
|
249
|
+
├── Polygon
|
|
250
|
+
└── ... (40+ shapes)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Related
|
|
254
|
+
|
|
255
|
+
- [Transformable](./transformable.md) - Parent class
|
|
256
|
+
- [Shape Hierarchy](../hierarchy.md) - Full inheritance diagram
|
|
257
|
+
- [Shapes Module](../README.md) - All available shapes
|
|
258
|
+
|
|
259
|
+
## See Also
|
|
260
|
+
|
|
261
|
+
- [Rendering Pipeline](../../../concepts/rendering-pipeline.md)
|
|
262
|
+
- [Hello World](../../../getting-started/hello-world.md)
|