like2d 2.8.0 → 2.10.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.
Files changed (122) hide show
  1. package/README.md +44 -41
  2. package/dist/__benchmarks__/vector2.bench.d.ts +2 -0
  3. package/dist/__benchmarks__/vector2.bench.d.ts.map +1 -0
  4. package/dist/__benchmarks__/vector2.bench.js +74 -0
  5. package/dist/{core → audio}/audio.d.ts +21 -9
  6. package/dist/audio/audio.d.ts.map +1 -0
  7. package/dist/{core → audio}/audio.js +15 -4
  8. package/dist/audio/index.d.ts +2 -0
  9. package/dist/audio/index.d.ts.map +1 -0
  10. package/dist/engine.d.ts +30 -15
  11. package/dist/engine.d.ts.map +1 -1
  12. package/dist/engine.js +79 -160
  13. package/dist/events.d.ts +86 -0
  14. package/dist/events.d.ts.map +1 -0
  15. package/dist/events.js +5 -0
  16. package/dist/gamecontrollerdb.txt +9 -8
  17. package/dist/graphics/canvas.d.ts +65 -0
  18. package/dist/graphics/canvas.d.ts.map +1 -0
  19. package/dist/graphics/canvas.js +224 -0
  20. package/dist/graphics/drawing.d.ts +203 -0
  21. package/dist/graphics/drawing.d.ts.map +1 -0
  22. package/dist/graphics/drawing.js +388 -0
  23. package/dist/graphics/index.d.ts +19 -0
  24. package/dist/graphics/index.d.ts.map +1 -0
  25. package/dist/graphics/index.js +13 -0
  26. package/dist/index.d.ts +18 -24
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +15 -15
  29. package/dist/input/gamepad-mapping.d.ts +134 -0
  30. package/dist/input/gamepad-mapping.d.ts.map +1 -0
  31. package/dist/input/gamepad-mapping.js +146 -0
  32. package/dist/input/gamepad.d.ts +74 -0
  33. package/dist/input/gamepad.d.ts.map +1 -0
  34. package/dist/input/gamepad.js +288 -0
  35. package/dist/input/index.d.ts +6 -0
  36. package/dist/input/index.d.ts.map +1 -0
  37. package/dist/input/index.js +1 -0
  38. package/dist/input/input.d.ts +76 -0
  39. package/dist/input/input.d.ts.map +1 -0
  40. package/dist/input/input.js +164 -0
  41. package/dist/input/keyboard.d.ts +15 -0
  42. package/dist/input/keyboard.d.ts.map +1 -0
  43. package/dist/input/keyboard.js +53 -0
  44. package/dist/input/mouse.d.ts +108 -0
  45. package/dist/input/mouse.d.ts.map +1 -0
  46. package/dist/input/mouse.js +241 -0
  47. package/dist/like.d.ts +80 -0
  48. package/dist/like.d.ts.map +1 -0
  49. package/dist/like.js +5 -0
  50. package/dist/math/index.d.ts +18 -0
  51. package/dist/math/index.d.ts.map +1 -0
  52. package/dist/math/index.js +17 -0
  53. package/dist/math/rect.d.ts +68 -0
  54. package/dist/math/rect.d.ts.map +1 -0
  55. package/dist/{core → math}/rect.js +48 -66
  56. package/dist/math/vector2.d.ts +133 -0
  57. package/dist/math/vector2.d.ts.map +1 -0
  58. package/dist/math/vector2.js +111 -0
  59. package/dist/prefab-scenes/index.d.ts +8 -0
  60. package/dist/prefab-scenes/index.d.ts.map +1 -0
  61. package/dist/prefab-scenes/index.js +7 -0
  62. package/dist/prefab-scenes/mapGamepad.d.ts +28 -0
  63. package/dist/prefab-scenes/mapGamepad.d.ts.map +1 -0
  64. package/dist/prefab-scenes/mapGamepad.js +181 -0
  65. package/dist/prefab-scenes/startScreen.d.ts +59 -0
  66. package/dist/prefab-scenes/startScreen.d.ts.map +1 -0
  67. package/dist/{scenes/startup.js → prefab-scenes/startScreen.js} +48 -8
  68. package/dist/scene.d.ts +104 -6
  69. package/dist/scene.d.ts.map +1 -1
  70. package/dist/scene.js +28 -1
  71. package/dist/timer/index.d.ts +2 -0
  72. package/dist/timer/index.d.ts.map +1 -0
  73. package/dist/timer/timer.d.ts +32 -0
  74. package/dist/timer/timer.d.ts.map +1 -0
  75. package/dist/{core → timer}/timer.js +19 -14
  76. package/package.json +27 -2
  77. package/dist/core/audio.d.ts.map +0 -1
  78. package/dist/core/canvas-config.d.ts +0 -22
  79. package/dist/core/canvas-config.d.ts.map +0 -1
  80. package/dist/core/canvas-config.js +0 -14
  81. package/dist/core/canvas-manager.d.ts +0 -32
  82. package/dist/core/canvas-manager.d.ts.map +0 -1
  83. package/dist/core/canvas-manager.js +0 -179
  84. package/dist/core/events.d.ts +0 -31
  85. package/dist/core/events.d.ts.map +0 -1
  86. package/dist/core/gamepad-buttons.d.ts +0 -23
  87. package/dist/core/gamepad-buttons.d.ts.map +0 -1
  88. package/dist/core/gamepad-buttons.js +0 -36
  89. package/dist/core/gamepad-mapping.d.ts +0 -19
  90. package/dist/core/gamepad-mapping.d.ts.map +0 -1
  91. package/dist/core/gamepad-mapping.js +0 -223
  92. package/dist/core/gamepad.d.ts +0 -61
  93. package/dist/core/gamepad.d.ts.map +0 -1
  94. package/dist/core/gamepad.js +0 -237
  95. package/dist/core/graphics.d.ts +0 -93
  96. package/dist/core/graphics.d.ts.map +0 -1
  97. package/dist/core/graphics.js +0 -289
  98. package/dist/core/input-state.d.ts +0 -14
  99. package/dist/core/input-state.d.ts.map +0 -1
  100. package/dist/core/input-state.js +0 -50
  101. package/dist/core/input.d.ts +0 -33
  102. package/dist/core/input.d.ts.map +0 -1
  103. package/dist/core/input.js +0 -117
  104. package/dist/core/keyboard.d.ts +0 -16
  105. package/dist/core/keyboard.d.ts.map +0 -1
  106. package/dist/core/keyboard.js +0 -83
  107. package/dist/core/like.d.ts +0 -59
  108. package/dist/core/like.d.ts.map +0 -1
  109. package/dist/core/mouse.d.ts +0 -45
  110. package/dist/core/mouse.d.ts.map +0 -1
  111. package/dist/core/mouse.js +0 -182
  112. package/dist/core/rect.d.ts +0 -26
  113. package/dist/core/rect.d.ts.map +0 -1
  114. package/dist/core/timer.d.ts +0 -18
  115. package/dist/core/timer.d.ts.map +0 -1
  116. package/dist/core/vector2.d.ts +0 -26
  117. package/dist/core/vector2.d.ts.map +0 -1
  118. package/dist/core/vector2.js +0 -105
  119. package/dist/scenes/startup.d.ts +0 -18
  120. package/dist/scenes/startup.d.ts.map +0 -1
  121. /package/dist/{core/events.js → audio/index.js} +0 -0
  122. /package/dist/{core/like.js → timer/index.js} +0 -0
@@ -0,0 +1,224 @@
1
+ import { Rect } from "../math/rect";
2
+ import { Vec2 } from "../math/vector2";
3
+ export class Canvas {
4
+ constructor(
5
+ /** The ultimately visible canvas in the browser */
6
+ displayCanvas, dispatch, abort) {
7
+ Object.defineProperty(this, "displayCanvas", {
8
+ enumerable: true,
9
+ configurable: true,
10
+ writable: true,
11
+ value: displayCanvas
12
+ });
13
+ Object.defineProperty(this, "dispatch", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: dispatch
18
+ });
19
+ Object.defineProperty(this, "abort", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: abort
24
+ });
25
+ /** The canvas that we're drawing to with `like.gfx` functions.
26
+ * If it's the same as displayCanvas, we're in native mode.
27
+ * Otherwise, we're in pixelart mode, consisting of nearest -> linear scaling.
28
+ */
29
+ Object.defineProperty(this, "renderCanvas", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+ Object.defineProperty(this, "resizeTimeoutId", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true,
39
+ value: 0
40
+ });
41
+ displayCanvas.tabIndex = 0;
42
+ displayCanvas.style.width = '100%';
43
+ displayCanvas.style.height = '100%';
44
+ this.renderCanvas = this.displayCanvas;
45
+ this.setMode('native');
46
+ /** Only the canvas can really transform the mouse to the game size.
47
+ * This hack sends an event for the mouse module to listen to.
48
+ */
49
+ this.displayCanvas.addEventListener('mousemove', (ev) => {
50
+ let pos;
51
+ let delta;
52
+ const rawPos = [ev.offsetX, ev.offsetY];
53
+ const rawDelta = [ev.movementX, ev.movementY];
54
+ if (this.renderCanvas == this.displayCanvas) {
55
+ /* Native mode. */
56
+ pos = Vec2.mul(rawPos, window.devicePixelRatio ?? 1);
57
+ delta = Vec2.mul(rawDelta, window.devicePixelRatio ?? 1);
58
+ }
59
+ else {
60
+ /* Pixelart mode. This math simulates object-fit: contain,
61
+ * which preserves aspect ratio.
62
+ */
63
+ const csize = [
64
+ this.displayCanvas.clientWidth,
65
+ this.displayCanvas.clientHeight
66
+ ];
67
+ /* Scale of both dimensions */
68
+ const scale = calcAspectFriendlyScale(this.getSize(), csize);
69
+ /* Upper-left corner */
70
+ const offset = Vec2.div(Vec2.sub(csize, Vec2.mul(this.getSize(), scale)), 2);
71
+ pos = Vec2.div(Vec2.sub(rawPos, offset), scale);
72
+ delta = Vec2.div(rawDelta, scale);
73
+ /* Only handle mousemove events that are in bounds. */
74
+ if (!Rect.containsPoint(this.getRect(), pos)) {
75
+ return;
76
+ }
77
+ }
78
+ this.displayCanvas.dispatchEvent(new CustomEvent('like:mousemoved', {
79
+ detail: {
80
+ pos,
81
+ delta,
82
+ }
83
+ }));
84
+ }, { signal: this.abort });
85
+ this.displayCanvas.addEventListener("like:preDraw", this.preDraw.bind(this), { signal: this.abort });
86
+ this.displayCanvas.addEventListener("like:postDraw", this.postDraw.bind(this), { signal: this.abort });
87
+ }
88
+ /** Get a unified canvas info object. */
89
+ getMode() {
90
+ return {
91
+ size: this.getSize(),
92
+ flags: {
93
+ fullscreen: this.getFullscreen(),
94
+ }
95
+ };
96
+ }
97
+ /** Set the game's apparent resolution, fullscreen, etc.
98
+ *
99
+ * ### `'native'` mode
100
+ * Keeps the canvas pixel resolution
101
+ * the same as the physical pixel resolution of the
102
+ * device.
103
+ *
104
+ * ### Pixel art mode `[width, height]`
105
+ * The canvas will use prescaling to keep your pixel
106
+ * games looking sharp, but without the uneven pixels
107
+ * caused by the naive approach.
108
+ *
109
+ * @param size 'native' for native mode, otherwise [width, height]
110
+ * @param flags optional options.
111
+ */
112
+ setMode(size, flags = {}) {
113
+ // set up sizing / render target
114
+ const prevRenderCanvas = this.renderCanvas;
115
+ if (size == 'native') {
116
+ this.displayCanvas.style.objectFit = 'fill';
117
+ this.renderCanvas = this.displayCanvas;
118
+ }
119
+ else {
120
+ this.displayCanvas.style.objectFit = 'contain';
121
+ this.renderCanvas = document.createElement('canvas');
122
+ const changed = Canvas.setCanvasElemSize(this.renderCanvas, size);
123
+ if (changed) {
124
+ this.dispatchResize(size);
125
+ }
126
+ }
127
+ if (prevRenderCanvas != this.renderCanvas) {
128
+ this.displayCanvas.dispatchEvent(new CustomEvent("like:updateRenderTarget", {
129
+ detail: {
130
+ target: this.renderCanvas,
131
+ },
132
+ }));
133
+ }
134
+ if ('fullscreen' in flags) {
135
+ this.setFullscreen(flags.fullscreen);
136
+ }
137
+ }
138
+ /** Get the apparent (in-game) canvas size. */
139
+ getSize() {
140
+ return [this.renderCanvas.width, this.renderCanvas.height];
141
+ }
142
+ dispatchResize(size) {
143
+ this.displayCanvas.dispatchEvent(new CustomEvent("like:resizeCanvas", {
144
+ detail: {
145
+ size,
146
+ },
147
+ }));
148
+ this.dispatch("resize", [size]);
149
+ }
150
+ /** Sometimes you want a screen rect! */
151
+ getRect() {
152
+ return [0, 0, ...this.getSize()];
153
+ }
154
+ /** Get the actual (physical) canvas size on screen. */
155
+ getDisplayPixelSize() {
156
+ return Vec2.round(Vec2.mul([this.displayCanvas.clientWidth, this.displayCanvas.clientHeight], window.devicePixelRatio ?? 1));
157
+ }
158
+ /** Are we fullscreen? */
159
+ getFullscreen() {
160
+ return this.displayCanvas === document.fullscreenElement;
161
+ }
162
+ /** Set fullscreen. */
163
+ setFullscreen(fullscreen) {
164
+ if (fullscreen) {
165
+ this.displayCanvas.requestFullscreen();
166
+ this.displayCanvas.focus();
167
+ }
168
+ else {
169
+ if (this.getFullscreen()) {
170
+ document.exitFullscreen();
171
+ }
172
+ }
173
+ }
174
+ /**
175
+ * Called internally by the engine before
176
+ * rendering a frame.
177
+ */
178
+ preDraw() {
179
+ if (this.renderCanvas == this.displayCanvas) {
180
+ const realSize = this.getDisplayPixelSize();
181
+ if ((realSize[0] != this.displayCanvas.width ||
182
+ realSize[1] != this.displayCanvas.height) &&
183
+ !this.resizeTimeoutId) {
184
+ /** In native scaling mode, zooming and resizing the window cause us
185
+ * to set canvas width and height every frame, which could cause
186
+ * tons of canvas bitmap reallocations. So wait 1/4 second..
187
+ */
188
+ Canvas.setCanvasElemSize(this.displayCanvas, realSize);
189
+ this.dispatchResize(realSize);
190
+ this.resizeTimeoutId = setTimeout(() => { this.resizeTimeoutId = 0; }, 250);
191
+ }
192
+ }
193
+ this.renderCanvas.getContext('2d').resetTransform();
194
+ }
195
+ /** Called every frame by the engine after drawing */
196
+ postDraw() {
197
+ if (this.renderCanvas != this.displayCanvas) {
198
+ /* We're in pixelart mode,
199
+ * so set output canvas size to an ideal integer scale.
200
+ * No debounce: changes to integer ratio are infrequent.
201
+ */
202
+ Canvas.setCanvasElemSize(this.displayCanvas, Vec2.mul(this.getSize(), Math.round(calcAspectFriendlyScale(this.getSize(), this.getDisplayPixelSize()))));
203
+ // Copy the internal canvas to the visible one.
204
+ const ctx = this.displayCanvas.getContext('2d');
205
+ ctx.imageSmoothingEnabled = false;
206
+ ctx.drawImage(this.renderCanvas, 0, 0, this.renderCanvas.width, this.renderCanvas.height, 0, 0, this.displayCanvas.width, this.displayCanvas.height);
207
+ }
208
+ }
209
+ /** @returns if size was changed. */
210
+ static setCanvasElemSize(canvas, newSize) {
211
+ if (canvas.width != newSize[0] || canvas.height != newSize[1]) {
212
+ [canvas.width, canvas.height] = newSize;
213
+ return true;
214
+ }
215
+ return false;
216
+ }
217
+ static getCanvasElemSize(canvas) {
218
+ return [canvas.width, canvas.height];
219
+ }
220
+ }
221
+ /** How much could this image be scaled, preserving aspect? */
222
+ function calcAspectFriendlyScale(imageSize, containerSize) {
223
+ return Math.min(...Vec2.div(containerSize, imageSize));
224
+ }
@@ -0,0 +1,203 @@
1
+ /**
2
+ * @module graphics
3
+ * @description a reduced-state, Love2D-like wrapper around browser canvas
4
+ *
5
+ * # Graphics Module
6
+ *
7
+ * A wrapper around browser Canvas.
8
+ * In standard usage `like.gfx` gives a {@link BoundGraphics} object with a canvas already on it.
9
+ * So, you can for example call `like.gfx.rectangle('fill', 'green', [10, 10, 30, 30])`
10
+ *
11
+ * ## State Isolation
12
+ * Each drawing operation resets relevant canvas state before executing:
13
+ * - Stroke properties (`lineWidth`, `lineCap`, `lineJoin`, `miterLimit`) are always set to defaults first
14
+ * - No state leakage between drawing calls
15
+ *
16
+ * ## Predicable Parameter Ordering
17
+ * - No clunky argument overrides that could affect positionality.
18
+ * - **Required arguments** come first as positional parameters
19
+ * - **Optional arguments** are grouped in a trailing `props` object
20
+ * - **Mode** `'fill' | 'line'` is the first arg if relevent.
21
+ * - **Color** then {@link Color}, if relevant -- there is no `setColor`.
22
+ *
23
+ * ## Note: Coordinate System is unchanged from native Canvas.
24
+ * - Origin (0, 0) at top-left
25
+ * - X increases right
26
+ * - Y increases down
27
+ * - Angles in radians, 0 is right, positive is clockwise
28
+ */
29
+ import { type Vector2 } from "../math/vector2";
30
+ import type { Rectangle } from "../math/rect";
31
+ export type DrawMode = "fill" | "line";
32
+ /**
33
+ * - RGBA array with values 0-1: `[r, g, b, a]`
34
+ * - Alpha defaults to 1 if omitted
35
+ * - CSS color strings also accepted: `"red"`, `"#ff0000"`, `"rgb(255,0,0)"`
36
+ */
37
+ export type Color = [number, number, number, number?] | string;
38
+ export type ShapeProps = {
39
+ lineWidth?: number;
40
+ lineCap?: CanvasLineCap;
41
+ lineJoin?: CanvasLineJoin;
42
+ miterLimit?: number;
43
+ };
44
+ export type DrawProps = ShapeProps & {
45
+ quad?: Rectangle;
46
+ r?: number;
47
+ scale?: number | Vector2;
48
+ origin?: number | Vector2;
49
+ };
50
+ export type PrintProps = {
51
+ font?: string;
52
+ width?: number;
53
+ align?: CanvasTextAlign;
54
+ };
55
+ export declare class ImageHandle {
56
+ readonly path: string;
57
+ private element;
58
+ private loadPromise;
59
+ private isLoaded;
60
+ constructor(path: string);
61
+ isReady(): boolean;
62
+ ready(): Promise<void>;
63
+ get size(): Vector2;
64
+ getElement(): HTMLImageElement | null;
65
+ }
66
+ /**
67
+ * All of these methods exist on `like.gfx`, but with `ctx`
68
+ * bound to the first arg.
69
+ *
70
+ * Acts as the core of the graphics system, but can be used separately.
71
+ *
72
+ * ```ts
73
+ * import { draw } from "like/graphics"
74
+ * draw.clear(my2dContext, "red");
75
+ * ```
76
+ *
77
+ */
78
+ export declare const draw: {
79
+ /**
80
+ * Clears the canvas with a solid color.
81
+ * @param ctx Canvas context.
82
+ * @param color Fill color.
83
+ */
84
+ clear(ctx: CanvasRenderingContext2D, color?: Color): void;
85
+ /**
86
+ * Draws a rectangle.
87
+ * @param ctx Canvas context.
88
+ * @param mode Fill or line.
89
+ * @param color Fill or stroke color.
90
+ * @param rect Rectangle [x, y, w, h].
91
+ * @param props Optional stroke properties.
92
+ */
93
+ rectangle(ctx: CanvasRenderingContext2D, mode: DrawMode, color: Color, rect: Rectangle, props?: ShapeProps): void;
94
+ /**
95
+ * Draws a circle or ellipse.
96
+ * @param ctx Canvas context.
97
+ * @param mode Fill or line.
98
+ * @param color Fill or stroke color.
99
+ * @param position Center position.
100
+ * @param radii Radius (number) or [rx, ry] for ellipse.
101
+ * @param props Optional arc, center, and stroke properties. Center is true by default.
102
+ */
103
+ circle(ctx: CanvasRenderingContext2D, mode: DrawMode, color: Color, position: Vector2, radii: number | Vector2, props?: ShapeProps & {
104
+ arc?: [number, number];
105
+ center?: boolean;
106
+ }): void;
107
+ /**
108
+ * Draws connected line segments.
109
+ * @param ctx Canvas context.
110
+ * @param color Stroke color.
111
+ * @param points Array of [x, y] positions.
112
+ * @param props Optional stroke properties.
113
+ */
114
+ line(ctx: CanvasRenderingContext2D, color: Color, points: Vector2[], props?: ShapeProps): void;
115
+ /**
116
+ * Draws text at a position.
117
+ *
118
+ * Keep in mind: if you set `align` without `width` in your props,
119
+ * nothing will happen -- you'll get left-aligned text.
120
+ *
121
+ * Align works browser-style: if you align center, your text draws
122
+ * to the left and right of its position. If you align right, your position
123
+ * becomes the upper-right corner of the text.
124
+ *
125
+ * @param ctx Canvas context.
126
+ * @param color Fill color.
127
+ * @param text Text string.
128
+ * @param position Top-left position.
129
+ * @param props {@link PrintProps} Optional font, text limit, or alignment.
130
+ */
131
+ print(ctx: CanvasRenderingContext2D, color: Color, text: string, position: Vector2, props?: PrintProps): void;
132
+ /**
133
+ * Draws an image.
134
+ *
135
+ * @remarks named "draw" because it draws anything _drawable_
136
+ * in the long run.
137
+ *
138
+ * @param ctx Canvas context.
139
+ * @param handle Image handle from newImage.
140
+ * @param position Draw position.
141
+ * @param props Optional rotation, scale, origin, or quad.
142
+ */
143
+ draw(ctx: CanvasRenderingContext2D, handle: ImageHandle, position: Vector2, props?: DrawProps): void;
144
+ /**
145
+ * Loads an image from a path.
146
+ * Unlike built-in loading, this pretends to be synchronous.
147
+ * @param ctx Canvas context.
148
+ * @param path Image file path.
149
+ * @returns ImageHandle for use with draw.
150
+ */
151
+ newImage(_ctx: CanvasRenderingContext2D, path: string): ImageHandle;
152
+ /**
153
+ * Sets the clipping region.
154
+ * @param ctx Canvas context.
155
+ * @param rect Clipping rectangle, or full canvas if omitted.
156
+ */
157
+ clip(ctx: CanvasRenderingContext2D, rect?: Rectangle): void;
158
+ /**
159
+ * Draws a polygon.
160
+ * @param ctx Canvas context.
161
+ * @param mode Fill or line.
162
+ * @param color Fill or stroke color.
163
+ * @param points Array of [x, y] vertices.
164
+ * @param props Optional stroke properties.
165
+ */
166
+ polygon(ctx: CanvasRenderingContext2D, mode: DrawMode, color: Color, points: Vector2[], props?: ShapeProps): void;
167
+ /**
168
+ * Draws individual pixels.
169
+ * @param ctx Canvas context.
170
+ * @param color Fill color.
171
+ * @param pts Array of [x, y] positions.
172
+ */
173
+ points(ctx: CanvasRenderingContext2D, color: Color, pts: Vector2[]): void;
174
+ /**
175
+ * Saves canvas state.
176
+ * @param ctx Canvas context.
177
+ */
178
+ push(ctx: CanvasRenderingContext2D): void;
179
+ /**
180
+ * Restores canvas state.
181
+ * @param ctx Canvas context.
182
+ */
183
+ pop(ctx: CanvasRenderingContext2D): void;
184
+ /**
185
+ * Applies a translation.
186
+ * @param ctx Canvas context.
187
+ * @param offset [x, y] offset.
188
+ */
189
+ translate(ctx: CanvasRenderingContext2D, offset: Vector2): void;
190
+ /**
191
+ * Applies a rotation.
192
+ * @param ctx Canvas context.
193
+ * @param angle Rotation in radians.
194
+ */
195
+ rotate(ctx: CanvasRenderingContext2D, angle: number): void;
196
+ /**
197
+ * Applies a scale.
198
+ * @param ctx Canvas context.
199
+ * @param factor Scale factor (number or [x, y]).
200
+ */
201
+ scale(ctx: CanvasRenderingContext2D, factor: number | Vector2): void;
202
+ };
203
+ //# sourceMappingURL=drawing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drawing.d.ts","sourceRoot":"","sources":["../../src/graphics/drawing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAQ,KAAK,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC;;;;GAIG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG;IACnC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,UAAU,GAA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