rapid-render 1.0.0 → 1.0.3
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/README.md +87 -70
- package/dist/draw.d.ts +30 -0
- package/dist/index.d.ts +1 -0
- package/dist/math.d.ts +2 -0
- package/dist/matrix-engine.d.ts +1 -0
- package/dist/particle.d.ts +1 -3
- package/dist/rapid-render.js +658 -417
- package/dist/rapid-render.umd.cjs +60 -9
- package/dist/region/particleRegion.d.ts +16 -0
- package/dist/region/region.d.ts +1 -0
- package/dist/region/spriteRegion.d.ts +8 -5
- package/dist/render.d.ts +9 -1
- package/package.json +38 -36
package/README.md
CHANGED
|
@@ -1,70 +1,87 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="./docs/image/logo_title.png" alt="Rapid" width="180" height="97" style="image-rendering: pixelated;">
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<p align="center">
|
|
6
|
-
A stateless, high-performance WebGL 2D renderer for browser games.
|
|
7
|
-
</p>
|
|
8
|
-
|
|
9
|
-
<p align="center">
|
|
10
|
-
<a href="https://nightre.github.io/Rapid.js/">Website</a>
|
|
11
|
-
·
|
|
12
|
-
<a href="https://nightre.github.io/Rapid.js/docs.html">Docs</a>
|
|
13
|
-
·
|
|
14
|
-
<a href="https://nightre.github.io/Rapid.js/api/">API Reference</a>
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## What is Rapid?
|
|
20
|
-
|
|
21
|
-
Rapid is a focused WebGL 2D rendering engine for games and visual tools. It handles the rendering layer while leaving your game architecture, update loop, and state management fully in your hands.
|
|
22
|
-
|
|
23
|
-
> The documentation and demos are still being written.
|
|
24
|
-
|
|
25
|
-
## Highlights
|
|
26
|
-
|
|
27
|
-
- **Automatic batching**
|
|
28
|
-
Rapid automatically batches compatible draw work. Multi-texture batching binds different textures into a single draw call, eliminating manual grouping.
|
|
29
|
-
|
|
30
|
-
- **Powerful custom shaders**
|
|
31
|
-
Add sprite and geometry effects through shader hooks while still using Rapid's normal renderer, transforms, textures, and draw APIs.
|
|
32
|
-
|
|
33
|
-
- **Flexible transforms**
|
|
34
|
-
Compose motion, hierarchy, camera behavior, and local drawing with multiple transform styles backed by a fast matrix engine.
|
|
35
|
-
|
|
36
|
-
- **A complete 2D toolkit**
|
|
37
|
-
Draw sprites, lines, masks, particles, render textures, text, and custom geometry from one compact WebGL renderer.
|
|
38
|
-
|
|
39
|
-
## Install
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
npm install rapid-render
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Quick Start
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
import { Rapid, Color } from "rapid-render";
|
|
49
|
-
|
|
50
|
-
const canvas = document.querySelector("canvas")!;
|
|
51
|
-
const rapid = new Rapid({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./docs/image/logo_title.png" alt="Rapid" width="180" height="97" style="image-rendering: pixelated;">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
A stateless, high-performance WebGL 2D renderer for browser games.
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://nightre.github.io/Rapid.js/">Website</a>
|
|
11
|
+
·
|
|
12
|
+
<a href="https://nightre.github.io/Rapid.js/docs.html">Docs</a>
|
|
13
|
+
·
|
|
14
|
+
<a href="https://nightre.github.io/Rapid.js/api/">API Reference</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## What is Rapid?
|
|
20
|
+
|
|
21
|
+
Rapid is a focused WebGL 2D rendering engine for games and visual tools. lightweight at just **67 kB** (**~19.5 kB gzipped**) It handles the rendering layer while leaving your game architecture, update loop, and state management fully in your hands.
|
|
22
|
+
|
|
23
|
+
> The documentation and demos are still being written.
|
|
24
|
+
|
|
25
|
+
## Highlights
|
|
26
|
+
|
|
27
|
+
- **Automatic batching**
|
|
28
|
+
Rapid automatically batches compatible draw work. Multi-texture batching binds different textures into a single draw call, eliminating manual grouping.
|
|
29
|
+
|
|
30
|
+
- **Powerful custom shaders**
|
|
31
|
+
Add sprite and geometry effects through shader hooks while still using Rapid's normal renderer, transforms, textures, and draw APIs.
|
|
32
|
+
|
|
33
|
+
- **Flexible transforms**
|
|
34
|
+
Compose motion, hierarchy, camera behavior, and local drawing with multiple transform styles backed by a fast matrix engine.
|
|
35
|
+
|
|
36
|
+
- **A complete 2D toolkit**
|
|
37
|
+
Draw sprites, lines, masks, particles, render textures, text, and custom geometry from one compact WebGL renderer.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install rapid-render
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Quick Start
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { Rapid, Color } from "rapid-render";
|
|
49
|
+
|
|
50
|
+
const canvas = document.querySelector("canvas")!;
|
|
51
|
+
const rapid = new Rapid({canvas});
|
|
52
|
+
|
|
53
|
+
rapid.clear();
|
|
54
|
+
rapid.drawRect({
|
|
55
|
+
x: 40,
|
|
56
|
+
y: 40,
|
|
57
|
+
width: 160,
|
|
58
|
+
height: 96,
|
|
59
|
+
color: new Color(84, 184, 234),
|
|
60
|
+
});
|
|
61
|
+
rapid.flush();
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Benchmark
|
|
65
|
+
|
|
66
|
+
Performance Comparison: Rapid vs. Other Renderers and Game Engines
|
|
67
|
+
|
|
68
|
+
<p align="center">
|
|
69
|
+
<a href="https://nightre.github.io/Rapid.js/benchmark/">
|
|
70
|
+
<img src="./docs/benchmark/benchmark.png" alt="Benchmark Result">
|
|
71
|
+
<img src="./docs/benchmark/benchmark2.png" alt="Benchmark Result">
|
|
72
|
+
</a>
|
|
73
|
+
</p>
|
|
74
|
+
|
|
75
|
+
<p align="center">
|
|
76
|
+
🎮 <strong><a href="https://nightre.github.io/Rapid.js/benchmark/">Run Interactive Benchmark Live →</a></strong>
|
|
77
|
+
</p>
|
|
78
|
+
|
|
79
|
+
Tested on **Windows 11 / Intel i7-12850H / NVIDIA RTX 4070 Laptop GPU / Google Chrome (WebGL 2.0)** (Chrome / WebGL 2.0)
|
|
80
|
+
|
|
81
|
+
## Contributing
|
|
82
|
+
|
|
83
|
+
Contributions, issues, and feature requests are welcome!
|
|
84
|
+
|
|
85
|
+
Before submitting a Pull Request, please ensure:
|
|
86
|
+
- **Strict TypeScript (Zero any)**: All code must pass strict type checking with zero `any`, loose casts, or `@ts-ignore` directives.
|
|
87
|
+
- **Passing Checks**: Run `npm run build` to ensure clean compilation with zero warnings or errors.
|
package/dist/draw.d.ts
CHANGED
|
@@ -14,6 +14,34 @@ export interface IDrawOptions extends ITransformOptions {
|
|
|
14
14
|
shader?: DrawShader;
|
|
15
15
|
customMatrix?: number;
|
|
16
16
|
}
|
|
17
|
+
export interface IDrawParticleOptions {
|
|
18
|
+
shader?: DrawShader;
|
|
19
|
+
texture: Texture;
|
|
20
|
+
color?: Color;
|
|
21
|
+
flipX?: boolean;
|
|
22
|
+
flipY?: boolean;
|
|
23
|
+
x?: number;
|
|
24
|
+
y?: number;
|
|
25
|
+
position?: Vec2;
|
|
26
|
+
rotation?: number;
|
|
27
|
+
scaleX?: number;
|
|
28
|
+
scaleY?: number;
|
|
29
|
+
isRotated?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface IDrawParticleBatchOptions {
|
|
32
|
+
shader?: DrawShader;
|
|
33
|
+
texture: Texture;
|
|
34
|
+
x: Array<number>;
|
|
35
|
+
y: Array<number>;
|
|
36
|
+
rotation: Array<number>;
|
|
37
|
+
color: Array<Color>;
|
|
38
|
+
count?: number;
|
|
39
|
+
scaleX?: number;
|
|
40
|
+
scaleY?: number;
|
|
41
|
+
flipX?: boolean;
|
|
42
|
+
flipY?: boolean;
|
|
43
|
+
isRotated?: boolean;
|
|
44
|
+
}
|
|
17
45
|
export interface ISpriteOptions extends IDrawOptions {
|
|
18
46
|
texture: Texture;
|
|
19
47
|
color?: Color;
|
|
@@ -46,6 +74,8 @@ export interface ICircleOptions extends IDrawOptions {
|
|
|
46
74
|
}
|
|
47
75
|
export declare const drawSpriteRaw: (rapid: Rapid, options: ISpriteOptions) => void;
|
|
48
76
|
export declare const drawSprite: (rapid: Rapid, options: ISpriteOptions) => void;
|
|
77
|
+
export declare const drawParticle: (rapid: Rapid, options: IDrawParticleOptions) => void;
|
|
78
|
+
export declare const drawParticles: (rapid: Rapid, options: IDrawParticleBatchOptions) => void;
|
|
49
79
|
export declare const drawGraphic: (rapid: Rapid, options: IGraphicOptions) => void;
|
|
50
80
|
export declare const drawLine: (rapid: Rapid, options: ILineOptions) => void;
|
|
51
81
|
export declare const drawMaskImage: (rapid: Rapid, options: IMaskImageOptions) => void;
|
package/dist/index.d.ts
CHANGED
package/dist/math.d.ts
CHANGED
|
@@ -44,3 +44,5 @@ export declare class Vec2 {
|
|
|
44
44
|
static FromArray(array: number[][]): Vec2[];
|
|
45
45
|
static fromAngle(angle: number): Vec2;
|
|
46
46
|
}
|
|
47
|
+
export declare const composeProjectionWithAffine: (projection: Float32Array, affine: Float32Array) => Float32Array;
|
|
48
|
+
export declare const multiplyMat4: (A: Float32Array, B: Float32Array) => Float32Array;
|
package/dist/matrix-engine.d.ts
CHANGED
|
@@ -202,6 +202,7 @@ export declare class MatrixStore {
|
|
|
202
202
|
* @param f - An array (Float32Array or standard number array) containing the 6 new elements.
|
|
203
203
|
*/
|
|
204
204
|
setMatrix(index: number, f: Float32Array | number[]): void;
|
|
205
|
+
multiplyAffineInPlace(index: number, a: number, b: number, c: number, dValue: number, tx: number, ty: number): void;
|
|
205
206
|
}
|
|
206
207
|
/**
|
|
207
208
|
* A highly performant MatrixStack useful for hierarchal scene graphs.
|
package/dist/particle.d.ts
CHANGED
|
@@ -43,10 +43,8 @@ export interface IParticleAnimation {
|
|
|
43
43
|
scale?: ParticleAttribute<number> | number;
|
|
44
44
|
/** Tint color (0-255 components, uses engine Color class). */
|
|
45
45
|
color?: ParticleAttribute<Color> | Color;
|
|
46
|
-
/** Additive velocity vector (pixels/sec). */
|
|
46
|
+
/** Additive velocity vector (pixels/sec). Use `velocity.delta` to simulate constant acceleration (e.g. gravity). */
|
|
47
47
|
velocity?: ParticleAttribute<Vec2> | Vec2;
|
|
48
|
-
/** Acceleration vector added to velocity each second (pixels/sec²). */
|
|
49
|
-
acceleration?: ParticleAttribute<Vec2> | Vec2;
|
|
50
48
|
}
|
|
51
49
|
export interface IParticleOptions {
|
|
52
50
|
/** Texture(s) to pick from. Pass a weighted tuple `[Texture, weight][]` for weighted random. */
|