rapid-render 0.1.111 → 1.0.2
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 +58 -51
- package/dist/buffer.d.ts +153 -0
- package/dist/color.d.ts +144 -0
- package/dist/draw.d.ts +83 -0
- package/dist/index.d.ts +13 -11
- package/dist/line.d.ts +16 -2
- package/dist/math.d.ts +20 -442
- package/dist/matrix-engine.d.ts +361 -0
- package/dist/particle.d.ts +181 -14
- package/dist/rapid-render.js +3499 -0
- package/dist/rapid-render.umd.cjs +319 -0
- package/dist/region/atlasSpriteRegion.d.ts +9 -0
- package/dist/region/graphicRegion.d.ts +40 -0
- package/dist/region/particleRegion.d.ts +16 -0
- package/dist/region/region.d.ts +43 -0
- package/dist/region/spriteRegion.d.ts +36 -0
- package/dist/render.d.ts +351 -188
- package/dist/texture.d.ts +219 -152
- package/dist/utils.d.ts +29 -1
- 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 +19 -17
- package/dist/depth.d.ts +0 -8
- package/dist/interface.d.ts +0 -165
- package/dist/light.d.ts +0 -5
- 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 -97
- package/dist/webgl/uniform.d.ts +0 -14
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2026 夜均
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,72 +1,79 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./docs/image/logo_title.png" alt="Rapid" width="180" height="97" style="image-rendering: pixelated;">
|
|
3
|
+
</p>
|
|
1
4
|
|
|
2
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
A stateless, high-performance WebGL 2D renderer for browser games.
|
|
7
|
+
</p>
|
|
3
8
|
|
|
4
|
-
|
|
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>
|
|
5
16
|
|
|
6
|
-
|
|
17
|
+
---
|
|
7
18
|
|
|
8
|
-
|
|
19
|
+
## What is Rapid?
|
|
9
20
|
|
|
10
|
-
|
|
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.
|
|
11
22
|
|
|
12
|
-
|
|
13
|
-
* **TileMap** - YSort, isometric
|
|
14
|
-
* **Graphics Drawing**
|
|
15
|
-
* **Text Rendering**
|
|
16
|
-
* **Line Drawing** - line texture
|
|
17
|
-
* **Custom Shaders**
|
|
18
|
-
* **Mask**
|
|
19
|
-
* **Frame Buffer Object**
|
|
23
|
+
> The documentation and demos are still being written.
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
> This project is a work in progress! Expect bugs, report issues, and feel free to contribute.
|
|
25
|
+
## Highlights
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
- **Automatic batching**
|
|
28
|
+
Rapid automatically batches compatible draw work. Multi-texture batching binds different textures into a single draw call, eliminating manual grouping.
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```
|
|
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.
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
- **Flexible transforms**
|
|
34
|
+
Compose motion, hierarchy, camera behavior, and local drawing with multiple transform styles backed by a fast matrix engine.
|
|
31
35
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
36
|
+
- **A complete 2D toolkit**
|
|
37
|
+
Draw sprites, lines, masks, particles, render textures, text, and custom geometry from one compact WebGL renderer.
|
|
35
38
|
|
|
36
|
-
##
|
|
39
|
+
## Install
|
|
37
40
|
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Initialize
|
|
42
|
-
const rapid = new Rapid({
|
|
43
|
-
canvas: document.getElementById("gameCanvas"),
|
|
44
|
-
backgroundColor: Color.fromHex("E6F0FF")
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
// Render example
|
|
48
|
-
rapid.render(() => {
|
|
49
|
-
rapid.renderRect({
|
|
50
|
-
offset: new Vec2(100, 100),
|
|
51
|
-
width: 50,
|
|
52
|
-
height: 50,
|
|
53
|
-
color: Color.Red
|
|
54
|
-
})
|
|
55
|
-
})
|
|
41
|
+
```bash
|
|
42
|
+
npm install rapid-render
|
|
56
43
|
```
|
|
57
44
|
|
|
58
|
-
|
|
45
|
+
## Quick Start
|
|
59
46
|
|
|
60
|
-
|
|
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
|
+
```
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
* Nodejs Support
|
|
64
|
+
## Benchmark
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
Performance Comparison: Rapid vs. Other Renderers and Game Engines
|
|
66
67
|
|
|
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>
|
|
68
74
|
|
|
69
|
-
|
|
75
|
+
<p align="center">
|
|
76
|
+
🎮 <strong><a href="https://nightre.github.io/Rapid.js/benchmark/">Run Interactive Benchmark Live →</a></strong>
|
|
77
|
+
</p>
|
|
70
78
|
|
|
71
|
-
|
|
72
|
-

|
|
79
|
+
Tested on **NVIDIA GeForce RTX 4070 Laptop GPU** (Chrome / WebGL 2.0)
|
package/dist/buffer.d.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { WebGLContext } from './webgl/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Defines the type of the underlying array buffer elements.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ArrayType {
|
|
6
|
+
Float32 = 0,
|
|
7
|
+
Uint32 = 1,
|
|
8
|
+
Uint16 = 2
|
|
9
|
+
}
|
|
10
|
+
type TypedArrayConstructor = Float32ArrayConstructor | Uint32ArrayConstructor | Uint16ArrayConstructor;
|
|
11
|
+
/**
|
|
12
|
+
* A dynamic array buffer that can grow in size automatically when elements are added.
|
|
13
|
+
* It allocates an ArrayBuffer and provides typed array views to manipulate the data.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DynamicArrayBuffer {
|
|
16
|
+
/** The number of elements currently used in the buffer. */
|
|
17
|
+
usedElemNum: number;
|
|
18
|
+
/** The main typed array view corresponding to the specified ArrayType. */
|
|
19
|
+
typedArray: Float32Array | Uint32Array | Uint16Array;
|
|
20
|
+
private arrayType;
|
|
21
|
+
/** The maximum number of elements the buffer can currently hold without resizing. */
|
|
22
|
+
protected maxElemNum: number;
|
|
23
|
+
/** The number of bytes per element based on the `ArrayType`. */
|
|
24
|
+
readonly bytePerElem: number;
|
|
25
|
+
private arraybuffer;
|
|
26
|
+
/** `Uint32Array` view of the underlying memory buffer. */
|
|
27
|
+
uint32?: Uint32Array;
|
|
28
|
+
/** `Float32Array` view of the underlying memory buffer. */
|
|
29
|
+
float32?: Float32Array;
|
|
30
|
+
/** `Uint16Array` view of the underlying memory buffer. */
|
|
31
|
+
uint16?: Uint16Array;
|
|
32
|
+
/**
|
|
33
|
+
* Initializes a new dynamic array buffer.
|
|
34
|
+
* @param arrayType - The type of elements this buffer will store primarily.
|
|
35
|
+
*/
|
|
36
|
+
constructor(arrayType: ArrayType);
|
|
37
|
+
/**
|
|
38
|
+
* Returns the typed array constructor for the corresponding `ArrayType`.
|
|
39
|
+
* @param arrayType - The type of the array.
|
|
40
|
+
* @returns The typed array constructor.
|
|
41
|
+
* @throws Dispatches an error if the specified type is unsupported.
|
|
42
|
+
*/
|
|
43
|
+
getArrayType(arrayType: ArrayType): TypedArrayConstructor;
|
|
44
|
+
/**
|
|
45
|
+
* Updates the typed array views when the internal array buffer gets reallocated.
|
|
46
|
+
*/
|
|
47
|
+
updateTypedArray(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Resets the element usage count to zero. The underlying memory capacity is preserved.
|
|
50
|
+
*/
|
|
51
|
+
clear(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if the buffer has enough space for additional elements and resizes the buffer if necessary.
|
|
54
|
+
* @param size - The number of new elements that need to be accommodated.
|
|
55
|
+
* @returns `true` if the buffer was resized, `false` otherwise.
|
|
56
|
+
*/
|
|
57
|
+
resize(size?: number): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Reallocates the underlying array buffer to a new size and copies existing data.
|
|
60
|
+
* @param size - The new maximum number of elements.
|
|
61
|
+
*/
|
|
62
|
+
protected setMaxSize(size?: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Appends a new 32-bit unsigned integer element to the buffer.
|
|
65
|
+
* @param value - The item to add.
|
|
66
|
+
*/
|
|
67
|
+
pushUint32(value: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Appends a new 32-bit floating point element to the buffer.
|
|
70
|
+
* @param value - The item to add.
|
|
71
|
+
*/
|
|
72
|
+
pushFloat32(value: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* Appends an element to the buffer, using the primary typed array view.
|
|
75
|
+
* @param value - The item to add.
|
|
76
|
+
*/
|
|
77
|
+
push(value: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Removes and returns the last element in the buffer.
|
|
80
|
+
* @returns The removed element or undefined if the buffer is empty.
|
|
81
|
+
*/
|
|
82
|
+
pop(): number;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the last element pushed to the buffer without removing it.
|
|
85
|
+
* @returns The last element.
|
|
86
|
+
*/
|
|
87
|
+
top(): number;
|
|
88
|
+
/**
|
|
89
|
+
* Gets the value of the element at the specified index.
|
|
90
|
+
* @param index - The index of the element to retrieve.
|
|
91
|
+
* @returns The requested element.
|
|
92
|
+
*/
|
|
93
|
+
get(index: number): number;
|
|
94
|
+
/**
|
|
95
|
+
* Returns a constrained view of the primary typed array up to the specified range.
|
|
96
|
+
* If `end` is omitted, returns the whole reallocated buffer slice.
|
|
97
|
+
* @param begin - The starting index (inclusive). Defaults to 0.
|
|
98
|
+
* @param end - The ending index (exclusive). Optional.
|
|
99
|
+
* @returns A subarray corresponding to the specified range.
|
|
100
|
+
*/
|
|
101
|
+
getArray(begin?: number, end?: number): Float32Array | Uint32Array | Uint16Array;
|
|
102
|
+
/**
|
|
103
|
+
* The number of elements currently stored in the buffer.
|
|
104
|
+
*/
|
|
105
|
+
get length(): number;
|
|
106
|
+
/**
|
|
107
|
+
* Resets the buffer's used element count, effectively emptying it.
|
|
108
|
+
* Same behavior as `clear`.
|
|
109
|
+
*/
|
|
110
|
+
reset(): void;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A specialized dynamic buffer intended for WebGL operations.
|
|
114
|
+
*/
|
|
115
|
+
export declare class WebglBufferArray extends DynamicArrayBuffer {
|
|
116
|
+
/** The actual WebGLBuffer object maintained by this instance. */
|
|
117
|
+
buffer: WebGLBuffer;
|
|
118
|
+
/** The related WebGL rendering context. */
|
|
119
|
+
gl: WebGLContext;
|
|
120
|
+
/** Signifies whether the buffer has been updated and requires resyncing to the GPU. */
|
|
121
|
+
protected dirty: boolean;
|
|
122
|
+
/** The WebGL buffer type, e.g., gl.ARRAY_BUFFER. */
|
|
123
|
+
readonly type: number;
|
|
124
|
+
/** Size of the allocated buffer block on the GPU side, bounded in elements count. */
|
|
125
|
+
private webglBufferSize;
|
|
126
|
+
/** Usage hint for WebGL, e.g., gl.DYNAMIC_DRAW. */
|
|
127
|
+
readonly usage: number;
|
|
128
|
+
/**
|
|
129
|
+
* Initializes a new WebGL dynamic buffer.
|
|
130
|
+
* @param gl - The active WebGL rendering context state.
|
|
131
|
+
* @param arrayType - Type of the underlying data elements to bind.
|
|
132
|
+
* @param type - Determines the type of WebGLBuffer (defaults to gl.ARRAY_BUFFER).
|
|
133
|
+
* @param usage - Determines the data usage pattern (defaults to gl.DYNAMIC_DRAW).
|
|
134
|
+
*/
|
|
135
|
+
constructor(gl: WebGLContext, arrayType: ArrayType, type?: number, usage?: number);
|
|
136
|
+
/**
|
|
137
|
+
* Flags the buffer as dirty, marking it for future data synchronization.
|
|
138
|
+
*/
|
|
139
|
+
makeDirty(): void;
|
|
140
|
+
/**
|
|
141
|
+
* Clears CPU side data usage and marks buffer as synced to stop needless updates.
|
|
142
|
+
*/
|
|
143
|
+
clear(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Binds this buffer object tracking it as the current bound buffer to the GPU.
|
|
146
|
+
*/
|
|
147
|
+
bindBuffer(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Uploads the local buffer data to the GPU memory synchronously.
|
|
150
|
+
*/
|
|
151
|
+
bufferData(): void;
|
|
152
|
+
}
|
|
153
|
+
export {};
|
package/dist/color.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export declare class Color {
|
|
2
|
+
private _r;
|
|
3
|
+
private _g;
|
|
4
|
+
private _b;
|
|
5
|
+
private _a;
|
|
6
|
+
uint32: number;
|
|
7
|
+
premultipliedUint32: number;
|
|
8
|
+
private static clampByte;
|
|
9
|
+
/**
|
|
10
|
+
* Creates an instance of Color.
|
|
11
|
+
* @param r - The red component (0-255).
|
|
12
|
+
* @param g - The green component (0-255).
|
|
13
|
+
* @param b - The blue component (0-255).
|
|
14
|
+
* @param a - The alpha component (0-255).
|
|
15
|
+
*/
|
|
16
|
+
constructor(r: number, g: number, b: number, a?: number);
|
|
17
|
+
setClearColor(gl: WebGL2RenderingContext): void;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the red component.
|
|
20
|
+
*/
|
|
21
|
+
get r(): number;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the red component and updates the uint32 representation.
|
|
24
|
+
* @param value - The new red component (0-255).
|
|
25
|
+
*/
|
|
26
|
+
set r(value: number);
|
|
27
|
+
/**
|
|
28
|
+
* Gets the green component.
|
|
29
|
+
*/
|
|
30
|
+
get g(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the green component and updates the uint32 representation.
|
|
33
|
+
* @param value - The new green component (0-255).
|
|
34
|
+
*/
|
|
35
|
+
set g(value: number);
|
|
36
|
+
/**
|
|
37
|
+
* Gets the blue component.
|
|
38
|
+
*/
|
|
39
|
+
get b(): number;
|
|
40
|
+
/**
|
|
41
|
+
* Sets the blue component and updates the uint32 representation.
|
|
42
|
+
* @param value - The new blue component (0-255).
|
|
43
|
+
*/
|
|
44
|
+
set b(value: number);
|
|
45
|
+
/**
|
|
46
|
+
* Gets the alpha component.
|
|
47
|
+
*/
|
|
48
|
+
get a(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the alpha component and updates the uint32 representation.
|
|
51
|
+
* @param value - The new alpha component (0-255).
|
|
52
|
+
*/
|
|
53
|
+
set a(value: number);
|
|
54
|
+
/**
|
|
55
|
+
* Updates the uint32 representation of the color.
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
private updateUint;
|
|
59
|
+
reset(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Sets the RGBA values of the color and updates the uint32 representation.
|
|
62
|
+
* @param r - The red component (0-255).
|
|
63
|
+
* @param g - The green component (0-255).
|
|
64
|
+
* @param b - The blue component (0-255).
|
|
65
|
+
* @param a - The alpha component (0-255).
|
|
66
|
+
*/
|
|
67
|
+
setRGBA(r: number, g: number, b: number, a: number): void;
|
|
68
|
+
setHSL(h: number, s: number, l: number): Color;
|
|
69
|
+
toHex(): string;
|
|
70
|
+
/**
|
|
71
|
+
* Copies the RGBA values from another color.
|
|
72
|
+
* @param color - The color to copy from.
|
|
73
|
+
*/
|
|
74
|
+
copy(color: Color): void;
|
|
75
|
+
/**
|
|
76
|
+
* Clone the current color
|
|
77
|
+
* @returns A new `Color` instance with the same RGBA values.
|
|
78
|
+
*/
|
|
79
|
+
clone(): Color;
|
|
80
|
+
/**
|
|
81
|
+
* Converts the color to a hexadecimal string representation (e.g., '#RRGGBBAA').
|
|
82
|
+
* @param includeAlpha - Whether to include the alpha channel in the hex string.
|
|
83
|
+
* @returns The hexadecimal string representation of the color.
|
|
84
|
+
*/
|
|
85
|
+
toHexString(includeAlpha?: boolean): string;
|
|
86
|
+
/**
|
|
87
|
+
* Checks if the current color is equal to another color.
|
|
88
|
+
* @param color - The color to compare with.
|
|
89
|
+
* @returns True if the colors are equal, otherwise false.
|
|
90
|
+
*/
|
|
91
|
+
equal(color: Color): boolean;
|
|
92
|
+
equals(color: Color): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a Color instance from normalized float components (0–1 range).
|
|
95
|
+
* Use this instead of `new Color()` when working with shader-style 0.0–1.0 values.
|
|
96
|
+
* @param r - Red channel (0.0–1.0)
|
|
97
|
+
* @param g - Green channel (0.0–1.0)
|
|
98
|
+
* @param b - Blue channel (0.0–1.0)
|
|
99
|
+
* @param a - Alpha channel (0.0–1.0), defaults to 1.0
|
|
100
|
+
* @returns A new Color instance with components scaled to 0–255.
|
|
101
|
+
* @example
|
|
102
|
+
* Color.fromNorm(0.9, 0.87, 0.55, 0.1) // moon glow
|
|
103
|
+
*/
|
|
104
|
+
static FromHSL(h: number, s: number, l: number): Color;
|
|
105
|
+
static FromRGB(r: number, g: number, b: number): Color;
|
|
106
|
+
static fromNorm(r: number, g: number, b: number, a?: number): Color;
|
|
107
|
+
/**
|
|
108
|
+
* Creates a Color instance from a hexadecimal color string.
|
|
109
|
+
* @param hexString - The hexadecimal color string, e.g., '#RRGGBB' or '#RRGGBBAA'.
|
|
110
|
+
* @returns A new Color instance.
|
|
111
|
+
*/
|
|
112
|
+
static fromHex(hexString: string): Color;
|
|
113
|
+
/**
|
|
114
|
+
* Adds the components of another color to this color, clamping the result to 255.
|
|
115
|
+
* @param color - The color to add.
|
|
116
|
+
* @returns A new Color instance with the result of the addition.
|
|
117
|
+
*/
|
|
118
|
+
add(color: Color): Color;
|
|
119
|
+
/**
|
|
120
|
+
* Subtracts the components of another color from this color, clamping the result to 0.
|
|
121
|
+
* @param color - The color to subtract.
|
|
122
|
+
* @returns A new Color instance with the result of the subtraction.
|
|
123
|
+
*/
|
|
124
|
+
subtract(color: Color): Color;
|
|
125
|
+
divide(color: Color | number): Color;
|
|
126
|
+
multiply(color: Color | number): Color;
|
|
127
|
+
clamp(): void;
|
|
128
|
+
static Red: Color;
|
|
129
|
+
static Green: Color;
|
|
130
|
+
static Blue: Color;
|
|
131
|
+
static Yellow: Color;
|
|
132
|
+
static Purple: Color;
|
|
133
|
+
static Orange: Color;
|
|
134
|
+
static Pink: Color;
|
|
135
|
+
static Gray: Color;
|
|
136
|
+
static Brown: Color;
|
|
137
|
+
static Cyan: Color;
|
|
138
|
+
static Magenta: Color;
|
|
139
|
+
static Lime: Color;
|
|
140
|
+
static White: Color;
|
|
141
|
+
static Black: Color;
|
|
142
|
+
static Transparent: Color;
|
|
143
|
+
static TRANSPARENT: Color;
|
|
144
|
+
}
|
package/dist/draw.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Color } from './color';
|
|
2
|
+
import { ITransformOptions } from './matrix-engine';
|
|
3
|
+
import { Vec2 } from './math';
|
|
4
|
+
import { Texture } from './texture';
|
|
5
|
+
import { default as GLShader, CustomGlShader } from './webgl/glshader';
|
|
6
|
+
import { ILineRenderOptions } from './line';
|
|
7
|
+
import { Rapid } from './render';
|
|
8
|
+
export type DrawShader = GLShader | CustomGlShader;
|
|
9
|
+
export type DrawPoint = Vec2 | {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
export interface IDrawOptions extends ITransformOptions {
|
|
14
|
+
shader?: DrawShader;
|
|
15
|
+
customMatrix?: number;
|
|
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
|
+
}
|
|
45
|
+
export interface ISpriteOptions extends IDrawOptions {
|
|
46
|
+
texture: Texture;
|
|
47
|
+
color?: Color;
|
|
48
|
+
flipX?: boolean;
|
|
49
|
+
flipY?: boolean;
|
|
50
|
+
padding?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface IGraphicOptions extends IDrawOptions {
|
|
53
|
+
points: DrawPoint[];
|
|
54
|
+
color?: Color | Color[];
|
|
55
|
+
drawMode?: number;
|
|
56
|
+
uv?: DrawPoint[];
|
|
57
|
+
texture?: Texture;
|
|
58
|
+
}
|
|
59
|
+
export interface IMaskImageOptions extends IDrawOptions {
|
|
60
|
+
texture: Texture;
|
|
61
|
+
}
|
|
62
|
+
export interface ILineOptions extends ILineRenderOptions, IDrawOptions {
|
|
63
|
+
}
|
|
64
|
+
export interface IRectOptions extends IDrawOptions {
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
color?: Color;
|
|
68
|
+
texture?: Texture;
|
|
69
|
+
}
|
|
70
|
+
export interface ICircleOptions extends IDrawOptions {
|
|
71
|
+
radius: number;
|
|
72
|
+
color?: Color;
|
|
73
|
+
segments?: number;
|
|
74
|
+
}
|
|
75
|
+
export declare const drawSpriteRaw: (rapid: Rapid, options: ISpriteOptions) => void;
|
|
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;
|
|
79
|
+
export declare const drawGraphic: (rapid: Rapid, options: IGraphicOptions) => void;
|
|
80
|
+
export declare const drawLine: (rapid: Rapid, options: ILineOptions) => void;
|
|
81
|
+
export declare const drawMaskImage: (rapid: Rapid, options: IMaskImageOptions) => void;
|
|
82
|
+
export declare const drawRect: (rapid: Rapid, options: IRectOptions) => void;
|
|
83
|
+
export declare const drawCircle: (rapid: Rapid, options: ICircleOptions) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from
|
|
11
|
-
export * from
|
|
1
|
+
export * from './buffer';
|
|
2
|
+
export * from './color';
|
|
3
|
+
export * from './matrix-engine';
|
|
4
|
+
export * from './render';
|
|
5
|
+
export * from './draw';
|
|
6
|
+
export * from './texture';
|
|
7
|
+
export * from './webgl/glshader';
|
|
8
|
+
export * from './region/region';
|
|
9
|
+
export * from './region/spriteRegion';
|
|
10
|
+
export * from './region/graphicRegion';
|
|
11
|
+
export * from './math';
|
|
12
|
+
export * from './particle';
|
|
13
|
+
export { LineTextureMode, type ILineRenderOptions } from './line';
|
package/dist/line.d.ts
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Vec2 } from
|
|
1
|
+
import { Color } from './color';
|
|
2
|
+
import { Vec2 } from './math';
|
|
3
|
+
import { Texture } from './texture';
|
|
4
|
+
export declare enum LineTextureMode {
|
|
5
|
+
STRETCH = 0,
|
|
6
|
+
REPEAT = 1
|
|
7
|
+
}
|
|
8
|
+
export interface ILineRenderOptions {
|
|
9
|
+
points: Vec2[];
|
|
10
|
+
width?: number;
|
|
11
|
+
closed?: boolean;
|
|
12
|
+
roundCap?: boolean;
|
|
13
|
+
textureMode?: LineTextureMode;
|
|
14
|
+
texture?: Texture;
|
|
15
|
+
color?: Color;
|
|
16
|
+
}
|
|
3
17
|
/**
|
|
4
18
|
* @ignore
|
|
5
19
|
*/
|