rapid-render 0.1.12 β†’ 0.1.111

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 CHANGED
@@ -9,15 +9,17 @@ A highly efficient ([stress-test](https://nightre.github.io/Rapid.js/docs/exampl
9
9
 
10
10
  ## Features
11
11
 
12
- * **Fast Rendering** ⚑
13
- * **TileMap** - YSort, isometric πŸ—ΊοΈ
14
- * **Light Shadow** πŸ’‘
15
- * **Graphics Drawing** ✏️
16
- * **Text Rendering** πŸ“
17
- * **Line Drawing** - line texture 〰️
18
- * **Custom Shaders** 🎨
19
- * **Mask** 🎭
20
- * **Frame Buffer Object** πŸ–ΌοΈ
12
+ * **Fast Rendering**
13
+ * **TileMap** - YSort, isometric
14
+ * **Graphics Drawing**
15
+ * **Text Rendering**
16
+ * **Line Drawing** - line texture
17
+ * **Custom Shaders**
18
+ * **Mask**
19
+ * **Frame Buffer Object**
20
+
21
+ > [!WARNING]
22
+ > This project is a work in progress! Expect bugs, report issues, and feel free to contribute.
21
23
 
22
24
  ## Install
23
25
 
@@ -57,7 +59,7 @@ For more examples and detailed documentation, visit our [website](https://nightr
57
59
 
58
60
  ## Roadmap
59
61
 
60
- * 9-slice 🚧 (In Progress)
62
+ * Light System 🚧 (In Progress)
61
63
  * Nodejs Support
62
64
 
63
65
  ## Contributing
@@ -67,5 +69,4 @@ Issues and PRs are welcome!
67
69
  ## Screen shot
68
70
 
69
71
  ![1](./screenshot/1.gif)
70
- ![2](./screenshot/2.gif)
71
- ![3](./screenshot/3.png)
72
+ ![2](./screenshot/2.gif)
@@ -1,178 +1,165 @@
1
- import { Color, Vec2 } from "./math";
2
- import { Texture } from "./texture";
3
- import { TileSet } from "./tilemap";
4
- import GLShader from "./webgl/glshader";
5
- import { Uniform } from "./webgl/uniform";
6
- /**
7
- * @ignore
8
- */
9
- export type WebGLContext = WebGL2RenderingContext | WebGLRenderingContext;
10
- /**
11
- * @ignore
12
- */
13
- export interface IMathStruct<T> {
14
- clone(obj: T): T;
15
- copy(obj: T): void;
16
- equal(obj: T): boolean;
17
- }
18
- export interface IRapidOptions {
19
- canvas: HTMLCanvasElement;
20
- width?: number;
21
- height?: number;
22
- backgroundColor?: Color;
23
- antialias?: boolean;
24
- }
25
- export interface IAttribute {
26
- name: string;
27
- size: number;
28
- type: number;
29
- normalized?: boolean;
30
- stride: number;
31
- offset?: number;
32
- }
33
- export interface ITransformOptions {
34
- position?: Vec2;
35
- scale?: Vec2 | number;
36
- rotation?: number;
37
- offset?: Vec2;
38
- x?: number;
39
- y?: number;
40
- offsetX?: number;
41
- offsetY?: number;
42
- origin?: Vec2 | number;
43
- restoreTransform?: boolean;
44
- saveTransform?: boolean;
45
- afterSave?(): unknown;
46
- beforRestore?(): unknown;
47
- }
48
- export interface ISpriteRenderOptions extends ITransformOptions, IShaderRenderOptions {
49
- color?: Color;
50
- texture?: Texture;
51
- offset?: Vec2;
52
- flipX?: boolean;
53
- flipY?: boolean;
54
- }
55
- export interface ITextTextureOptions {
56
- /**
57
- * The text string to be rendered.
58
- */
59
- text?: string;
60
- /**
61
- * The font size for the text.
62
- * Default is 16.
63
- */
64
- fontSize?: number;
65
- /**
66
- * The font family for the text.
67
- * Default is 'Arial'.
68
- */
69
- fontFamily?: string;
70
- /**
71
- * The color of the text.
72
- * Default is '#000000' (black).
73
- */
74
- color?: string;
75
- /**
76
- * The alignment of the text.
77
- * Possible values: 'left', 'right', 'center', 'start', 'end'.
78
- * Default is 'left'.
79
- */
80
- textAlign?: CanvasTextAlign;
81
- /**
82
- * The baseline of the text.
83
- * Possible values: 'top', 'hanging', 'middle', 'alphabetic', 'ideographic', 'bottom'.
84
- * Default is 'top'.
85
- */
86
- textBaseline?: CanvasTextBaseline;
87
- }
88
- export interface ILineRenderOptions extends IGraphicRenderOptions {
89
- width?: number;
90
- closed?: boolean;
91
- roundCap?: boolean;
92
- textureMode?: LineTextureMode;
93
- }
94
- export declare enum LineTextureMode {
95
- STRETCH = "stretch",
96
- REPEAT = "repeat"
97
- }
98
- export declare enum TextureWrapMode {
99
- REPEAT = "repeat",
100
- CLAMP = "clamp",
101
- MIRROR = "mirror"
102
- }
103
- export interface IRenderLineOptions extends ILineRenderOptions, ITransformOptions {
104
- }
105
- export interface IGraphicRenderOptions extends ITransformOptions, IShaderRenderOptions {
106
- points: Vec2[];
107
- color?: Color | Color[];
108
- drawType?: number;
109
- uv?: Vec2[];
110
- texture?: Texture;
111
- }
112
- export interface ICircleRenderOptions extends IGraphicRenderOptions {
113
- radius: number;
114
- segments?: number;
115
- }
116
- export interface IRectRenderOptions extends IGraphicRenderOptions {
117
- width: number;
118
- height: number;
119
- }
120
- export declare enum MaskType {
121
- Include = "normal",
122
- Exclude = "inverse"
123
- }
124
- export type UniformType = Record<string, number | Array<any> | boolean | Texture>;
125
- export type Images = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas;
126
- export interface IRegisterTileOptions extends ISpriteRenderOptions {
127
- texture: Texture;
128
- offsetX?: number;
129
- offsetY?: number;
130
- ySortOffset?: number;
131
- }
132
- export interface YSortCallback {
133
- ySort: number;
134
- render?: () => void;
135
- renderSprite?: ISpriteRenderOptions;
136
- }
137
- export interface ILayerRenderOptions extends ITransformOptions {
138
- error?: number | Vec2;
139
- errorX?: number;
140
- errorY?: number;
141
- ySortCallback?: Array<YSortCallback>;
142
- shape?: TilemapShape;
143
- tileSet: TileSet;
144
- eachTile?: (tileId: string | number, mapX: number, mapY: number) => ISpriteRenderOptions | undefined | void;
145
- }
146
- export interface IShaderRenderOptions {
147
- shader?: GLShader;
148
- uniforms?: Uniform;
149
- }
150
- export declare enum TilemapShape {
151
- SQUARE = "square",
152
- ISOMETRIC = "isometric"
153
- }
154
- export declare enum ShaderType {
155
- SPRITE = "sprite",
156
- GRAPHIC = "graphic"
157
- }
158
- export interface IParticleEmitterOptions extends ITransformOptions, IShaderRenderOptions {
159
- texture: Texture | Texture[] | [Texture, number][];
160
- }
161
- export declare enum BlendMode {
162
- Additive = "additive",
163
- Subtractive = "subtractive",
164
- Mix = "mix"
165
- }
166
- /**
167
- * Interface for light rendering options
168
- */
169
- export interface ILightRenderOptions {
170
- /** Position of the light source */
171
- lightSource: Vec2;
172
- /** Array of vertex arrays for occlusion objects, each occlusion object is defined by a set of vertices */
173
- occlusion: Vec2[][];
174
- /** Base projection length that controls shadow length */
175
- baseProjectionLength?: number;
176
- /** Type of mask to apply */
177
- type?: MaskType;
178
- }
1
+ import { Color, Vec2 } from "./math";
2
+ import { Texture } from "./texture";
3
+ import { TileSet } from "./tilemap";
4
+ import GLShader from "./webgl/glshader";
5
+ import { Uniform } from "./webgl/uniform";
6
+ /**
7
+ * @ignore
8
+ */
9
+ export type WebGLContext = WebGL2RenderingContext | WebGLRenderingContext;
10
+ /**
11
+ * @ignore
12
+ */
13
+ export interface IMathStruct<T> {
14
+ clone(obj: T): T;
15
+ copy(obj: T): void;
16
+ equal(obj: T): boolean;
17
+ }
18
+ export interface IRapidOptions {
19
+ canvas: HTMLCanvasElement;
20
+ width?: number;
21
+ height?: number;
22
+ backgroundColor?: Color;
23
+ antialias?: boolean;
24
+ }
25
+ export interface IAttribute {
26
+ name: string;
27
+ size: number;
28
+ type: number;
29
+ normalized?: boolean;
30
+ stride: number;
31
+ offset?: number;
32
+ }
33
+ export interface ITransformOptions {
34
+ position?: Vec2;
35
+ scale?: Vec2 | number;
36
+ rotation?: number;
37
+ offset?: Vec2;
38
+ x?: number;
39
+ y?: number;
40
+ offsetX?: number;
41
+ offsetY?: number;
42
+ origin?: Vec2 | number;
43
+ restoreTransform?: boolean;
44
+ saveTransform?: boolean;
45
+ afterSave?(): unknown;
46
+ beforRestore?(): unknown;
47
+ }
48
+ export interface ISpriteRenderOptions extends ITransformOptions, IShaderRenderOptions {
49
+ color?: Color;
50
+ texture?: Texture;
51
+ offset?: Vec2;
52
+ flipX?: boolean;
53
+ flipY?: boolean;
54
+ }
55
+ export interface ITextTextureOptions {
56
+ /**
57
+ * The text string to be rendered.
58
+ */
59
+ text?: string;
60
+ /**
61
+ * The font size for the text.
62
+ * Default is 16.
63
+ */
64
+ fontSize?: number;
65
+ /**
66
+ * The font family for the text.
67
+ * Default is 'Arial'.
68
+ */
69
+ fontFamily?: string;
70
+ /**
71
+ * The color of the text.
72
+ * Default is '#000000' (black).
73
+ */
74
+ color?: string;
75
+ /**
76
+ * The alignment of the text.
77
+ * Possible values: 'left', 'right', 'center', 'start', 'end'.
78
+ * Default is 'left'.
79
+ */
80
+ textAlign?: CanvasTextAlign;
81
+ /**
82
+ * The baseline of the text.
83
+ * Possible values: 'top', 'hanging', 'middle', 'alphabetic', 'ideographic', 'bottom'.
84
+ * Default is 'top'.
85
+ */
86
+ textBaseline?: CanvasTextBaseline;
87
+ }
88
+ export interface ILineRenderOptions extends IGraphicRenderOptions {
89
+ width?: number;
90
+ closed?: boolean;
91
+ roundCap?: boolean;
92
+ textureMode?: LineTextureMode;
93
+ }
94
+ export declare enum LineTextureMode {
95
+ STRETCH = "stretch",
96
+ REPEAT = "repeat"
97
+ }
98
+ export declare enum TextureWrapMode {
99
+ REPEAT = "repeat",
100
+ CLAMP = "clamp",
101
+ MIRROR = "mirror"
102
+ }
103
+ export interface IRenderLineOptions extends ILineRenderOptions, ITransformOptions {
104
+ }
105
+ export interface IGraphicRenderOptions extends ITransformOptions, IShaderRenderOptions {
106
+ points: Vec2[];
107
+ color?: Color | Color[];
108
+ drawType?: number;
109
+ uv?: Vec2[];
110
+ texture?: Texture;
111
+ }
112
+ export interface ICircleRenderOptions extends IGraphicRenderOptions {
113
+ radius: number;
114
+ segments?: number;
115
+ }
116
+ export interface IRectRenderOptions extends IGraphicRenderOptions {
117
+ width: number;
118
+ height: number;
119
+ }
120
+ export declare enum MaskType {
121
+ Include = "normal",
122
+ Exclude = "inverse"
123
+ }
124
+ export type UniformType = Record<string, number | Array<any> | boolean | Texture>;
125
+ export type Images = ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas;
126
+ export interface IRegisterTileOptions extends ISpriteRenderOptions {
127
+ texture: Texture;
128
+ offsetX?: number;
129
+ offsetY?: number;
130
+ ySortOffset?: number;
131
+ }
132
+ export interface YSortCallback {
133
+ ySort: number;
134
+ render?: () => void;
135
+ renderSprite?: ISpriteRenderOptions;
136
+ }
137
+ export interface ILayerRenderOptions extends ITransformOptions {
138
+ error?: number | Vec2;
139
+ errorX?: number;
140
+ errorY?: number;
141
+ ySortCallback?: Array<YSortCallback>;
142
+ shape?: TilemapShape;
143
+ tileSet: TileSet;
144
+ eachTile?: (tileId: string | number, mapX: number, mapY: number) => ISpriteRenderOptions | undefined | void;
145
+ }
146
+ export interface IShaderRenderOptions {
147
+ shader?: GLShader;
148
+ uniforms?: Uniform;
149
+ }
150
+ export declare enum TilemapShape {
151
+ SQUARE = "square",
152
+ ISOMETRIC = "isometric"
153
+ }
154
+ export declare enum ShaderType {
155
+ SPRITE = "sprite",
156
+ GRAPHIC = "graphic"
157
+ }
158
+ export interface IParticleEmitterOptions extends ITransformOptions, IShaderRenderOptions {
159
+ texture: Texture | Texture[] | [Texture, number][];
160
+ }
161
+ export declare enum BlendMode {
162
+ Additive = "additive",
163
+ Subtractive = "subtractive",
164
+ Mix = "mix"
165
+ }
package/dist/light.d.ts CHANGED
@@ -1,7 +1,5 @@
1
- import { Vec2 } from "./math";
2
- import Rapid from "./render";
3
- export declare class LightManager {
4
- render: Rapid;
5
- constructor(render: Rapid);
6
- createLightShadowMaskPolygon(occlusion: Vec2[][], lightSource: Vec2, baseProjectionLength?: number): Vec2[][];
7
- }
1
+ import Rapid from "./render";
2
+ export declare class LightManager {
3
+ render: Rapid;
4
+ constructor(render: Rapid);
5
+ }