@guinetik/gcanvas 1.0.0
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/.github/workflows/release.yaml +70 -0
- package/.jshintrc +4 -0
- package/.vscode/settings.json +22 -0
- package/CLAUDE.md +310 -0
- package/blackhole.jpg +0 -0
- package/demo.png +0 -0
- package/demos/CNAME +1 -0
- package/demos/animations.html +31 -0
- package/demos/basic.html +38 -0
- package/demos/baskara.html +31 -0
- package/demos/bezier.html +35 -0
- package/demos/beziersignature.html +29 -0
- package/demos/blackhole.html +28 -0
- package/demos/blob.html +35 -0
- package/demos/demos.css +289 -0
- package/demos/easing.html +28 -0
- package/demos/events.html +195 -0
- package/demos/fluent.html +647 -0
- package/demos/fractals.html +36 -0
- package/demos/genart.html +26 -0
- package/demos/gendream.html +26 -0
- package/demos/group.html +36 -0
- package/demos/home.html +587 -0
- package/demos/index.html +364 -0
- package/demos/isometric.html +34 -0
- package/demos/js/animations.js +452 -0
- package/demos/js/basic.js +204 -0
- package/demos/js/baskara.js +751 -0
- package/demos/js/bezier.js +692 -0
- package/demos/js/beziersignature.js +241 -0
- package/demos/js/blackhole/accretiondisk.obj.js +379 -0
- package/demos/js/blackhole/blackhole.obj.js +318 -0
- package/demos/js/blackhole/index.js +409 -0
- package/demos/js/blackhole/particle.js +56 -0
- package/demos/js/blackhole/starfield.obj.js +218 -0
- package/demos/js/blob.js +2263 -0
- package/demos/js/easing.js +477 -0
- package/demos/js/fluent.js +183 -0
- package/demos/js/fractals.js +931 -0
- package/demos/js/fractalworker.js +93 -0
- package/demos/js/genart.js +268 -0
- package/demos/js/gendream.js +209 -0
- package/demos/js/group.js +140 -0
- package/demos/js/info-toggle.js +25 -0
- package/demos/js/isometric.js +863 -0
- package/demos/js/kerr.js +1556 -0
- package/demos/js/lavalamp.js +590 -0
- package/demos/js/layout.js +354 -0
- package/demos/js/mondrian.js +285 -0
- package/demos/js/opacity.js +275 -0
- package/demos/js/painter.js +484 -0
- package/demos/js/particles-showcase.js +514 -0
- package/demos/js/particles.js +299 -0
- package/demos/js/patterns.js +397 -0
- package/demos/js/penrose/artifact.js +69 -0
- package/demos/js/penrose/blackhole.js +121 -0
- package/demos/js/penrose/constants.js +73 -0
- package/demos/js/penrose/game.js +943 -0
- package/demos/js/penrose/lore.js +278 -0
- package/demos/js/penrose/penrosescene.js +892 -0
- package/demos/js/penrose/ship.js +216 -0
- package/demos/js/penrose/sounds.js +211 -0
- package/demos/js/penrose/voidparticle.js +55 -0
- package/demos/js/penrose/voidscene.js +258 -0
- package/demos/js/penrose/voidship.js +144 -0
- package/demos/js/penrose/wormhole.js +46 -0
- package/demos/js/pipeline.js +555 -0
- package/demos/js/scene.js +304 -0
- package/demos/js/scenes.js +320 -0
- package/demos/js/schrodinger.js +410 -0
- package/demos/js/schwarzschild.js +1023 -0
- package/demos/js/shapes.js +628 -0
- package/demos/js/space/alien.js +171 -0
- package/demos/js/space/boom.js +98 -0
- package/demos/js/space/boss.js +353 -0
- package/demos/js/space/buff.js +73 -0
- package/demos/js/space/bullet.js +102 -0
- package/demos/js/space/constants.js +85 -0
- package/demos/js/space/game.js +1884 -0
- package/demos/js/space/hud.js +112 -0
- package/demos/js/space/laserbeam.js +179 -0
- package/demos/js/space/lightning.js +277 -0
- package/demos/js/space/minion.js +192 -0
- package/demos/js/space/missile.js +212 -0
- package/demos/js/space/player.js +430 -0
- package/demos/js/space/powerup.js +90 -0
- package/demos/js/space/starfield.js +58 -0
- package/demos/js/space/starpower.js +90 -0
- package/demos/js/spacetime.js +559 -0
- package/demos/js/svgtween.js +204 -0
- package/demos/js/tde/accretiondisk.js +418 -0
- package/demos/js/tde/blackhole.js +219 -0
- package/demos/js/tde/blackholescene.js +209 -0
- package/demos/js/tde/config.js +59 -0
- package/demos/js/tde/index.js +695 -0
- package/demos/js/tde/jets.js +290 -0
- package/demos/js/tde/lensedstarfield.js +147 -0
- package/demos/js/tde/tdestar.js +317 -0
- package/demos/js/tde/tidalstream.js +356 -0
- package/demos/js/tde_old/blackhole.obj.js +354 -0
- package/demos/js/tde_old/debris.obj.js +791 -0
- package/demos/js/tde_old/flare.obj.js +239 -0
- package/demos/js/tde_old/index.js +448 -0
- package/demos/js/tde_old/star.obj.js +812 -0
- package/demos/js/tiles.js +312 -0
- package/demos/js/tweendemo.js +79 -0
- package/demos/js/visibility.js +102 -0
- package/demos/kerr.html +28 -0
- package/demos/lavalamp.html +27 -0
- package/demos/layouts.html +37 -0
- package/demos/logo.svg +4 -0
- package/demos/loop.html +84 -0
- package/demos/mondrian.html +32 -0
- package/demos/og_image.png +0 -0
- package/demos/opacity.html +36 -0
- package/demos/painter.html +39 -0
- package/demos/particles-showcase.html +28 -0
- package/demos/particles.html +24 -0
- package/demos/patterns.html +33 -0
- package/demos/penrose-game.html +31 -0
- package/demos/pipeline.html +737 -0
- package/demos/scene.html +33 -0
- package/demos/scenes.html +96 -0
- package/demos/schrodinger.html +27 -0
- package/demos/schwarzschild.html +27 -0
- package/demos/shapes.html +16 -0
- package/demos/space.html +85 -0
- package/demos/spacetime.html +27 -0
- package/demos/svgtween.html +29 -0
- package/demos/tde.html +28 -0
- package/demos/tiles.html +28 -0
- package/demos/transforms.html +400 -0
- package/demos/tween.html +45 -0
- package/demos/visibility.html +33 -0
- package/disk_example.png +0 -0
- package/docs/README.md +222 -0
- package/docs/concepts/architecture-overview.md +204 -0
- package/docs/concepts/lifecycle.md +255 -0
- package/docs/concepts/rendering-pipeline.md +279 -0
- package/docs/concepts/tde-zorder.md +106 -0
- package/docs/concepts/two-layer-architecture.md +229 -0
- package/docs/getting-started/first-game.md +354 -0
- package/docs/getting-started/hello-world.md +269 -0
- package/docs/getting-started/installation.md +157 -0
- package/docs/modules/collision/README.md +453 -0
- package/docs/modules/fluent/README.md +1075 -0
- package/docs/modules/game/README.md +303 -0
- package/docs/modules/isometric-camera.md +210 -0
- package/docs/modules/isometric.md +275 -0
- package/docs/modules/painter/README.md +328 -0
- package/docs/modules/particle/README.md +559 -0
- package/docs/modules/shapes/README.md +221 -0
- package/docs/modules/shapes/base/euclidian.md +123 -0
- package/docs/modules/shapes/base/geometry2d.md +204 -0
- package/docs/modules/shapes/base/renderable.md +215 -0
- package/docs/modules/shapes/base/shape.md +262 -0
- package/docs/modules/shapes/base/transformable.md +243 -0
- package/docs/modules/shapes/hierarchy.md +218 -0
- package/docs/modules/state/README.md +577 -0
- package/docs/modules/util/README.md +99 -0
- package/docs/modules/util/camera3d.md +412 -0
- package/docs/modules/util/scene3d.md +395 -0
- package/index.html +17 -0
- package/jsdoc.json +50 -0
- package/package.json +55 -0
- package/readme.md +599 -0
- package/scripts/build-demo.js +69 -0
- package/scripts/bundle4llm.js +276 -0
- package/scripts/clearconsole.js +48 -0
- package/src/collision/collision-system.js +332 -0
- package/src/collision/collision.js +303 -0
- package/src/collision/index.js +10 -0
- package/src/fluent/fluent-game.js +430 -0
- package/src/fluent/fluent-go.js +1060 -0
- package/src/fluent/fluent-layer.js +152 -0
- package/src/fluent/fluent-scene.js +291 -0
- package/src/fluent/index.js +98 -0
- package/src/fluent/sketch.js +380 -0
- package/src/game/game.js +467 -0
- package/src/game/index.js +49 -0
- package/src/game/objects/go.js +220 -0
- package/src/game/objects/imagego.js +30 -0
- package/src/game/objects/index.js +54 -0
- package/src/game/objects/isometric-scene.js +260 -0
- package/src/game/objects/layoutscene.js +549 -0
- package/src/game/objects/scene.js +175 -0
- package/src/game/objects/scene3d.js +118 -0
- package/src/game/objects/text.js +221 -0
- package/src/game/objects/wrapper.js +232 -0
- package/src/game/pipeline.js +243 -0
- package/src/game/ui/button.js +396 -0
- package/src/game/ui/cursor.js +93 -0
- package/src/game/ui/fps.js +91 -0
- package/src/game/ui/index.js +5 -0
- package/src/game/ui/togglebutton.js +93 -0
- package/src/game/ui/tooltip.js +249 -0
- package/src/index.js +25 -0
- package/src/io/events.js +20 -0
- package/src/io/index.js +86 -0
- package/src/io/input.js +70 -0
- package/src/io/keys.js +152 -0
- package/src/io/mouse.js +61 -0
- package/src/io/touch.js +39 -0
- package/src/logger/debugtab.js +138 -0
- package/src/logger/index.js +3 -0
- package/src/logger/loggable.js +47 -0
- package/src/logger/logger.js +113 -0
- package/src/math/complex.js +37 -0
- package/src/math/constants.js +1 -0
- package/src/math/fractal.js +1271 -0
- package/src/math/gr.js +201 -0
- package/src/math/heat.js +202 -0
- package/src/math/index.js +12 -0
- package/src/math/noise.js +433 -0
- package/src/math/orbital.js +191 -0
- package/src/math/patterns.js +1339 -0
- package/src/math/penrose.js +259 -0
- package/src/math/quantum.js +115 -0
- package/src/math/random.js +195 -0
- package/src/math/tensor.js +1009 -0
- package/src/mixins/anchor.js +131 -0
- package/src/mixins/draggable.js +72 -0
- package/src/mixins/index.js +2 -0
- package/src/motion/bezier.js +132 -0
- package/src/motion/bounce.js +58 -0
- package/src/motion/easing.js +349 -0
- package/src/motion/float.js +130 -0
- package/src/motion/follow.js +125 -0
- package/src/motion/hop.js +52 -0
- package/src/motion/index.js +82 -0
- package/src/motion/motion.js +1124 -0
- package/src/motion/orbit.js +49 -0
- package/src/motion/oscillate.js +39 -0
- package/src/motion/parabolic.js +141 -0
- package/src/motion/patrol.js +147 -0
- package/src/motion/pendulum.js +48 -0
- package/src/motion/pulse.js +88 -0
- package/src/motion/shake.js +83 -0
- package/src/motion/spiral.js +144 -0
- package/src/motion/spring.js +150 -0
- package/src/motion/swing.js +47 -0
- package/src/motion/tween.js +92 -0
- package/src/motion/tweenetik.js +139 -0
- package/src/motion/waypoint.js +210 -0
- package/src/painter/index.js +8 -0
- package/src/painter/painter.colors.js +331 -0
- package/src/painter/painter.effects.js +230 -0
- package/src/painter/painter.img.js +229 -0
- package/src/painter/painter.js +295 -0
- package/src/painter/painter.lines.js +189 -0
- package/src/painter/painter.opacity.js +41 -0
- package/src/painter/painter.shapes.js +277 -0
- package/src/painter/painter.text.js +273 -0
- package/src/particle/emitter.js +124 -0
- package/src/particle/index.js +11 -0
- package/src/particle/particle-system.js +322 -0
- package/src/particle/particle.js +71 -0
- package/src/particle/updaters.js +170 -0
- package/src/shapes/arc.js +43 -0
- package/src/shapes/arrow.js +33 -0
- package/src/shapes/bezier.js +42 -0
- package/src/shapes/circle.js +62 -0
- package/src/shapes/clouds.js +56 -0
- package/src/shapes/cone.js +219 -0
- package/src/shapes/cross.js +70 -0
- package/src/shapes/cube.js +244 -0
- package/src/shapes/cylinder.js +254 -0
- package/src/shapes/diamond.js +48 -0
- package/src/shapes/euclidian.js +111 -0
- package/src/shapes/figure.js +115 -0
- package/src/shapes/geometry.js +220 -0
- package/src/shapes/group.js +375 -0
- package/src/shapes/heart.js +42 -0
- package/src/shapes/hexagon.js +26 -0
- package/src/shapes/image.js +192 -0
- package/src/shapes/index.js +111 -0
- package/src/shapes/line.js +29 -0
- package/src/shapes/pattern.js +90 -0
- package/src/shapes/pin.js +44 -0
- package/src/shapes/poly.js +31 -0
- package/src/shapes/prism.js +226 -0
- package/src/shapes/rect.js +35 -0
- package/src/shapes/renderable.js +333 -0
- package/src/shapes/ring.js +26 -0
- package/src/shapes/roundrect.js +95 -0
- package/src/shapes/shape.js +117 -0
- package/src/shapes/slice.js +26 -0
- package/src/shapes/sphere.js +314 -0
- package/src/shapes/sphere3d.js +537 -0
- package/src/shapes/square.js +15 -0
- package/src/shapes/star.js +99 -0
- package/src/shapes/svg.js +408 -0
- package/src/shapes/text.js +553 -0
- package/src/shapes/traceable.js +83 -0
- package/src/shapes/transform.js +357 -0
- package/src/shapes/transformable.js +172 -0
- package/src/shapes/triangle.js +26 -0
- package/src/sound/index.js +17 -0
- package/src/sound/sound.js +473 -0
- package/src/sound/synth.analyzer.js +149 -0
- package/src/sound/synth.effects.js +207 -0
- package/src/sound/synth.envelope.js +59 -0
- package/src/sound/synth.js +229 -0
- package/src/sound/synth.musical.js +160 -0
- package/src/sound/synth.noise.js +85 -0
- package/src/sound/synth.oscillators.js +293 -0
- package/src/state/index.js +10 -0
- package/src/state/state-machine.js +371 -0
- package/src/util/camera3d.js +438 -0
- package/src/util/index.js +6 -0
- package/src/util/isometric-camera.js +235 -0
- package/src/util/layout.js +317 -0
- package/src/util/position.js +147 -0
- package/src/util/tasks.js +47 -0
- package/src/util/zindex.js +287 -0
- package/src/webgl/index.js +9 -0
- package/src/webgl/shaders/sphere-shaders.js +994 -0
- package/src/webgl/webgl-renderer.js +388 -0
- package/tde.png +0 -0
- package/test/math/orbital.test.js +61 -0
- package/test/math/tensor.test.js +114 -0
- package/test/particle/emitter.test.js +204 -0
- package/test/particle/particle-system.test.js +310 -0
- package/test/particle/particle.test.js +116 -0
- package/test/particle/updaters.test.js +386 -0
- package/test/setup.js +120 -0
- package/test/shapes/euclidian.test.js +44 -0
- package/test/shapes/geometry.test.js +86 -0
- package/test/shapes/group.test.js +86 -0
- package/test/shapes/rectangle.test.js +64 -0
- package/test/shapes/transform.test.js +379 -0
- package/test/util/camera3d.test.js +428 -0
- package/test/util/scene3d.test.js +352 -0
- package/types/collision.d.ts +249 -0
- package/types/common.d.ts +155 -0
- package/types/game.d.ts +497 -0
- package/types/index.d.ts +309 -0
- package/types/io.d.ts +188 -0
- package/types/logger.d.ts +127 -0
- package/types/math.d.ts +268 -0
- package/types/mixins.d.ts +92 -0
- package/types/motion.d.ts +678 -0
- package/types/painter.d.ts +378 -0
- package/types/shapes.d.ts +864 -0
- package/types/sound.d.ts +672 -0
- package/types/state.d.ts +251 -0
- package/types/util.d.ts +253 -0
- package/vite.config.js +50 -0
- package/vitest.config.js +13 -0
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GCanvas Shapes Module
|
|
3
|
+
* Base classes and geometric primitives for 2D rendering.
|
|
4
|
+
* @module shapes
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Bounds, Point } from './common';
|
|
8
|
+
import { Loggable, LoggableOptions } from './logger';
|
|
9
|
+
|
|
10
|
+
// ==========================================================================
|
|
11
|
+
// Base Classes - Spatial Hierarchy
|
|
12
|
+
// ==========================================================================
|
|
13
|
+
|
|
14
|
+
/** Options for Euclidian base class */
|
|
15
|
+
export interface EuclidianOptions extends LoggableOptions {
|
|
16
|
+
/** X position */
|
|
17
|
+
x?: number;
|
|
18
|
+
/** Y position */
|
|
19
|
+
y?: number;
|
|
20
|
+
/** Width */
|
|
21
|
+
width?: number;
|
|
22
|
+
/** Height */
|
|
23
|
+
height?: number;
|
|
24
|
+
/** Enable debug visualization */
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
/** Color for debug bounding box */
|
|
27
|
+
debugColor?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Root class for all drawable objects with spatial properties.
|
|
32
|
+
* Provides x, y, width, height positioning.
|
|
33
|
+
* @abstract
|
|
34
|
+
*/
|
|
35
|
+
export class Euclidian extends Loggable {
|
|
36
|
+
constructor(options?: EuclidianOptions);
|
|
37
|
+
|
|
38
|
+
/** X position */
|
|
39
|
+
get x(): number;
|
|
40
|
+
set x(v: number);
|
|
41
|
+
/** Y position */
|
|
42
|
+
get y(): number;
|
|
43
|
+
set y(v: number);
|
|
44
|
+
/** Width */
|
|
45
|
+
get width(): number;
|
|
46
|
+
set width(v: number);
|
|
47
|
+
/** Height */
|
|
48
|
+
get height(): number;
|
|
49
|
+
set height(v: number);
|
|
50
|
+
/** Debug mode enabled */
|
|
51
|
+
get debug(): boolean;
|
|
52
|
+
set debug(v: boolean);
|
|
53
|
+
/** Debug bounding box color */
|
|
54
|
+
get debugColor(): string;
|
|
55
|
+
set debugColor(v: string);
|
|
56
|
+
|
|
57
|
+
/** @internal Validate a property value */
|
|
58
|
+
protected validateProp(v: any, prop: string): void;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Options for Geometry2d */
|
|
62
|
+
export interface Geometry2dOptions extends EuclidianOptions {
|
|
63
|
+
/** Minimum X constraint */
|
|
64
|
+
minX?: number;
|
|
65
|
+
/** Maximum X constraint */
|
|
66
|
+
maxX?: number;
|
|
67
|
+
/** Minimum Y constraint */
|
|
68
|
+
minY?: number;
|
|
69
|
+
/** Maximum Y constraint */
|
|
70
|
+
maxY?: number;
|
|
71
|
+
/** Enable crisp pixel rendering */
|
|
72
|
+
crisp?: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Spatial object with bounding box calculations and constraints.
|
|
77
|
+
* Extends Euclidian with bounds calculation and movement constraints.
|
|
78
|
+
* @abstract
|
|
79
|
+
*/
|
|
80
|
+
export class Geometry2d extends Euclidian {
|
|
81
|
+
/** Enable crisp pixel rendering (rounds coordinates) */
|
|
82
|
+
crisp: boolean;
|
|
83
|
+
|
|
84
|
+
constructor(options?: Geometry2dOptions);
|
|
85
|
+
|
|
86
|
+
/** Minimum X constraint */
|
|
87
|
+
get minX(): number | undefined;
|
|
88
|
+
set minX(v: number | undefined);
|
|
89
|
+
/** Maximum X constraint */
|
|
90
|
+
get maxX(): number | undefined;
|
|
91
|
+
set maxX(v: number | undefined);
|
|
92
|
+
/** Minimum Y constraint */
|
|
93
|
+
get minY(): number | undefined;
|
|
94
|
+
set minY(v: number | undefined);
|
|
95
|
+
/** Maximum Y constraint */
|
|
96
|
+
get maxY(): number | undefined;
|
|
97
|
+
set maxY(v: number | undefined);
|
|
98
|
+
/** Whether bounds need recalculation */
|
|
99
|
+
get boundsDirty(): boolean;
|
|
100
|
+
|
|
101
|
+
/** Update the object (called each frame) */
|
|
102
|
+
update(dt?: number): void;
|
|
103
|
+
/** Apply position constraints */
|
|
104
|
+
applyConstraints(): void;
|
|
105
|
+
/** Get the bounding box (cached) */
|
|
106
|
+
getBounds(): Bounds;
|
|
107
|
+
/** Calculate the bounding box (override in subclasses) */
|
|
108
|
+
protected calculateBounds(): Bounds;
|
|
109
|
+
/** Get position relative to parent */
|
|
110
|
+
getLocalPosition(): Point;
|
|
111
|
+
/** Mark bounds as needing recalculation */
|
|
112
|
+
markBoundsDirty(): void;
|
|
113
|
+
/** Set position by top-left corner */
|
|
114
|
+
setTopLeft(x: number, y: number): this;
|
|
115
|
+
/** Set position by center point */
|
|
116
|
+
setCenter(x: number, y: number): this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Adds tracing/debugging support to geometry objects.
|
|
121
|
+
* @abstract
|
|
122
|
+
*/
|
|
123
|
+
export class Traceable extends Geometry2d {
|
|
124
|
+
constructor(options?: Geometry2dOptions);
|
|
125
|
+
|
|
126
|
+
/** Draw debug visualization */
|
|
127
|
+
drawDebug(): void;
|
|
128
|
+
/** Get bounds for debug drawing */
|
|
129
|
+
getDebugBounds(): Bounds;
|
|
130
|
+
/** Log a trace message */
|
|
131
|
+
trace(msg?: string): void;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ==========================================================================
|
|
135
|
+
// Renderable - Visibility & Effects
|
|
136
|
+
// ==========================================================================
|
|
137
|
+
|
|
138
|
+
/** Options for Renderable */
|
|
139
|
+
export interface RenderableOptions extends Geometry2dOptions {
|
|
140
|
+
/** Whether object is visible */
|
|
141
|
+
visible?: boolean;
|
|
142
|
+
/** Opacity (0-1) */
|
|
143
|
+
opacity?: number;
|
|
144
|
+
/** Whether object is active */
|
|
145
|
+
active?: boolean;
|
|
146
|
+
/** Canvas blend mode */
|
|
147
|
+
blendMode?: GlobalCompositeOperation;
|
|
148
|
+
/** Shadow color */
|
|
149
|
+
shadowColor?: string;
|
|
150
|
+
/** Shadow blur radius */
|
|
151
|
+
shadowBlur?: number;
|
|
152
|
+
/** Shadow X offset */
|
|
153
|
+
shadowOffsetX?: number;
|
|
154
|
+
/** Shadow Y offset */
|
|
155
|
+
shadowOffsetY?: number;
|
|
156
|
+
/** Z-index for rendering order */
|
|
157
|
+
zIndex?: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Render-capable object with visibility, opacity, blend mode, and shadow support.
|
|
162
|
+
* @abstract
|
|
163
|
+
*/
|
|
164
|
+
export class Renderable extends Traceable {
|
|
165
|
+
/** Z-index for rendering order */
|
|
166
|
+
zIndex: number;
|
|
167
|
+
|
|
168
|
+
constructor(options?: RenderableOptions);
|
|
169
|
+
|
|
170
|
+
/** Whether object is visible */
|
|
171
|
+
get visible(): boolean;
|
|
172
|
+
set visible(v: boolean);
|
|
173
|
+
/** Whether object is active (receives updates) */
|
|
174
|
+
get active(): boolean;
|
|
175
|
+
set active(v: boolean);
|
|
176
|
+
/** Opacity (0-1) */
|
|
177
|
+
get opacity(): number;
|
|
178
|
+
set opacity(v: number);
|
|
179
|
+
/** Canvas blend mode */
|
|
180
|
+
get blendMode(): GlobalCompositeOperation;
|
|
181
|
+
set blendMode(v: GlobalCompositeOperation);
|
|
182
|
+
/** Shadow color */
|
|
183
|
+
get shadowColor(): string | undefined;
|
|
184
|
+
set shadowColor(v: string | undefined);
|
|
185
|
+
/** Shadow blur radius */
|
|
186
|
+
get shadowBlur(): number;
|
|
187
|
+
set shadowBlur(v: number);
|
|
188
|
+
/** Shadow X offset */
|
|
189
|
+
get shadowOffsetX(): number;
|
|
190
|
+
set shadowOffsetX(v: number);
|
|
191
|
+
/** Shadow Y offset */
|
|
192
|
+
get shadowOffsetY(): number;
|
|
193
|
+
set shadowOffsetY(v: number);
|
|
194
|
+
/** Current frame tick count */
|
|
195
|
+
get tick(): number;
|
|
196
|
+
|
|
197
|
+
/** Render the object (handles transforms and calls draw) */
|
|
198
|
+
render(): void;
|
|
199
|
+
/** Draw the object (override in subclasses) */
|
|
200
|
+
draw(): void;
|
|
201
|
+
/** Update the object */
|
|
202
|
+
update(dt: number): void;
|
|
203
|
+
/** Apply shadow settings to context */
|
|
204
|
+
applyShadow(ctx: CanvasRenderingContext2D): void;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ==========================================================================
|
|
208
|
+
// Transformable - Rotation & Scale
|
|
209
|
+
// ==========================================================================
|
|
210
|
+
|
|
211
|
+
/** Options for Transformable */
|
|
212
|
+
export interface TransformableOptions extends RenderableOptions {
|
|
213
|
+
/** Rotation in degrees */
|
|
214
|
+
rotation?: number;
|
|
215
|
+
/** X scale factor */
|
|
216
|
+
scaleX?: number;
|
|
217
|
+
/** Y scale factor */
|
|
218
|
+
scaleY?: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Renderable object with canvas transformation support (rotation, scale).
|
|
223
|
+
* @abstract
|
|
224
|
+
*/
|
|
225
|
+
export class Transformable extends Renderable {
|
|
226
|
+
/** Fluent transform API */
|
|
227
|
+
transform: Transform;
|
|
228
|
+
/** Reference to parent container (if any) */
|
|
229
|
+
parent: Transformable | null;
|
|
230
|
+
|
|
231
|
+
constructor(options?: TransformableOptions);
|
|
232
|
+
|
|
233
|
+
/** Rotation in degrees */
|
|
234
|
+
get rotation(): number;
|
|
235
|
+
set rotation(v: number);
|
|
236
|
+
/** X scale factor */
|
|
237
|
+
get scaleX(): number;
|
|
238
|
+
set scaleX(v: number);
|
|
239
|
+
/** Y scale factor */
|
|
240
|
+
get scaleY(): number;
|
|
241
|
+
set scaleY(v: number);
|
|
242
|
+
|
|
243
|
+
/** Draw with transforms applied */
|
|
244
|
+
draw(): void;
|
|
245
|
+
/** Apply canvas transforms */
|
|
246
|
+
applyTransforms(): void;
|
|
247
|
+
/** Calculate bounds with transforms */
|
|
248
|
+
calculateBounds(): Bounds;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// ==========================================================================
|
|
252
|
+
// Transform - Fluent API
|
|
253
|
+
// ==========================================================================
|
|
254
|
+
|
|
255
|
+
/** Transform properties for batch operations */
|
|
256
|
+
export interface TransformProps {
|
|
257
|
+
x?: number;
|
|
258
|
+
y?: number;
|
|
259
|
+
width?: number;
|
|
260
|
+
height?: number;
|
|
261
|
+
rotation?: number;
|
|
262
|
+
scaleX?: number;
|
|
263
|
+
scaleY?: number;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Fluent API for modifying spatial and transform properties.
|
|
268
|
+
* Allows chaining transform operations.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* shape.transform
|
|
272
|
+
* .position(100, 100)
|
|
273
|
+
* .rotation(45)
|
|
274
|
+
* .scale(2);
|
|
275
|
+
*/
|
|
276
|
+
export class Transform {
|
|
277
|
+
/** Enable strict mode warnings for direct property assignment */
|
|
278
|
+
static strictMode: boolean;
|
|
279
|
+
|
|
280
|
+
constructor(owner: Transformable);
|
|
281
|
+
|
|
282
|
+
/** Get the owner of this transform */
|
|
283
|
+
get owner(): Transformable;
|
|
284
|
+
|
|
285
|
+
// Position methods
|
|
286
|
+
/** Set X position */
|
|
287
|
+
x(value: number): this;
|
|
288
|
+
/** Set Y position */
|
|
289
|
+
y(value: number): this;
|
|
290
|
+
/** Set X and Y position */
|
|
291
|
+
position(x: number, y: number): this;
|
|
292
|
+
/** Translate by delta values */
|
|
293
|
+
translateBy(dx: number, dy: number): this;
|
|
294
|
+
|
|
295
|
+
// Dimension methods
|
|
296
|
+
/** Set width */
|
|
297
|
+
width(value: number): this;
|
|
298
|
+
/** Set height */
|
|
299
|
+
height(value: number): this;
|
|
300
|
+
/** Set width and height */
|
|
301
|
+
size(width: number, height: number): this;
|
|
302
|
+
|
|
303
|
+
// Rotation methods
|
|
304
|
+
/** Set rotation in degrees */
|
|
305
|
+
rotation(degrees: number): this;
|
|
306
|
+
/** Set rotation in radians */
|
|
307
|
+
rotationRad(radians: number): this;
|
|
308
|
+
/** Add to current rotation */
|
|
309
|
+
rotateBy(degrees: number): this;
|
|
310
|
+
|
|
311
|
+
// Scale methods
|
|
312
|
+
/** Set X scale */
|
|
313
|
+
scaleX(value: number): this;
|
|
314
|
+
/** Set Y scale */
|
|
315
|
+
scaleY(value: number): this;
|
|
316
|
+
/** Set uniform scale (X and Y) */
|
|
317
|
+
scale(value: number): this;
|
|
318
|
+
/** Multiply current scale */
|
|
319
|
+
scaleBy(factor: number): this;
|
|
320
|
+
|
|
321
|
+
// Batch operations
|
|
322
|
+
/** Set multiple properties at once */
|
|
323
|
+
set(props: TransformProps): this;
|
|
324
|
+
/** Reset scale and rotation to defaults */
|
|
325
|
+
reset(): this;
|
|
326
|
+
/** Reset all transform properties including position */
|
|
327
|
+
resetAll(): this;
|
|
328
|
+
|
|
329
|
+
// Utility methods
|
|
330
|
+
/** Get current transform state as object */
|
|
331
|
+
toObject(): Required<TransformProps>;
|
|
332
|
+
/** Copy transform values from another source */
|
|
333
|
+
copyFrom(source: Transform | TransformProps): this;
|
|
334
|
+
|
|
335
|
+
/** @internal Handle direct property set warnings */
|
|
336
|
+
static handleDirectSet(property: string, value: any): void;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// ==========================================================================
|
|
340
|
+
// Shape - Styled Geometry Base
|
|
341
|
+
// ==========================================================================
|
|
342
|
+
|
|
343
|
+
/** Options for Shape */
|
|
344
|
+
export interface ShapeOptions extends TransformableOptions {
|
|
345
|
+
/** Fill color (null for no fill) */
|
|
346
|
+
color?: string | null;
|
|
347
|
+
/** Stroke color (null for no stroke) */
|
|
348
|
+
stroke?: string | null;
|
|
349
|
+
/** Stroke line width */
|
|
350
|
+
lineWidth?: number;
|
|
351
|
+
/** Line join style */
|
|
352
|
+
lineJoin?: 'miter' | 'round' | 'bevel';
|
|
353
|
+
/** Line cap style */
|
|
354
|
+
lineCap?: 'butt' | 'round' | 'square';
|
|
355
|
+
/** Miter limit for sharp corners */
|
|
356
|
+
miterLimit?: number;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Base class for drawable geometric primitives.
|
|
361
|
+
* Adds fill, stroke, and line styling to Transformable.
|
|
362
|
+
* @abstract
|
|
363
|
+
*/
|
|
364
|
+
export class Shape extends Transformable {
|
|
365
|
+
constructor(options?: ShapeOptions);
|
|
366
|
+
|
|
367
|
+
/** Fill color */
|
|
368
|
+
get color(): string | null;
|
|
369
|
+
set color(v: string | null);
|
|
370
|
+
/** Stroke color */
|
|
371
|
+
get stroke(): string | null;
|
|
372
|
+
set stroke(v: string | null);
|
|
373
|
+
/** Stroke line width */
|
|
374
|
+
get lineWidth(): number;
|
|
375
|
+
set lineWidth(v: number);
|
|
376
|
+
/** Line join style */
|
|
377
|
+
get lineJoin(): 'miter' | 'round' | 'bevel';
|
|
378
|
+
set lineJoin(v: 'miter' | 'round' | 'bevel');
|
|
379
|
+
/** Line cap style */
|
|
380
|
+
get lineCap(): 'butt' | 'round' | 'square';
|
|
381
|
+
set lineCap(v: 'butt' | 'round' | 'square');
|
|
382
|
+
/** Miter limit */
|
|
383
|
+
get miterLimit(): number;
|
|
384
|
+
set miterLimit(v: number);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// ==========================================================================
|
|
388
|
+
// Group - Container
|
|
389
|
+
// ==========================================================================
|
|
390
|
+
|
|
391
|
+
/** Options for Group */
|
|
392
|
+
export interface GroupOptions extends TransformableOptions {
|
|
393
|
+
/** Children inherit parent opacity */
|
|
394
|
+
inheritOpacity?: boolean;
|
|
395
|
+
/** Children inherit parent visibility */
|
|
396
|
+
inheritVisible?: boolean;
|
|
397
|
+
/** Children inherit parent scale */
|
|
398
|
+
inheritScale?: boolean;
|
|
399
|
+
/** Sort children by zIndex before rendering */
|
|
400
|
+
sortByZIndex?: boolean;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Container for composing multiple transformable objects.
|
|
405
|
+
* Children are transformed relative to the group's position.
|
|
406
|
+
*/
|
|
407
|
+
export class Group extends Transformable {
|
|
408
|
+
/** Whether dimensions were explicitly set */
|
|
409
|
+
userDefinedDimensions: boolean;
|
|
410
|
+
|
|
411
|
+
constructor(options?: GroupOptions);
|
|
412
|
+
|
|
413
|
+
/** Get all children */
|
|
414
|
+
get children(): Transformable[];
|
|
415
|
+
|
|
416
|
+
/** Add a child object */
|
|
417
|
+
add(object: Transformable): Transformable;
|
|
418
|
+
/** Remove a child object */
|
|
419
|
+
remove(object: Transformable): boolean;
|
|
420
|
+
/** Remove all children */
|
|
421
|
+
clear(): void;
|
|
422
|
+
/** Move object to front (highest z-order) */
|
|
423
|
+
bringToFront(object: Transformable): void;
|
|
424
|
+
/** Move object to back (lowest z-order) */
|
|
425
|
+
sendToBack(object: Transformable): void;
|
|
426
|
+
/** Move object forward one z-level */
|
|
427
|
+
bringForward(object: Transformable): void;
|
|
428
|
+
/** Move object backward one z-level */
|
|
429
|
+
sendBackward(object: Transformable): void;
|
|
430
|
+
|
|
431
|
+
draw(): void;
|
|
432
|
+
update(dt: number): void;
|
|
433
|
+
calculateBounds(): Bounds;
|
|
434
|
+
getDebugBounds(): Bounds;
|
|
435
|
+
|
|
436
|
+
// Group-wide transform operations
|
|
437
|
+
/** Execute callback for each child's transform */
|
|
438
|
+
forEachTransform(callback: (transform: Transform, child: Transformable, index: number) => void): this;
|
|
439
|
+
/** Translate all children by delta */
|
|
440
|
+
translateChildren(dx: number, dy: number): this;
|
|
441
|
+
/** Scale all children by factor */
|
|
442
|
+
scaleChildren(factor: number): this;
|
|
443
|
+
/** Rotate all children by degrees */
|
|
444
|
+
rotateChildren(degrees: number): this;
|
|
445
|
+
/** Reset all children's transforms */
|
|
446
|
+
resetChildTransforms(): this;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// ==========================================================================
|
|
450
|
+
// Concrete Shape Classes
|
|
451
|
+
// ==========================================================================
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Circle shape.
|
|
455
|
+
*/
|
|
456
|
+
export class Circle extends Shape {
|
|
457
|
+
/**
|
|
458
|
+
* @param radius - Circle radius
|
|
459
|
+
* @param options - Shape options
|
|
460
|
+
*/
|
|
461
|
+
constructor(radius: number, options?: ShapeOptions);
|
|
462
|
+
|
|
463
|
+
/** Circle radius */
|
|
464
|
+
get radius(): number;
|
|
465
|
+
set radius(v: number);
|
|
466
|
+
|
|
467
|
+
draw(): void;
|
|
468
|
+
calculateBounds(): Bounds;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Rectangle shape.
|
|
473
|
+
*/
|
|
474
|
+
export class Rectangle extends Shape {
|
|
475
|
+
constructor(options?: ShapeOptions);
|
|
476
|
+
|
|
477
|
+
draw(): void;
|
|
478
|
+
/** @internal */
|
|
479
|
+
protected drawRect(): void;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** Options for RoundedRectangle */
|
|
483
|
+
export interface RoundedRectangleOptions extends ShapeOptions {
|
|
484
|
+
/** Corner radius */
|
|
485
|
+
cornerRadius?: number;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Rectangle with rounded corners.
|
|
490
|
+
*/
|
|
491
|
+
export class RoundedRectangle extends Shape {
|
|
492
|
+
constructor(options?: RoundedRectangleOptions);
|
|
493
|
+
|
|
494
|
+
/** Corner radius */
|
|
495
|
+
get cornerRadius(): number;
|
|
496
|
+
set cornerRadius(v: number);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Square shape (Rectangle with equal width/height).
|
|
501
|
+
*/
|
|
502
|
+
export class Square extends Rectangle {
|
|
503
|
+
/**
|
|
504
|
+
* @param size - Side length
|
|
505
|
+
* @param options - Shape options
|
|
506
|
+
*/
|
|
507
|
+
constructor(size: number, options?: ShapeOptions);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/** Options for Arc */
|
|
511
|
+
export interface ArcOptions extends ShapeOptions {
|
|
512
|
+
/** Start angle in radians */
|
|
513
|
+
startAngle?: number;
|
|
514
|
+
/** End angle in radians */
|
|
515
|
+
endAngle?: number;
|
|
516
|
+
/** Draw counter-clockwise */
|
|
517
|
+
counterClockwise?: boolean;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Arc shape (partial circle).
|
|
522
|
+
*/
|
|
523
|
+
export class Arc extends Shape {
|
|
524
|
+
/**
|
|
525
|
+
* @param radius - Arc radius
|
|
526
|
+
* @param options - Arc options
|
|
527
|
+
*/
|
|
528
|
+
constructor(radius: number, options?: ArcOptions);
|
|
529
|
+
|
|
530
|
+
/** Arc radius */
|
|
531
|
+
get radius(): number;
|
|
532
|
+
set radius(v: number);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Line segment.
|
|
537
|
+
*/
|
|
538
|
+
export class Line extends Shape {
|
|
539
|
+
/**
|
|
540
|
+
* @param x1 - Start X
|
|
541
|
+
* @param y1 - Start Y
|
|
542
|
+
* @param x2 - End X
|
|
543
|
+
* @param y2 - End Y
|
|
544
|
+
* @param options - Shape options
|
|
545
|
+
*/
|
|
546
|
+
constructor(x1: number, y1: number, x2: number, y2: number, options?: ShapeOptions);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Triangle shape.
|
|
551
|
+
*/
|
|
552
|
+
export class Triangle extends Shape {
|
|
553
|
+
constructor(options?: ShapeOptions);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/** Options for Star */
|
|
557
|
+
export interface StarOptions extends ShapeOptions {
|
|
558
|
+
/** Number of points */
|
|
559
|
+
points?: number;
|
|
560
|
+
/** Inner radius */
|
|
561
|
+
innerRadius?: number;
|
|
562
|
+
/** Outer radius */
|
|
563
|
+
outerRadius?: number;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Star shape with configurable points.
|
|
568
|
+
*/
|
|
569
|
+
export class Star extends Shape {
|
|
570
|
+
constructor(options?: StarOptions);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Regular polygon with N sides.
|
|
575
|
+
*/
|
|
576
|
+
export class Polygon extends Shape {
|
|
577
|
+
/**
|
|
578
|
+
* @param sides - Number of sides
|
|
579
|
+
* @param radius - Circumscribed circle radius
|
|
580
|
+
* @param options - Shape options
|
|
581
|
+
*/
|
|
582
|
+
constructor(sides: number, radius: number, options?: ShapeOptions);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Regular hexagon (6-sided polygon).
|
|
587
|
+
*/
|
|
588
|
+
export class Hexagon extends Polygon {
|
|
589
|
+
/**
|
|
590
|
+
* @param radius - Circumscribed circle radius
|
|
591
|
+
* @param options - Shape options
|
|
592
|
+
*/
|
|
593
|
+
constructor(radius: number, options?: ShapeOptions);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Diamond/rhombus shape.
|
|
598
|
+
*/
|
|
599
|
+
export class Diamond extends Shape {
|
|
600
|
+
constructor(options?: ShapeOptions);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Cross/plus shape.
|
|
605
|
+
*/
|
|
606
|
+
export class Cross extends Shape {
|
|
607
|
+
constructor(options?: ShapeOptions);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Heart shape.
|
|
612
|
+
*/
|
|
613
|
+
export class Heart extends Shape {
|
|
614
|
+
constructor(options?: ShapeOptions);
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** Options for Ring */
|
|
618
|
+
export interface RingOptions extends ShapeOptions {
|
|
619
|
+
/** Inner radius */
|
|
620
|
+
innerRadius?: number;
|
|
621
|
+
/** Outer radius */
|
|
622
|
+
outerRadius?: number;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Ring/donut shape.
|
|
627
|
+
*/
|
|
628
|
+
export class Ring extends Shape {
|
|
629
|
+
constructor(options?: RingOptions);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Cloud shape.
|
|
634
|
+
*/
|
|
635
|
+
export class Cloud extends Shape {
|
|
636
|
+
constructor(options?: ShapeOptions);
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Pin/marker shape.
|
|
641
|
+
*/
|
|
642
|
+
export class Pin extends Shape {
|
|
643
|
+
constructor(options?: ShapeOptions);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Arrow shape.
|
|
648
|
+
*/
|
|
649
|
+
export class Arrow extends Shape {
|
|
650
|
+
constructor(options?: ShapeOptions);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/** Options for PieSlice */
|
|
654
|
+
export interface PieSliceOptions extends ShapeOptions {
|
|
655
|
+
/** Start angle in radians */
|
|
656
|
+
startAngle?: number;
|
|
657
|
+
/** End angle in radians */
|
|
658
|
+
endAngle?: number;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Pie slice/wedge shape.
|
|
663
|
+
*/
|
|
664
|
+
export class PieSlice extends Shape {
|
|
665
|
+
/**
|
|
666
|
+
* @param radius - Slice radius
|
|
667
|
+
* @param options - Pie slice options
|
|
668
|
+
*/
|
|
669
|
+
constructor(radius: number, options?: PieSliceOptions);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Bezier curve shape.
|
|
674
|
+
*/
|
|
675
|
+
export class BezierShape extends Shape {
|
|
676
|
+
/**
|
|
677
|
+
* @param points - Control points [P0, P1, P2, P3]
|
|
678
|
+
* @param options - Shape options
|
|
679
|
+
*/
|
|
680
|
+
constructor(points: Point[], options?: ShapeOptions);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* SVG path shape.
|
|
685
|
+
*/
|
|
686
|
+
export class SVGShape extends Shape {
|
|
687
|
+
/**
|
|
688
|
+
* @param svgPath - SVG path string (d attribute)
|
|
689
|
+
* @param options - Shape options
|
|
690
|
+
*/
|
|
691
|
+
constructor(svgPath: string, options?: ShapeOptions);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Stick figure shape.
|
|
696
|
+
*/
|
|
697
|
+
export class StickFigure extends Shape {
|
|
698
|
+
constructor(options?: ShapeOptions);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/** Options for PatternRectangle */
|
|
702
|
+
export interface PatternRectangleOptions extends ShapeOptions {
|
|
703
|
+
/** Canvas pattern or pattern name */
|
|
704
|
+
pattern?: CanvasPattern | string;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Rectangle filled with a pattern.
|
|
709
|
+
*/
|
|
710
|
+
export class PatternRectangle extends Rectangle {
|
|
711
|
+
constructor(options?: PatternRectangleOptions);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** Options for ImageShape */
|
|
715
|
+
export interface ImageShapeOptions extends ShapeOptions {
|
|
716
|
+
/** Image source URL */
|
|
717
|
+
src?: string;
|
|
718
|
+
/** Image element */
|
|
719
|
+
image?: HTMLImageElement;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Image shape.
|
|
724
|
+
*/
|
|
725
|
+
export class ImageShape extends Shape {
|
|
726
|
+
constructor(options?: ImageShapeOptions);
|
|
727
|
+
|
|
728
|
+
/** The image element */
|
|
729
|
+
get image(): HTMLImageElement | null;
|
|
730
|
+
set image(v: HTMLImageElement | null);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// ==========================================================================
|
|
734
|
+
// 2.5D / Isometric Shapes
|
|
735
|
+
// ==========================================================================
|
|
736
|
+
|
|
737
|
+
/** Options for Cube */
|
|
738
|
+
export interface CubeOptions extends ShapeOptions {
|
|
739
|
+
/** Top face color */
|
|
740
|
+
faceTopColor?: string;
|
|
741
|
+
/** Left face color */
|
|
742
|
+
faceLeftColor?: string;
|
|
743
|
+
/** Right face color */
|
|
744
|
+
faceRightColor?: string;
|
|
745
|
+
/** X rotation for perspective */
|
|
746
|
+
rotationX?: number;
|
|
747
|
+
/** Y rotation for perspective */
|
|
748
|
+
rotationY?: number;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Isometric cube shape.
|
|
753
|
+
*/
|
|
754
|
+
export class Cube extends Shape {
|
|
755
|
+
/**
|
|
756
|
+
* @param size - Cube size
|
|
757
|
+
* @param options - Cube options
|
|
758
|
+
*/
|
|
759
|
+
constructor(size: number, options?: CubeOptions);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Isometric cylinder shape.
|
|
764
|
+
*/
|
|
765
|
+
export class Cylinder extends Shape {
|
|
766
|
+
/**
|
|
767
|
+
* @param radius - Cylinder radius
|
|
768
|
+
* @param height - Cylinder height
|
|
769
|
+
* @param options - Shape options
|
|
770
|
+
*/
|
|
771
|
+
constructor(radius: number, height: number, options?: ShapeOptions);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Isometric cone shape.
|
|
776
|
+
*/
|
|
777
|
+
export class Cone extends Shape {
|
|
778
|
+
/**
|
|
779
|
+
* @param radius - Base radius
|
|
780
|
+
* @param height - Cone height
|
|
781
|
+
* @param options - Shape options
|
|
782
|
+
*/
|
|
783
|
+
constructor(radius: number, height: number, options?: ShapeOptions);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Isometric prism shape.
|
|
788
|
+
*/
|
|
789
|
+
export class Prism extends Shape {
|
|
790
|
+
constructor(options?: ShapeOptions);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Isometric sphere shape.
|
|
795
|
+
*/
|
|
796
|
+
export class Sphere extends Shape {
|
|
797
|
+
/**
|
|
798
|
+
* @param radius - Sphere radius
|
|
799
|
+
* @param options - Shape options
|
|
800
|
+
*/
|
|
801
|
+
constructor(radius: number, options?: ShapeOptions);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
// ==========================================================================
|
|
805
|
+
// Text Shapes
|
|
806
|
+
// ==========================================================================
|
|
807
|
+
|
|
808
|
+
/** Options for TextShape */
|
|
809
|
+
export interface TextShapeOptions extends ShapeOptions {
|
|
810
|
+
/** CSS font string */
|
|
811
|
+
font?: string;
|
|
812
|
+
/** Text alignment */
|
|
813
|
+
align?: CanvasTextAlign;
|
|
814
|
+
/** Text baseline */
|
|
815
|
+
baseline?: CanvasTextBaseline;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Basic text shape.
|
|
820
|
+
*/
|
|
821
|
+
export class TextShape extends Shape {
|
|
822
|
+
/** The text content */
|
|
823
|
+
text: string;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* @param text - Text to display
|
|
827
|
+
* @param options - Text options
|
|
828
|
+
*/
|
|
829
|
+
constructor(text: string, options?: TextShapeOptions);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/** Options for OutlinedText */
|
|
833
|
+
export interface OutlinedTextOptions extends TextShapeOptions {
|
|
834
|
+
/** Outline color */
|
|
835
|
+
outlineColor?: string;
|
|
836
|
+
/** Outline width */
|
|
837
|
+
outlineWidth?: number;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* Text with outline/stroke effect.
|
|
842
|
+
*/
|
|
843
|
+
export class OutlinedText extends TextShape {
|
|
844
|
+
/**
|
|
845
|
+
* @param text - Text to display
|
|
846
|
+
* @param options - Outlined text options
|
|
847
|
+
*/
|
|
848
|
+
constructor(text: string, options?: OutlinedTextOptions);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Text with automatic word wrapping.
|
|
853
|
+
*/
|
|
854
|
+
export class WrappedText extends TextShape {
|
|
855
|
+
/**
|
|
856
|
+
* @param x - X position
|
|
857
|
+
* @param y - Y position
|
|
858
|
+
* @param text - Text to display
|
|
859
|
+
* @param maxWidth - Maximum line width
|
|
860
|
+
* @param lineHeight - Line height
|
|
861
|
+
* @param options - Text options
|
|
862
|
+
*/
|
|
863
|
+
constructor(x: number, y: number, text: string, maxWidth: number, lineHeight: number, options?: TextShapeOptions);
|
|
864
|
+
}
|