rapid-render 0.1.21 → 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/LICENSE +2 -2
- package/README.md +70 -82
- package/dist/buffer.d.ts +153 -0
- package/dist/color.d.ts +144 -0
- package/dist/draw.d.ts +53 -0
- package/dist/index.d.ts +12 -15
- package/dist/line.d.ts +17 -3
- package/dist/math.d.ts +17 -492
- package/dist/matrix-engine.d.ts +360 -0
- package/dist/particle.d.ts +146 -36
- package/dist/rapid-render.js +3258 -0
- package/dist/rapid-render.umd.cjs +268 -0
- package/dist/region/atlasSpriteRegion.d.ts +9 -0
- package/dist/region/graphicRegion.d.ts +40 -0
- package/dist/region/region.d.ts +42 -0
- package/dist/region/spriteRegion.d.ts +33 -0
- package/dist/render.d.ts +342 -205
- package/dist/texture.d.ts +219 -152
- package/dist/utils.d.ts +28 -25
- package/dist/vite.svg +1 -0
- package/dist/webgl/glshader.d.ts +107 -25
- package/dist/webgl/utils.d.ts +18 -8
- package/package.json +36 -38
- package/dist/depth.d.ts +0 -8
- package/dist/input.d.ts +0 -60
- package/dist/interface.d.ts +0 -334
- package/dist/light.d.ts +0 -7
- package/dist/log.d.ts +0 -2
- package/dist/rapid.global.js +0 -1
- package/dist/rapid.js +0 -1
- package/dist/rapid.umd.cjs +0 -1
- package/dist/regions/attributes.d.ts +0 -44
- package/dist/regions/graphic_region.d.ts +0 -15
- package/dist/regions/region.d.ts +0 -41
- package/dist/regions/sprite_region.d.ts +0 -18
- package/dist/tilemap.d.ts +0 -98
- package/dist/webgl/uniform.d.ts +0 -14
package/dist/texture.d.ts
CHANGED
|
@@ -1,217 +1,284 @@
|
|
|
1
|
-
import Rapid from
|
|
2
|
-
import {
|
|
1
|
+
import { Rapid, TextureFilterMode } from './render';
|
|
2
|
+
import { Color } from './color';
|
|
3
|
+
export type Images = HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap | OffscreenCanvas;
|
|
4
|
+
export declare enum TextureWrapMode {
|
|
5
|
+
REPEAT = 0,
|
|
6
|
+
CLAMP = 1,
|
|
7
|
+
MIRRORED_REPEAT = 2
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Options for configuring texture creation.
|
|
11
|
+
*/
|
|
12
|
+
export interface ITextureOptions {
|
|
13
|
+
textureFilter?: TextureFilterMode;
|
|
14
|
+
wrap?: TextureWrapMode;
|
|
15
|
+
premultipliedAlpha?: boolean;
|
|
16
|
+
key?: string;
|
|
17
|
+
}
|
|
3
18
|
/**
|
|
4
|
-
* texture
|
|
5
|
-
* @ignore
|
|
19
|
+
* Manages texture loading, caching, and creation.
|
|
6
20
|
*/
|
|
7
|
-
declare class
|
|
21
|
+
declare class TextureManager {
|
|
8
22
|
private render;
|
|
9
23
|
private cache;
|
|
10
|
-
|
|
11
|
-
constructor(render: Rapid, antialias: boolean);
|
|
12
|
-
/**
|
|
13
|
-
* create texture from url
|
|
14
|
-
* Equivalent to {@link Texture.fromUrl} method
|
|
15
|
-
* @param url
|
|
16
|
-
* @param antialias
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
textureFromUrl(url: string, antialias?: boolean, wrapMode?: TextureWrapMode): Promise<Texture>;
|
|
24
|
+
constructor(render: Rapid);
|
|
20
25
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param
|
|
23
|
-
* @
|
|
26
|
+
* Asynchronously loads a texture from a URL.
|
|
27
|
+
* @param url - The image URL to load.
|
|
28
|
+
* @param options - Optional configuration for the texture.
|
|
29
|
+
* @returns A promise that resolves to the loaded Texture.
|
|
24
30
|
*/
|
|
25
|
-
|
|
31
|
+
load(url: string, options?: ITextureOptions): Promise<Texture>;
|
|
26
32
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param source - The
|
|
29
|
-
* @param
|
|
30
|
-
* @returns
|
|
33
|
+
* Creates a texture synchronously from an existing HTML element (Image, Canvas, Video).
|
|
34
|
+
* @param source - The source image element.
|
|
35
|
+
* @param options - Optional configuration for the texture.
|
|
36
|
+
* @returns The newly created Texture.
|
|
31
37
|
*/
|
|
32
|
-
|
|
38
|
+
create(source: Images, options?: ITextureOptions): Texture;
|
|
33
39
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param
|
|
36
|
-
* @
|
|
40
|
+
* Creates a generic Render Texture (FrameBuffer).
|
|
41
|
+
* @param width - The width of the render texture.
|
|
42
|
+
* @param height - The height of the render texture.
|
|
43
|
+
* @param options - Optional configuration for the texture.
|
|
44
|
+
* @returns The newly created RenderTexture.
|
|
37
45
|
*/
|
|
38
|
-
|
|
46
|
+
createRenderTexture(options: IRenderTextureOptions): RenderTexture;
|
|
39
47
|
/**
|
|
40
|
-
*
|
|
41
|
-
* @param options -
|
|
42
|
-
* @returns
|
|
48
|
+
* Creates a TextTexture for rendering text.
|
|
49
|
+
* @param options - Optional configuration for the texture.
|
|
50
|
+
* @returns The newly created TextTexture.
|
|
43
51
|
*/
|
|
44
|
-
|
|
52
|
+
createTextTexture(options?: ITextOptions): TextTexture;
|
|
45
53
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
54
|
+
* Destroys a texture and potentially removes its BaseTexture from the cache.
|
|
55
|
+
* If a Texture instance is provided, it decrements the reference count of the BaseTexture.
|
|
56
|
+
* The BaseTexture will only be destroyed if its reference count drops to 0, or if `force` is true.
|
|
57
|
+
* @param textureOrUrl - The texture instance, base texture, or cache key (URL) to destroy.
|
|
58
|
+
* @param force - If true, destroys the underlying BaseTexture immediately regardless of reference count.
|
|
48
59
|
*/
|
|
49
|
-
destroy(
|
|
60
|
+
destroy(textureOrUrl: Texture | BaseTexture | string, force?: boolean): void;
|
|
50
61
|
/**
|
|
51
|
-
*
|
|
52
|
-
* @param width - Width of the framebuffer
|
|
53
|
-
* @param height - Height of the framebuffer
|
|
54
|
-
* @param antialias - Whether to enable antialiasing
|
|
55
|
-
* @returns A new FrameBufferObject instance
|
|
62
|
+
* Destroys all cached textures and clears the cache, ignoring reference counts.
|
|
56
63
|
*/
|
|
57
|
-
|
|
58
|
-
private
|
|
64
|
+
destroyAll(): void;
|
|
65
|
+
private _fetchImage;
|
|
59
66
|
}
|
|
60
67
|
/**
|
|
61
|
-
*
|
|
68
|
+
* The underlying GPU resource holder for a texture.
|
|
69
|
+
* Implements simple reference counting.
|
|
62
70
|
*/
|
|
63
|
-
declare class BaseTexture {
|
|
64
|
-
|
|
71
|
+
export declare class BaseTexture {
|
|
72
|
+
glTexture: WebGLTexture | null;
|
|
65
73
|
width: number;
|
|
66
74
|
height: number;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Destroy the texture
|
|
72
|
-
* @param gl
|
|
73
|
-
* @ignore
|
|
74
|
-
*/
|
|
75
|
-
destroy(gl: WebGLContext): void;
|
|
76
|
-
}
|
|
77
|
-
declare class Texture {
|
|
78
|
-
/**
|
|
79
|
-
* Reference to the {@link BaseTexture} used by this texture.
|
|
80
|
-
*/
|
|
81
|
-
base?: BaseTexture;
|
|
82
|
-
/**
|
|
83
|
-
* The x-coordinate of the top-left corner of the clipped region.
|
|
84
|
-
*/
|
|
85
|
-
clipX: number;
|
|
75
|
+
uid?: string;
|
|
76
|
+
refCount: number;
|
|
77
|
+
constructor(texture: WebGLTexture, width: number, height: number);
|
|
86
78
|
/**
|
|
87
|
-
*
|
|
79
|
+
* Creates a BaseTexture from an image source.
|
|
80
|
+
* @param render - The Rapid renderer instance.
|
|
81
|
+
* @param source - The image source.
|
|
82
|
+
* @param options - Optional configuration.
|
|
83
|
+
* @returns The created BaseTexture.
|
|
88
84
|
*/
|
|
89
|
-
|
|
85
|
+
static fromSource(render: Rapid, source: Images, options?: ITextureOptions): BaseTexture;
|
|
90
86
|
/**
|
|
91
|
-
*
|
|
87
|
+
* Updates the content of the existing texture (e.g. for Video or dynamic Canvas).
|
|
88
|
+
* Uses texSubImage2D if dimensions haven't changed for better performance.
|
|
89
|
+
* @param gl - The WebGL rendering context.
|
|
90
|
+
* @param source - The new image source.
|
|
92
91
|
*/
|
|
93
|
-
|
|
92
|
+
updateSource(gl: WebGL2RenderingContext, source: Images, options?: ITextureOptions): void;
|
|
94
93
|
/**
|
|
95
|
-
*
|
|
94
|
+
* Dynamically updates the texture filtering mode.
|
|
96
95
|
*/
|
|
97
|
-
|
|
96
|
+
setFilterMode(gl: WebGL2RenderingContext, filterMode: TextureFilterMode): void;
|
|
98
97
|
/**
|
|
99
|
-
*
|
|
98
|
+
* Dynamically updates the texture wrap mode.
|
|
100
99
|
*/
|
|
101
|
-
|
|
100
|
+
setWrapMode(gl: WebGL2RenderingContext, wrapMode: TextureWrapMode): void;
|
|
102
101
|
/**
|
|
103
|
-
*
|
|
102
|
+
* Destroys the WebGL texture resource.
|
|
103
|
+
* @param gl - The WebGL rendering context.
|
|
104
104
|
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
destroy(gl: WebGL2RenderingContext): void;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A lightweight reference to a BaseTexture, containing UV clipping and logical size information.
|
|
109
|
+
*/
|
|
110
|
+
declare class Texture {
|
|
111
|
+
base?: BaseTexture;
|
|
112
|
+
uvX: number;
|
|
113
|
+
uvY: number;
|
|
114
|
+
uvW: number;
|
|
115
|
+
uvH: number;
|
|
116
|
+
rawWidth: number;
|
|
117
|
+
rawHeight: number;
|
|
118
|
+
offsetX: number;
|
|
119
|
+
offsetY: number;
|
|
120
|
+
scale: number;
|
|
121
|
+
isAtlas: boolean;
|
|
122
|
+
flipY: boolean;
|
|
123
|
+
isRotated: boolean;
|
|
124
|
+
glTexture: WebGLTexture | null;
|
|
125
|
+
get width(): number;
|
|
126
|
+
get height(): number;
|
|
127
|
+
protected _px: number;
|
|
128
|
+
protected _py: number;
|
|
129
|
+
protected _pw: number;
|
|
130
|
+
protected _ph: number;
|
|
131
|
+
constructor(base?: BaseTexture);
|
|
110
132
|
/**
|
|
111
|
-
*
|
|
112
|
-
* @param base - The
|
|
133
|
+
* Sets the base texture and increments its reference count.
|
|
134
|
+
* @param base - The BaseTexture instance.
|
|
135
|
+
* @returns The current Texture instance.
|
|
113
136
|
*/
|
|
114
|
-
|
|
137
|
+
setBase(base: BaseTexture): this;
|
|
115
138
|
/**
|
|
116
|
-
*
|
|
117
|
-
* @param
|
|
118
|
-
* @param
|
|
139
|
+
* Sets the visible region (clipping) in pixels relative to the BaseTexture.
|
|
140
|
+
* @param x - The x coordinate in pixels.
|
|
141
|
+
* @param y - The y coordinate in pixels.
|
|
142
|
+
* @param w - The width in pixels.
|
|
143
|
+
* @param h - The height in pixels.
|
|
144
|
+
* @returns The current Texture instance.
|
|
119
145
|
*/
|
|
120
|
-
|
|
146
|
+
setRegion(x: number, y: number, w: number, h: number): this;
|
|
121
147
|
/**
|
|
122
|
-
*
|
|
123
|
-
* @param x - The x
|
|
124
|
-
* @param y - The y
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
148
|
+
* Creates a new Texture representing a sub-region of this Texture.
|
|
149
|
+
* @param x - The x coordinate in pixels, relative to this texture's logical start.
|
|
150
|
+
* @param y - The y coordinate in pixels, relative to this texture's logical start.
|
|
151
|
+
* @param width - The width of the sub-texture in pixels.
|
|
152
|
+
* @param height - The height of the sub-texture in pixels.
|
|
153
|
+
* @returns A new Texture pointing to the sub-region.
|
|
127
154
|
*/
|
|
128
|
-
|
|
155
|
+
getSubTexture(x: number, y: number, width: number, height: number): Texture;
|
|
129
156
|
/**
|
|
130
|
-
* Creates a
|
|
131
|
-
* @
|
|
132
|
-
* @param image - The image source to create the texture from.
|
|
133
|
-
* @param antialias - Whether to enable antialiasing for the texture. Default is `false`.
|
|
134
|
-
* @returns A new `Texture` instance created from the image source.
|
|
157
|
+
* Creates a shallow copy of this Texture, sharing the same BaseTexture.
|
|
158
|
+
* @returns A new Texture instance.
|
|
135
159
|
*/
|
|
136
|
-
|
|
160
|
+
clone(target?: Texture): Texture;
|
|
137
161
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* @param
|
|
141
|
-
* @
|
|
162
|
+
* Utility to split this texture into a grid of sprite textures.
|
|
163
|
+
* Sub-textures will respect the current UV offsets.
|
|
164
|
+
* @param cellWidth - The width of each cell in pixels.
|
|
165
|
+
* @param cellHeight - The height of each cell in pixels.
|
|
166
|
+
* @param cols - Optional number of columns. Truncates based on texture width if omitted.
|
|
167
|
+
* @param rows - Optional number of rows. Truncates based on texture height if omitted.
|
|
168
|
+
* @param gap - Optional pixel gap between cells.
|
|
169
|
+
* @returns An array of split Textures.
|
|
142
170
|
*/
|
|
143
|
-
|
|
171
|
+
splitGrid(cellWidth: number, cellHeight: number, cols?: number, rows?: number, gap?: number): Texture[];
|
|
144
172
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @param
|
|
147
|
-
* @param
|
|
148
|
-
* @param spriteHeight - The height of each sprite in the spritesheet.
|
|
149
|
-
* @returns An array of `Texture` instances representing the sprites in the spritesheet.
|
|
173
|
+
* Creates a Texture directly from an image source, bypassing the TextureManager.
|
|
174
|
+
* @param source - The image element, canvas, video, or bitmap.
|
|
175
|
+
* @param options - Optional antialias and wrap mode settings.
|
|
150
176
|
*/
|
|
151
|
-
|
|
177
|
+
static fromImageSource(render: Rapid, source: Images, options?: ITextureOptions): Texture;
|
|
152
178
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @returns A new `Texture` instance with the same base texture reference.
|
|
179
|
+
* Marks this Texture as destroyed, decrementing the BaseTexture reference count.
|
|
155
180
|
*/
|
|
156
|
-
|
|
181
|
+
destroy(): void;
|
|
182
|
+
}
|
|
183
|
+
export interface IRenderTextureOptions extends ITextureOptions {
|
|
184
|
+
width: number;
|
|
185
|
+
height: number;
|
|
186
|
+
clearColor?: Color;
|
|
157
187
|
}
|
|
158
188
|
/**
|
|
159
|
-
*
|
|
189
|
+
* A texture that can be rendered to (wraps a WebGL Framebuffer).
|
|
160
190
|
*/
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
private
|
|
164
|
-
private
|
|
165
|
-
|
|
166
|
-
|
|
191
|
+
declare class RenderTexture extends Texture {
|
|
192
|
+
private framebuffer;
|
|
193
|
+
private renderbuffer;
|
|
194
|
+
private gl;
|
|
195
|
+
flipY: boolean;
|
|
196
|
+
clearColor?: Color;
|
|
197
|
+
/** Actual GPU-allocated dimensions — grow-only, never shrink */
|
|
198
|
+
private _allocW;
|
|
199
|
+
private _allocH;
|
|
200
|
+
constructor(render: Rapid, options: IRenderTextureOptions);
|
|
167
201
|
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
202
|
+
* Resizes the render texture using a grow-only GPU allocation strategy.
|
|
203
|
+
*
|
|
204
|
+
* - GPU memory is only reallocated when the new size **exceeds** the current allocation.
|
|
205
|
+
* - Shrinking only updates the logical dimensions and UV sub-region — no GPU work.
|
|
206
|
+
*
|
|
207
|
+
* This makes it safe to call every frame with varying sizes (e.g. inside applyFilters).
|
|
208
|
+
*
|
|
209
|
+
* @param width - New logical width.
|
|
210
|
+
* @param height - New logical height.
|
|
211
|
+
* @param force - Force full GPU reallocation regardless of current allocation size.
|
|
170
212
|
*/
|
|
171
|
-
|
|
172
|
-
private updateTextImage;
|
|
213
|
+
resize(width: number, height: number, force?: boolean): void;
|
|
173
214
|
/**
|
|
174
|
-
*
|
|
175
|
-
* @
|
|
215
|
+
* Activates this texture as the current render target.
|
|
216
|
+
* @param clear - Whether to clear the render target after activation.
|
|
176
217
|
*/
|
|
177
|
-
|
|
218
|
+
activate(clear?: boolean): void;
|
|
219
|
+
clear(clearColor?: Color): void;
|
|
178
220
|
/**
|
|
179
|
-
*
|
|
180
|
-
* @param text
|
|
221
|
+
* Deactivates this texture, returning rendering to the default frame buffer.
|
|
181
222
|
*/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
223
|
+
deactivate(): void;
|
|
224
|
+
/**
|
|
225
|
+
* Get raw pixels from the render texture.
|
|
226
|
+
* @param x - X coordinate in logical pixel space (top-left origin).
|
|
227
|
+
* @param y - Y coordinate in logical pixel space (top-left origin).
|
|
228
|
+
* @param width - Width of the region to read.
|
|
229
|
+
* @param height - Height of the region to read.
|
|
230
|
+
*/
|
|
231
|
+
GetPixels(x?: number, y?: number, width?: number, height?: number): Uint8Array;
|
|
187
232
|
/**
|
|
188
|
-
*
|
|
189
|
-
* @param
|
|
190
|
-
* @param
|
|
191
|
-
* @param height - Height of the framebuffer
|
|
192
|
-
* @param antialias - Whether to enable antialiasing
|
|
233
|
+
* Get the color at a pixel in the render texture.
|
|
234
|
+
* @param x - X coordinate in logical pixel space (top-left origin).
|
|
235
|
+
* @param y - Y coordinate in logical pixel space (top-left origin).
|
|
193
236
|
*/
|
|
194
|
-
|
|
237
|
+
GetColorAt(x: number, y: number): Color;
|
|
195
238
|
/**
|
|
196
|
-
*
|
|
197
|
-
* @ignore
|
|
239
|
+
* Destroys the framebuffer, renderbuffer, and base texture.
|
|
198
240
|
*/
|
|
199
|
-
|
|
241
|
+
destroy(): void;
|
|
242
|
+
}
|
|
243
|
+
export interface ITextStyle {
|
|
244
|
+
fontFamily?: string;
|
|
245
|
+
fontSize?: number;
|
|
246
|
+
fontWeight?: string;
|
|
247
|
+
fill?: string | CanvasGradient | CanvasPattern;
|
|
248
|
+
stroke?: string | CanvasGradient | CanvasPattern;
|
|
249
|
+
strokeThickness?: number;
|
|
250
|
+
align?: "left" | "center" | "right";
|
|
251
|
+
baseline?: CanvasTextBaseline;
|
|
252
|
+
}
|
|
253
|
+
export interface ITextOptions extends ITextStyle, ITextureOptions {
|
|
254
|
+
text?: string;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* A texture that renders text using an internal HTML Canvas.
|
|
258
|
+
*/
|
|
259
|
+
declare class TextTexture extends Texture {
|
|
260
|
+
private canvas;
|
|
261
|
+
private ctx;
|
|
262
|
+
private render;
|
|
263
|
+
private _text;
|
|
264
|
+
private _style;
|
|
265
|
+
private options;
|
|
266
|
+
flipY: boolean;
|
|
267
|
+
constructor(render: Rapid, options?: ITextOptions);
|
|
268
|
+
get text(): string;
|
|
200
269
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @ignore
|
|
270
|
+
* Set new text and update the texture
|
|
203
271
|
*/
|
|
204
|
-
|
|
272
|
+
set text(value: string);
|
|
273
|
+
get style(): ITextStyle;
|
|
205
274
|
/**
|
|
206
|
-
*
|
|
207
|
-
* @param width - New width
|
|
208
|
-
* @param height - New height
|
|
275
|
+
* Set new style partially and update the texture
|
|
209
276
|
*/
|
|
210
|
-
|
|
277
|
+
set style(value: Partial<ITextStyle>);
|
|
278
|
+
private updateOffset;
|
|
211
279
|
/**
|
|
212
|
-
*
|
|
213
|
-
* @param gl - WebGL context
|
|
280
|
+
* Updates the internal canvas and uploads it to WebGL
|
|
214
281
|
*/
|
|
215
|
-
|
|
282
|
+
update(): void;
|
|
216
283
|
}
|
|
217
|
-
export {
|
|
284
|
+
export { TextureManager, Texture, RenderTexture, TextTexture };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { Color } from './color';
|
|
2
|
+
import { Vec2 } from './math';
|
|
3
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
4
|
+
export declare class Random {
|
|
5
|
+
/** Random float in [min, max). */
|
|
6
|
+
static float(min: number, max: number): number;
|
|
7
|
+
/** Random integer in [min, max] (inclusive). */
|
|
8
|
+
static int(min: number, max: number): number;
|
|
9
|
+
/** Random angle in [0, 2π). */
|
|
10
|
+
static angle(): number;
|
|
11
|
+
/** Random Vec2 with components in the supplied per-axis ranges. */
|
|
12
|
+
static vector(minX: number, maxX: number, minY: number, maxY: number): Vec2;
|
|
13
|
+
/** Random Color with each component interpolated between minColor and maxColor. */
|
|
14
|
+
static randomColor(minColor: Color, maxColor: Color): Color;
|
|
15
|
+
/** Pick a random element from an array with uniform probability. */
|
|
16
|
+
static pick<T>(array: T[]): T;
|
|
17
|
+
/**
|
|
18
|
+
* Pick a random element using weighted probability.
|
|
19
|
+
* @param array - Pairs of [item, weight]. Higher weight = more likely.
|
|
20
|
+
*/
|
|
21
|
+
static pickWeight<T>(array: [T, number][]): T;
|
|
22
|
+
/**
|
|
23
|
+
* Resolves a scalar-or-range value to a concrete T.
|
|
24
|
+
* - `undefined` → `defaultValue`
|
|
25
|
+
* - `T` → `T` (or a clone for objects)
|
|
26
|
+
* - `[T, T]` → random value between the two bounds
|
|
27
|
+
*/
|
|
28
|
+
static scalarOrRange<T extends number | Vec2 | Color>(range?: T | [T, T], defaultValue?: T): T;
|
|
26
29
|
}
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="77" height="47" fill="none" aria-labelledby="vite-logo-title" viewBox="0 0 77 47"><title id="vite-logo-title">Vite</title><style>.parenthesis{fill:#000}@media (prefers-color-scheme:dark){.parenthesis{fill:#fff}}</style><path fill="#9135ff" d="M40.151 45.71c-.663.844-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.493c-.92 0-1.457-1.04-.92-1.788l7.479-10.471c1.07-1.498 0-3.578-1.842-3.578H15.443c-.92 0-1.456-1.04-.92-1.788l9.696-13.576c.213-.297.556-.474.92-.474h28.894c.92 0 1.456 1.04.92 1.788l-7.48 10.472c-1.07 1.497 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.087.89 1.83L40.153 45.712z"/><mask id="a" width="48" height="47" x="14" y="0" maskUnits="userSpaceOnUse" style="mask-type:alpha"><path fill="#000" d="M40.047 45.71c-.663.843-2.02.374-2.02-.699V34.708a2.26 2.26 0 0 0-2.262-2.262H24.389c-.92 0-1.457-1.04-.92-1.788l7.479-10.472c1.07-1.497 0-3.578-1.842-3.578H15.34c-.92 0-1.456-1.04-.92-1.788l9.696-13.575c.213-.297.556-.474.92-.474H53.93c.92 0 1.456 1.04.92 1.788L47.37 13.03c-1.07 1.498 0 3.578 1.842 3.578h11.376c.944 0 1.474 1.088.89 1.831L40.049 45.712z"/></mask><g mask="url(#a)"><g filter="url(#b)"><ellipse cx="5.508" cy="14.704" fill="#eee6ff" rx="5.508" ry="14.704" transform="rotate(269.814 20.96 11.29)scale(-1 1)"/></g><g filter="url(#c)"><ellipse cx="10.399" cy="29.851" fill="#eee6ff" rx="10.399" ry="29.851" transform="rotate(89.814 -16.902 -8.275)scale(1 -1)"/></g><g filter="url(#d)"><ellipse cx="5.508" cy="30.487" fill="#8900ff" rx="5.508" ry="30.487" transform="rotate(89.814 -19.197 -7.127)scale(1 -1)"/></g><g filter="url(#e)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.928 4.177)scale(1 -1)"/></g><g filter="url(#f)"><ellipse cx="5.508" cy="30.599" fill="#8900ff" rx="5.508" ry="30.599" transform="rotate(89.814 -25.738 5.52)scale(1 -1)"/></g><g filter="url(#g)"><ellipse cx="14.072" cy="22.078" fill="#eee6ff" rx="14.072" ry="22.078" transform="rotate(93.35 31.245 55.578)scale(-1 1)"/></g><g filter="url(#h)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#i)"><ellipse cx="3.47" cy="21.501" fill="#8900ff" rx="3.47" ry="21.501" transform="rotate(89.009 35.419 55.202)scale(-1 1)"/></g><g filter="url(#j)"><ellipse cx="14.592" cy="9.743" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(39.51 14.592 9.743)"/></g><g filter="url(#k)"><ellipse cx="61.728" cy="-5.321" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 61.728 -5.32)"/></g><g filter="url(#l)"><ellipse cx="55.618" cy="7.104" fill="#00c2ff" rx="5.971" ry="9.665" transform="rotate(37.892 55.618 7.104)"/></g><g filter="url(#m)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#n)"><ellipse cx="12.326" cy="39.103" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 12.326 39.103)"/></g><g filter="url(#o)"><ellipse cx="49.857" cy="30.678" fill="#8900ff" rx="4.407" ry="29.108" transform="rotate(37.892 49.857 30.678)"/></g><g filter="url(#p)"><ellipse cx="52.623" cy="33.171" fill="#00c2ff" rx="5.971" ry="15.297" transform="rotate(37.892 52.623 33.17)"/></g></g><path d="M6.919 0c-9.198 13.166-9.252 33.575 0 46.789h6.215c-9.25-13.214-9.196-33.623 0-46.789zm62.424 0h-6.215c9.198 13.166 9.252 33.575 0 46.789h6.215c9.25-13.214 9.196-33.623 0-46.789" class="parenthesis"/><defs><filter id="b" width="60.045" height="41.654" x="-5.564" y="16.92" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="c" width="90.34" height="51.437" x="-40.407" y="-6.762" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="d" width="79.355" height="29.4" x="-35.435" y="2.801" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="e" width="79.579" height="29.4" x="-30.84" y="20.8" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="f" width="79.579" height="29.4" x="-29.307" y="21.949" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="g" width="74.749" height="58.852" x="29.961" y="-17.13" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="7.659"/></filter><filter id="h" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="i" width="61.377" height="25.362" x="37.754" y="3.055" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="j" width="56.045" height="63.649" x="-13.43" y="-22.082" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="k" width="54.814" height="64.646" x="34.321" y="-37.644" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="l" width="33.541" height="35.313" x="38.847" y="-10.552" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="m" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="n" width="54.814" height="64.646" x="-15.081" y="6.78" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="o" width="54.814" height="64.646" x="22.45" y="-1.645" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter><filter id="p" width="39.409" height="43.623" x="32.919" y="11.36" color-interpolation-filters="sRGB" filterUnits="userSpaceOnUse"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feBlend in="SourceGraphic" in2="BackgroundImageFix" result="shape"/><feGaussianBlur result="effect1_foregroundBlur_2002_17286" stdDeviation="4.596"/></filter></defs></svg>
|