rapid-render 1.0.21 → 1.0.23

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/dist/texture.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { Rapid } from './render';
2
- import { TextureFilterMode } from './texture-filter-mode';
3
2
  import { Color } from './color';
3
+ export declare enum TextureFilterMode {
4
+ LINEAR = 0,
5
+ NEAREST = 1
6
+ }
4
7
  export type Images = HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap | OffscreenCanvas;
5
8
  export declare enum TextureWrapMode {
6
9
  REPEAT = 0,
@@ -22,7 +25,10 @@ export interface ITextureOptions {
22
25
  declare class TextureManager {
23
26
  private render;
24
27
  private cache;
28
+ texture: Set<Texture>;
25
29
  constructor(render: Rapid);
30
+ addTexture<T extends Texture = Texture>(t: T): T;
31
+ removeTexture<T extends Texture = Texture>(t: T): T;
26
32
  /**
27
33
  * Asynchronously loads a texture from a URL.
28
34
  * @param url - The image URL to load.
@@ -128,6 +134,7 @@ declare class Texture {
128
134
  protected _px: number;
129
135
  protected _py: number;
130
136
  constructor(base?: BaseTexture);
137
+ updateResolution(): void;
131
138
  /**
132
139
  * Sets the base texture and increments its reference count.
133
140
  * @param base - The BaseTexture instance.
@@ -191,6 +198,7 @@ declare class RenderTexture extends Texture {
191
198
  private framebuffer;
192
199
  private renderbuffer;
193
200
  private gl;
201
+ private readonly premultipliedAlpha;
194
202
  clearColor?: Color;
195
203
  /** Actual GPU-allocated dimensions — grow-only, never shrink */
196
204
  private _allocW;
@@ -262,7 +270,7 @@ declare class TextTexture extends Texture {
262
270
  private _text;
263
271
  private _style;
264
272
  private options;
265
- flipY: boolean;
273
+ resolution: number;
266
274
  constructor(render: Rapid, options?: ITextOptions);
267
275
  get text(): string;
268
276
  /**
@@ -275,6 +283,7 @@ declare class TextTexture extends Texture {
275
283
  */
276
284
  set style(value: Partial<ITextStyle>);
277
285
  private updateOffset;
286
+ updateResolution(): void;
278
287
  /**
279
288
  * Updates the internal canvas and uploads it to WebGL
280
289
  */
@@ -0,0 +1,52 @@
1
+ import { ITransformOptions } from './matrix-engine';
2
+ import { IWindowsOptions, Rapid } from './render';
3
+ export declare enum ExpandMode {
4
+ KEEP_W = 0,
5
+ KEEP_H = 1,
6
+ KEEP = 2,
7
+ IGNORE = 3,
8
+ EXPAND = 4,
9
+ NONE = 5
10
+ }
11
+ export interface ICamera extends ITransformOptions {
12
+ limitLeft?: number;
13
+ limitRight?: number;
14
+ limitTop?: number;
15
+ limitBottom?: number;
16
+ }
17
+ interface ScissorViewport {
18
+ x: number;
19
+ y: number;
20
+ width: number;
21
+ height: number;
22
+ }
23
+ export declare class ViewPort {
24
+ readonly rapid: Rapid;
25
+ private viewLeft;
26
+ private viewRight;
27
+ private viewTop;
28
+ private viewBottom;
29
+ private window;
30
+ scissorViewport: ScissorViewport | null;
31
+ resolution: number;
32
+ constructor(rapid: Rapid, options: IWindowsOptions);
33
+ updateWindowOption(window: IWindowsOptions): void;
34
+ /**
35
+ * Resizes the canvas, updates internal viewport values, and recreates projection boundaries.
36
+ * @param logicWidth The new logical display width.
37
+ * @param logicHeight The new logical display height.
38
+ * @param cssWidth Optional CSS display width.
39
+ * @param cssHeight Optional CSS display height.
40
+ */
41
+ resize(logicWidth: number, logicHeight: number, cssWidth?: number, cssHeight?: number): void;
42
+ private updateResolution;
43
+ updateProjection(): void;
44
+ updateOrthMatrix(out: Float32Array, left: number, right: number, bottom: number, top: number): void;
45
+ applyCamera(transform: ICamera): void;
46
+ /** Clips a rectangle in the current projection's logical coordinates. */
47
+ startScissor(x: number, y: number, width: number, height: number): void;
48
+ /** Restores the canvas's letterbox clip after a clear or a temporary scissor. */
49
+ restoreViewportScissor(): void;
50
+ endScissor(): void;
51
+ }
52
+ export {};
@@ -93,6 +93,8 @@ export declare class CustomGlShader {
93
93
  rapid: Rapid;
94
94
  prefix: string[];
95
95
  constructor(rapid: Rapid, vs?: string, fs?: string, usedTextureUnitNum?: number, uniforms?: Record<string, UniformValue>);
96
+ beforePreCompile(): void;
97
+ preCompile(): void;
96
98
  /**
97
99
  * Updates uniform values or textures for the custom shader.
98
100
  * @param uniforms Map of uniform values or WebGL textures to apply.
@@ -1,5 +1,4 @@
1
- import { TextureFilterMode } from '../texture-filter-mode';
2
- import { TextureWrapMode, ITextOptions } from '../texture';
1
+ import { TextureWrapMode, ITextOptions, TextureFilterMode } from '../texture';
3
2
  import { Rapid } from '../render';
4
3
  export type WebGLContext = WebGL2RenderingContext;
5
4
  export declare const supportsWebGL: (canvas: HTMLCanvasElement) => boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rapid-render",
3
3
  "private": false,
4
- "version": "1.0.21",
4
+ "version": "1.0.23",
5
5
  "type": "module",
6
6
  "description": "A high-performance lightweight WebGL 2D renderer for browser games.",
7
7
  "repository": "https://github.com/Nightre/Rapid.js",
@@ -1,5 +0,0 @@
1
- /** Texture sampling mode used when uploading or updating a texture. */
2
- export declare enum TextureFilterMode {
3
- LINEAR = 0,
4
- NEAREST = 1
5
- }