rapid-render 0.1.0 → 0.1.2-1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ export declare const spriteAttributes: ({
2
+ name: string;
3
+ size: number;
4
+ type: number;
5
+ stride: number;
6
+ offset?: undefined;
7
+ normalized?: undefined;
8
+ } | {
9
+ name: string;
10
+ size: number;
11
+ type: number;
12
+ stride: number;
13
+ offset: number;
14
+ normalized?: undefined;
15
+ } | {
16
+ name: string;
17
+ size: number;
18
+ type: number;
19
+ stride: number;
20
+ offset: number;
21
+ normalized: boolean;
22
+ })[];
23
+ export declare const graphicAttributes: ({
24
+ name: string;
25
+ size: number;
26
+ type: number;
27
+ stride: number;
28
+ offset?: undefined;
29
+ normalized?: undefined;
30
+ } | {
31
+ name: string;
32
+ size: number;
33
+ type: number;
34
+ stride: number;
35
+ offset: number;
36
+ normalized: boolean;
37
+ } | {
38
+ name: string;
39
+ size: number;
40
+ type: number;
41
+ stride: number;
42
+ offset: number;
43
+ normalized?: undefined;
44
+ })[];
@@ -1,28 +1,15 @@
1
- import { Rapid } from "..";
1
+ import type Rapid from "../render";
2
+ import { Uniform } from "../webgl/uniform";
2
3
  import RenderRegion from "./region";
4
+ import { Texture } from "../texture";
3
5
  declare class GraphicRegion extends RenderRegion {
4
6
  private vertex;
7
+ private texture?;
8
+ private offset;
5
9
  drawType: number;
6
10
  constructor(rapid: Rapid);
7
- startRender(): void;
8
- addVertex(x: number, y: number, color: number): void;
9
- drawCircle(x: number, y: number, radius: number, color: number): void;
11
+ startRender(offsetX: number, offsetY: number, texture?: Texture, uniforms?: Uniform): void;
12
+ addVertex(x: number, y: number, u: number, v: number, color: number): void;
10
13
  protected executeRender(): void;
11
14
  }
12
- declare const graphicAttributes: ({
13
- name: string;
14
- size: number;
15
- type: number;
16
- stride: number;
17
- offset?: undefined;
18
- normalized?: undefined;
19
- } | {
20
- name: string;
21
- size: number;
22
- type: number;
23
- stride: number;
24
- offset: number;
25
- normalized: boolean;
26
- })[];
27
- export { graphicAttributes };
28
15
  export default GraphicRegion;
@@ -2,24 +2,40 @@ import { IAttribute, WebGLContext } from "../interface";
2
2
  import { WebglBufferArray } from "../math";
3
3
  import Rapid from "../render";
4
4
  import GLShader from "../webgl/glshader";
5
+ import { Uniform } from "../webgl/uniform";
5
6
  declare class RenderRegion {
6
7
  currentShader?: GLShader;
7
- protected defaultShader: GLShader;
8
- protected attribute: IAttribute[];
9
8
  protected webglArrayBuffer: WebglBufferArray;
10
9
  protected rapid: Rapid;
11
10
  protected gl: WebGLContext;
12
11
  protected usedTextures: WebGLTexture[];
13
- protected readonly TEXTURE_UNITS_ARRAY: number[];
14
- protected needBind: Set<number>;
15
- constructor(rapid: Rapid, attributes?: IAttribute[]);
12
+ protected shaders: Map<string, GLShader>;
13
+ protected isCostumShader: boolean;
14
+ private costumUnifrom?;
15
+ private defaultShader?;
16
+ private maxTextureUnits;
17
+ protected freeTextureUnitNum: number;
18
+ constructor(rapid: Rapid);
19
+ getTextureUnitList(): number[];
16
20
  protected addVertex(x: number, y: number, ..._: unknown[]): void;
17
- protected useTexture(texture: WebGLTexture): number;
21
+ /**
22
+ * 使用纹理,必须在渲染操作之前
23
+ * @param texture
24
+ * @returns
25
+ */
26
+ useTexture(texture: WebGLTexture): [number, boolean];
18
27
  enterRegion(customShader?: GLShader): void;
28
+ updateProjection(): void;
29
+ isUnifromChanged(newCurrentUniform?: Uniform): boolean;
30
+ setCurrentUniform(newCurrentUniform: Uniform): void;
19
31
  exitRegion(): void;
20
- protected initDefaultShader(vs: string, fs: string): void;
32
+ protected initDefaultShader(vs: string, fs: string, attributes?: IAttribute[]): void;
33
+ setShader(name: string, vs: string, fs: string, attributes?: IAttribute[]): void;
34
+ getShader(name: string): GLShader | undefined;
21
35
  render(): void;
22
36
  protected executeRender(): void;
23
37
  protected initializeForNextRender(): void;
38
+ hasPendingContent(): boolean;
39
+ isShaderChanged(shader?: GLShader): boolean;
24
40
  }
25
41
  export default RenderRegion;
@@ -1,39 +1,18 @@
1
1
  import RenderRegion from "./region";
2
2
  import Rapid from "../render";
3
- import { UniformType } from "../interface";
4
3
  import GLShader from "../webgl/glshader";
4
+ import { Uniform } from "../webgl/uniform";
5
5
  declare class SpriteRegion extends RenderRegion {
6
6
  private batchSprite;
7
7
  private indexBuffer;
8
- protected readonly MAX_BATCH: number;
8
+ private spriteTextureUnits;
9
+ private spriteTextureUnitIndexOffset;
9
10
  constructor(rapid: Rapid);
10
11
  protected addVertex(x: number, y: number, u: number, v: number, textureUnit: number, color: number): void;
11
- renderSprite(texture: WebGLTexture, width: number, height: number, u0: number, v0: number, u1: number, v1: number, offsetX: number, offsetY: number, color: number, uniforms?: UniformType): void;
12
+ renderSprite(texture: WebGLTexture, width: number, height: number, u0: number, v0: number, u1: number, v1: number, offsetX: number, offsetY: number, color: number, uniforms?: Uniform, flipX?: boolean, flipY?: boolean, additionalTexturenit?: number): void;
12
13
  protected executeRender(): void;
13
14
  enterRegion(customShader?: GLShader | undefined): void;
14
15
  protected initializeForNextRender(): void;
16
+ hasPendingContent(): boolean;
15
17
  }
16
- declare const spriteAttributes: ({
17
- name: string;
18
- size: number;
19
- type: number;
20
- stride: number;
21
- offset?: undefined;
22
- normalized?: undefined;
23
- } | {
24
- name: string;
25
- size: number;
26
- type: number;
27
- stride: number;
28
- offset: number;
29
- normalized?: undefined;
30
- } | {
31
- name: string;
32
- size: number;
33
- type: number;
34
- stride: number;
35
- offset: number;
36
- normalized: boolean;
37
- })[];
38
- export { spriteAttributes };
39
18
  export default SpriteRegion;
package/dist/render.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { IGraphicOptions, IRapiadOptions, IRenderLineOptions, IRenderSpriteOptions, WebGLContext } from "./interface";
1
+ import { ICircleRenderOptions, IGraphicRenderOptions, ILayerRenderOptions, IRapidOptions, IRectRenderOptions, IRenderLineOptions, ISpriteRenderOptions, ShaderType as ShaderType, MaskType, WebGLContext, BlendMode, ILightRenderOptions, IParticleOptions, IPolygonGraphicRenderOptions } from "./interface";
2
+ import { LightManager } from "./light";
2
3
  import { Color, MatrixStack, Vec2 } from "./math";
3
4
  import RenderRegion from "./regions/region";
4
- import { Texture, TextureCache } from "./texture";
5
+ import { FrameBufferObject, Texture, TextureCache } from "./texture";
6
+ import { TileMapRender, TileSet } from "./tilemap";
5
7
  import GLShader from "./webgl/glshader";
8
+ import { ParticleEmitter } from "./particle";
6
9
  /**
7
10
  * The `Rapid` class provides a WebGL-based rendering engine.
8
11
  */
@@ -12,27 +15,49 @@ declare class Rapid {
12
15
  projection: Float32Array;
13
16
  projectionDirty: boolean;
14
17
  matrixStack: MatrixStack;
15
- textures: TextureCache;
18
+ texture: TextureCache;
19
+ tileMap: TileMapRender;
20
+ light: LightManager;
16
21
  width: number;
17
22
  height: number;
18
23
  backgroundColor: Color;
19
- readonly devicePixelRatio: number;
24
+ devicePixelRatio: number;
25
+ private physicsWidth;
26
+ private physicsHeight;
27
+ logicWidth: number;
28
+ logicHeight: number;
29
+ private scaleEnable;
30
+ private scaleRadio;
20
31
  readonly maxTextureUnits: number;
21
32
  private readonly defaultColor;
22
- private readonly defaultColorBlack;
23
33
  private currentRegion?;
24
34
  private currentRegionName?;
25
35
  private regions;
36
+ private currentMaskType;
37
+ private currentTransform;
38
+ private currentFBO;
39
+ private lastTime;
26
40
  /**
27
41
  * Constructs a new `Rapid` instance with the given options.
28
42
  * @param options - Options for initializing the `Rapid` instance.
29
43
  */
30
- constructor(options: IRapiadOptions);
44
+ constructor(options: IRapidOptions);
45
+ /**
46
+ * @param displayWdith css px size
47
+ * @param displayHeight css px size
48
+ */
49
+ updateDisplaySize(displayWdith: number, displayHeight: number): void;
50
+ private resizeSize;
51
+ private updateProjection;
31
52
  /**
32
53
  * Initializes WebGL context settings.
33
54
  * @param gl - The WebGL context.
34
55
  */
35
56
  private initWebgl;
57
+ /**
58
+ * @ignore
59
+ */
60
+ clearTextureUnit(): void;
36
61
  /**
37
62
  * Registers built-in regions such as sprite and graphic regions.
38
63
  */
@@ -43,10 +68,12 @@ declare class Rapid {
43
68
  * @param regionClass - The class of the region to register.
44
69
  */
45
70
  registerRegion(name: string, regionClass: typeof RenderRegion): void;
71
+ private quitCurrentRegion;
46
72
  /**
47
73
  * Sets the current render region by name and optionally a custom shader.
48
74
  * @param regionName - The name of the region to set as current.
49
75
  * @param customShader - An optional custom shader to use with the region.
76
+ * @param hasUnifrom - have costum unifrom
50
77
  */
51
78
  setRegion(regionName: string, customShader?: GLShader): void;
52
79
  /**
@@ -57,69 +84,95 @@ declare class Rapid {
57
84
  * Restores the matrix state from the stack.
58
85
  */
59
86
  restore(): void;
87
+ /**
88
+ * Executes a callback function within a saved and restored matrix state scope.
89
+ * @param cb - The callback function to execute within the saved and restored matrix state scope.
90
+ */
91
+ withTransform(cb: () => void): void;
60
92
  /**
61
93
  * Starts the rendering process, resetting the matrix stack and clearing the current region.
62
94
  * @param clear - Whether to clear the matrix stack. Defaults to true.
63
95
  */
64
- startRender(clear?: boolean): void;
96
+ startRender(clear?: boolean): number;
65
97
  /**
66
98
  * Ends the rendering process by rendering the current region.
67
99
  */
68
100
  endRender(): void;
69
101
  /**
70
- * Renders a sprite with the specified texture, offset, and options.
71
- * @param texture - The texture to render.
72
- * @param offsetX - The X offset for the sprite. Defaults to 0.
73
- * @param offsetY - The Y offset for the sprite. Defaults to 0.
74
- * @param options - Rendering options including color and custom shader.
102
+ * Render
103
+ * @param cb - The function to render.
75
104
  */
76
- renderSprite(texture: Texture, offsetX?: number, offsetY?: number, options?: IRenderSpriteOptions | Color): void;
105
+ render(cb: (dt: number) => void): void;
77
106
  /**
78
- * Renders a line with the specified options.
107
+ * Render a tile map layer.
108
+ * @param data - The map data to render.
109
+ * @param options - The options for rendering the tile map layer.
110
+ */
111
+ renderTileMapLayer(data: (number | string)[][], options: ILayerRenderOptions | TileSet): void;
112
+ /**
113
+ * Renders a sprite with the specified options.
79
114
  *
80
- * @param offsetX - The X offset to apply when rendering the line. Defaults to 0.
81
- * @param offsetY - The Y offset to apply when rendering the line. Defaults to 0.
82
- * @param options - The options for rendering the line, including points and color.
115
+ * @param options - The rendering options for the sprite, including texture, position, color, and shader.
83
116
  */
84
- renderLine(offsetX: number | undefined, offsetY: number | undefined, options: IRenderLineOptions): void;
117
+ renderSprite(options: ISpriteRenderOptions): void;
118
+ renderParticles(particleEmitter: ParticleEmitter): void;
85
119
  /**
86
- * Renders graphics based on the provided options or array of Vec2 points.
120
+ * Renders a texture directly without additional options.
121
+ * This is a convenience method that calls renderSprite with just the texture.
87
122
  *
88
- * @param offsetX - The X offset to apply when rendering the graphics. Defaults to 0.
89
- * @param offsetY - The Y offset to apply when rendering the graphics. Defaults to 0.
90
- * @param options - Either an object containing graphic options or an array of Vec2 points.
123
+ * @param texture - The texture to render at the current transformation position.
124
+ */
125
+ renderTexture(texture: Texture): void;
126
+ /**
127
+ * Renders a line with the specified options.
91
128
  *
92
- * @remarks
93
- * If `options` is an array of `Vec2`, it will be converted to an object with `points` property.
94
- * If `options` is an object, it should contain `points` (array of `Vec2`) and optionally `color` and `drawType`.
129
+ * @param options - The options for rendering the line, including points, color, width, and join/cap types.
95
130
  */
96
- renderGraphic(offsetX: number | undefined, offsetY: number | undefined, options: IGraphicOptions | Vec2[]): void;
131
+ renderLine(options: IRenderLineOptions): void;
97
132
  /**
98
- * Starts a graphic drawing process with an optional custom shader.
99
- * @param customShader - An optional custom shader to use.
133
+ * Renders graphics based on the provided options.
134
+ *
135
+ * @param options - The options for rendering the graphic, including points, color, texture, and draw type.
136
+ */
137
+ renderGraphic(options: IPolygonGraphicRenderOptions): void;
138
+ /**
139
+ * Starts the graphic drawing process.
140
+ *
141
+ * @param options - The options for the graphic drawing, including shader, texture, and draw type.
100
142
  */
101
- startGraphicDraw(customShader?: GLShader): void;
143
+ startGraphicDraw(options: IGraphicRenderOptions): void;
102
144
  /**
103
- * Adds a vertex to the current graphic drawing with a specified position and color.
104
- * @param x - The X position of the vertex.
105
- * @param y - The Y position of the vertex.
106
- * @param color - The color of the vertex.
145
+ * Adds a vertex to the current graphic being drawn.
146
+ *
147
+ * @param offsetX - The X coordinate of the vertex.
148
+ * @param offsetY - The Y coordinate of the vertex.
149
+ * @param uv - The texture UV coordinates for the vertex.
150
+ * @param color - The color of the vertex. Defaults to the renderer's default color.
107
151
  */
108
- addGraphicVertex(x: number | Vec2, y?: number | Color, color?: Color): void;
152
+ addGraphicVertex(offsetX: number, offsetY: number, uv: Vec2, color?: Color): void;
109
153
  /**
110
- * Ends the graphic drawing process by rendering the current graphic region.
154
+ * Completes the graphic drawing process and renders the result.
111
155
  */
112
156
  endGraphicDraw(): void;
157
+ private startDraw;
158
+ private afterDraw;
113
159
  /**
114
- * Resizes the canvas and updates the viewport and projection matrix.
115
- * @param width - The new width of the canvas.
116
- * @param height - The new height of the canvas.
160
+ * Renders a rectangle with the specified options.
161
+ *
162
+ * @param options - The options for rendering the rectangle, including width, height, position, and color.
163
+ */
164
+ renderRect(options: IRectRenderOptions): void;
165
+ /**
166
+ * Renders a circle with the specified options.
167
+ *
168
+ * @param options - The options for rendering the circle, including radius, position, color, and segment count.
117
169
  */
118
- resize(width: number, height: number): void;
170
+ renderCircle(options: ICircleRenderOptions): void;
119
171
  /**
120
172
  * Clears the canvas with the background color.
173
+ * @param bgColor - The background color to clear the canvas with.
121
174
  */
122
- clear(): void;
175
+ clear(bgColor?: Color): void;
123
176
  /**
124
177
  * Creates an orthogonal projection matrix.
125
178
  * @param left - The left bound of the projection.
@@ -130,11 +183,72 @@ declare class Rapid {
130
183
  */
131
184
  private createOrthMatrix;
132
185
  /**
133
- * Transforms a point by applying the current matrix stack.
134
- * @param x - The X coordinate of the point.
135
- * @param y - The Y coordinate of the point.
136
- * @returns The transformed point as an array `[newX, newY]`.
186
+ * Draw a mask. Automatically calls startDrawMask.
187
+ * @param type - The type of mask to draw.
188
+ * @param cb - The callback function to execute.
189
+ */
190
+ drawMask(type: MaskType | undefined, cb: () => void): void;
191
+ /**
192
+ * Start drawing a mask using the stencil buffer.
193
+ * This method configures the WebGL context to begin defining a mask area.
194
+ */
195
+ startDrawMask(type?: MaskType): void;
196
+ /**
197
+ * End the mask drawing process.
198
+ * This method configures the WebGL context to use the defined mask for subsequent rendering.
199
+ */
200
+ endDrawMask(): void;
201
+ /**
202
+ * Set the mask type for rendering
203
+ * @param type - The mask type to apply
204
+ * @param start - Whether this is the start of mask drawing
205
+ */
206
+ private setMaskType;
207
+ /**
208
+ * Clear the current mask by clearing the stencil buffer.
209
+ * This effectively removes any previously defined mask.
210
+ */
211
+ clearMask(): void;
212
+ /**
213
+ * Creates a custom shader.
214
+ * @param vs - Vertex shader code.
215
+ * @param fs - Fragment shader code.
216
+ * @param type - Shader type.
217
+ * @returns The created shader object.
218
+ */
219
+ createCostumShader(vs: string, fs: string, type: ShaderType, textureUnitNum?: number): GLShader;
220
+ /**
221
+ * Starts rendering to a Frame Buffer Object (FBO)
222
+ * Sets up the FBO for rendering by binding it, adjusting viewport size and projection
223
+ * @param fbo - The Frame Buffer Object to render to
224
+ */
225
+ startFBO(fbo: FrameBufferObject): void;
226
+ /**
227
+ * Ends rendering to a Frame Buffer Object
228
+ * Restores the default framebuffer and original viewport settings
229
+ * @param fbo - The Frame Buffer Object to unbind
230
+ */
231
+ endFBO(): void;
232
+ /**
233
+ * Convenience method to render to a Frame Buffer Object
234
+ * Handles starting and ending the FBO rendering automatically
235
+ * @param fbo - The Frame Buffer Object to render to
236
+ * @param cb - Callback function containing render commands to execute on the FBO
237
+ */
238
+ drawToFBO(fbo: FrameBufferObject, cb: () => void): void;
239
+ /**
240
+ * Set the blend mode for rendering
241
+ * @param mode - The blend mode to apply
242
+ */
243
+ setBlendMode(mode: BlendMode): void;
244
+ /**
245
+ * Render light shadow
246
+ * @param occlusion - The occlusion polygon
247
+ * @param lightSource - The light source position
137
248
  */
138
- transformPoint(x: number, y: number): number[] | Vec2;
249
+ drawLightShadowMask(options: ILightRenderOptions): void;
250
+ createParticleEmitter(options: IParticleOptions): ParticleEmitter;
251
+ cssToGameCoords(x: number | Vec2, y?: number): Vec2;
252
+ gameToCssCoords(x: number | Vec2, y?: number): Vec2;
139
253
  }
140
254
  export default Rapid;
package/dist/texture.d.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  import Rapid from "./render";
2
- import { Images, ITextOptions } from "./interface";
2
+ import { Images, ITextTextureOptions, TextureWrapMode, WebGLContext } from "./interface";
3
3
  /**
4
4
  * texture manager
5
+ * @ignore
5
6
  */
6
7
  declare class TextureCache {
7
8
  private render;
8
9
  private cache;
9
- constructor(render: Rapid);
10
+ private antialias;
11
+ constructor(render: Rapid, antialias: boolean);
10
12
  /**
11
13
  * create texture from url
12
14
  * Equivalent to {@link Texture.fromUrl} method
@@ -14,9 +16,46 @@ declare class TextureCache {
14
16
  * @param antialias
15
17
  * @returns
16
18
  */
17
- textureFromUrl(url: string, antialias?: boolean): Promise<Texture>;
19
+ textureFromUrl(url: string, antialias?: boolean, wrapMode?: TextureWrapMode): Promise<Texture>;
20
+ /**
21
+ * Create a new `Texture` instance from a FrameBufferObject.
22
+ * @param fbo - The FrameBufferObject to create the texture from.
23
+ * @returns A new `Texture` instance created from the specified FrameBufferObject.
24
+ */
25
+ textureFromFrameBufferObject(fbo: FrameBufferObject): Texture;
26
+ /**
27
+ * Create a new `Texture` instance from an image source.
28
+ * @param source - The image source to create the texture from.
29
+ * @param antialias - Whether to enable antialiasing.
30
+ * @returns A new `Texture` instance created from the specified image source.
31
+ */
32
+ textureFromSource(source: Images, antialias?: boolean, wrapMode?: TextureWrapMode): Texture;
33
+ /**
34
+ * Load an image from the specified URL.
35
+ * @param url - The URL of the image to load.
36
+ * @returns A promise that resolves to the loaded HTMLImageElement.
37
+ */
18
38
  loadImage(url: string): Promise<HTMLImageElement>;
19
- createText(options: ITextOptions): Text;
39
+ /**
40
+ * Create a new `Text` instance.
41
+ * @param options - The options for rendering the text, such as font, size, color, etc.
42
+ * @returns A new `Text` instance.
43
+ */
44
+ createText(options: ITextTextureOptions): Text;
45
+ /**
46
+ * Destroy the texture
47
+ * @param texture
48
+ */
49
+ destroy(texture: Texture | BaseTexture): void;
50
+ /**
51
+ * Create a new FrameBufferObject instance
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
56
+ */
57
+ createFrameBufferObject(width: number, height: number, antialias?: boolean): FrameBufferObject;
58
+ private removeCache;
20
59
  }
21
60
  /**
22
61
  * Each {@link Texture} references a baseTexture, and different textures may have the same baseTexture
@@ -25,8 +64,15 @@ declare class BaseTexture {
25
64
  texture: WebGLTexture;
26
65
  width: number;
27
66
  height: number;
28
- constructor(texture: WebGLTexture, width: number, height: number);
29
- static fromImageSource(r: Rapid, image: Images, antialias?: boolean): BaseTexture;
67
+ wrapMode: TextureWrapMode;
68
+ constructor(texture: WebGLTexture, width: number, height: number, wrapMode?: TextureWrapMode);
69
+ static fromImageSource(r: Rapid, image: Images, antialias?: boolean, wrapMode?: TextureWrapMode): BaseTexture;
70
+ /**
71
+ * Destroy the texture
72
+ * @param gl
73
+ * @ignore
74
+ */
75
+ destroy(gl: WebGLContext): void;
30
76
  }
31
77
  declare class Texture {
32
78
  /**
@@ -79,7 +125,7 @@ declare class Texture {
79
125
  * @param w - The width of the region.
80
126
  * @param h - The height of the region.
81
127
  */
82
- setClipRegion(x: number, y: number, w: number, h: number): void;
128
+ setClipRegion(x: number, y: number, w: number, h: number): this | undefined;
83
129
  /**
84
130
  * Creates a new `Texture` instance from the specified image source.
85
131
  * @param rapid - The Rapid instance to use.
@@ -89,13 +135,22 @@ declare class Texture {
89
135
  */
90
136
  static fromImageSource(rapid: Rapid, image: Images, antialias?: boolean): Texture;
91
137
  /**
92
- * Creates a new `Texture` instance from the specified URL.
138
+ * Converts the current texture into a spritesheet.
93
139
  * @param rapid - The Rapid instance to use.
94
- * @param url - The URL of the image to create the texture from.
95
- * @returns A new `Texture` instance created from the specified URL.
140
+ * @param spriteWidth - The width of each sprite in the spritesheet.
141
+ * @param spriteHeight - The height of each sprite in the spritesheet.
142
+ * @returns An array of `Texture` instances representing the sprites in the spritesheet.
143
+ */
144
+ createSpritesHeet(spriteWidth: number, spriteHeight: number): Texture[];
145
+ /**
146
+ * Clone the current texture
147
+ * @returns A new `Texture` instance with the same base texture reference.
96
148
  */
97
- static fromUrl(rapid: Rapid, url: string): Promise<Texture>;
149
+ clone(): Texture;
98
150
  }
151
+ /**
152
+ * @ignore
153
+ */
99
154
  export declare const SCALEFACTOR = 2;
100
155
  declare class Text extends Texture {
101
156
  private options;
@@ -106,8 +161,12 @@ declare class Text extends Texture {
106
161
  * Creates a new `Text` instance.
107
162
  * @param options - The options for rendering the text, such as font, size, color, etc.
108
163
  */
109
- constructor(rapid: Rapid, options: ITextOptions);
164
+ constructor(rapid: Rapid, options: ITextTextureOptions);
110
165
  private updateTextImage;
166
+ /**
167
+ * Creates a canvas element for rendering text.
168
+ * @returns HTMLCanvasElement - The created canvas element.
169
+ */
111
170
  private createTextCanvas;
112
171
  /**
113
172
  * Update the displayed text
@@ -115,4 +174,37 @@ declare class Text extends Texture {
115
174
  */
116
175
  setText(text: string): void;
117
176
  }
118
- export { Text, Texture, BaseTexture, TextureCache };
177
+ declare class FrameBufferObject extends BaseTexture {
178
+ private framebuffer;
179
+ private gl;
180
+ /**
181
+ * Creates a new FrameBufferObject instance
182
+ * @param render - The Rapid instance to use
183
+ * @param width - Width of the framebuffer
184
+ * @param height - Height of the framebuffer
185
+ * @param antialias - Whether to enable antialiasing
186
+ */
187
+ constructor(render: Rapid, width: number, height: number, antialias?: boolean);
188
+ /**
189
+ * Bind the framebuffer for rendering
190
+ * @ignore
191
+ */
192
+ bind(): void;
193
+ /**
194
+ * Unbind the framebuffer and restore default framebuffer
195
+ * @ignore
196
+ */
197
+ unbind(): void;
198
+ /**
199
+ * Resize the framebuffer
200
+ * @param width - New width
201
+ * @param height - New height
202
+ */
203
+ resize(width: number, height: number): void;
204
+ /**
205
+ * Override destroy method to clean up framebuffer resources
206
+ * @param gl - WebGL context
207
+ */
208
+ destroy(gl: WebGLContext): void;
209
+ }
210
+ export { Text, Texture, BaseTexture, TextureCache, FrameBufferObject };