tela.js 1.2.5 → 1.2.6
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 +2 -1
- package/package.json +2 -3
- package/src/Color/Color.js +8 -6
- package/src/Tela/Tela.js +12 -0
- package/src/Utils/Fonts.js +1 -0
package/README.md
CHANGED
|
@@ -151,7 +151,8 @@ You can find more examples of usage in:
|
|
|
151
151
|
- Serialize meshes not only triangles
|
|
152
152
|
- Optimize data serialization in parallel ray tracer
|
|
153
153
|
- Refactor geometric objects to have shader function
|
|
154
|
-
- Refactor parallel raytracing to parallel canvas map
|
|
154
|
+
- Refactor parallel raytracing to be just parallel canvas map
|
|
155
|
+
- Add Phong shading to raster graphics
|
|
155
156
|
- Read glb and gltf files
|
|
156
157
|
|
|
157
158
|
- Add lorentz attractors demo
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tela.js",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"author": "Pedroth",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"module": "./src/index.js",
|
|
10
10
|
"files": [
|
|
11
|
-
"src/"
|
|
12
|
-
"dist/"
|
|
11
|
+
"src/"
|
|
13
12
|
],
|
|
14
13
|
"dependencies": {
|
|
15
14
|
"@kmamal/sdl": "^0.10.2",
|
package/src/Color/Color.js
CHANGED
|
@@ -100,14 +100,16 @@ export default class Color {
|
|
|
100
100
|
return Color.ofRGB(r(), r(), r());
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
static RED = Color.ofRGB(1, 0, 0);
|
|
104
|
-
static GREEN = Color.ofRGB(0, 1, 0);
|
|
105
|
-
static BLUE = Color.ofRGB(0, 0, 1);
|
|
106
103
|
static BLACK = Color.ofRGB(0, 0, 0);
|
|
104
|
+
static BLUE = Color.ofRGB(0, 0, 1);
|
|
105
|
+
static GREEN = Color.ofRGB(0, 1, 0);
|
|
106
|
+
static CYAN = Color.ofRGB(0, 1, 1);
|
|
107
|
+
static RED = Color.ofRGB(1, 0, 0);
|
|
108
|
+
static PURPLE = Color.ofRGB(0.9, 0, 0.9);
|
|
109
|
+
static MAGENTA = Color.ofRGB(1, 0, 1);
|
|
110
|
+
static YELLOW = Color.ofRGB(1, 1, 0);
|
|
111
|
+
static ORANGE = Color.ofRGB(1, 0.8, 0);
|
|
107
112
|
static WHITE = Color.ofRGB(1, 1, 1);
|
|
108
113
|
static GRAY = Color.ofRGB(0.5, 0.5, 0.5);
|
|
109
114
|
static GREY = Color.ofRGB(0.5, 0.5, 0.5);
|
|
110
|
-
static PURPLE = Color.ofRGB(1, 0, 1);
|
|
111
|
-
static YELLOW = Color.ofRGB(1, 1, 0);
|
|
112
|
-
static CYAN = Color.ofRGB(0, 1, 1);
|
|
113
115
|
}
|
package/src/Tela/Tela.js
CHANGED
|
@@ -185,6 +185,18 @@ export default class Tela {
|
|
|
185
185
|
// end of chatGPT
|
|
186
186
|
ans.width = this.width;
|
|
187
187
|
ans.height = this.height;
|
|
188
|
+
ans.fill = color => {
|
|
189
|
+
const n = this.image.length;
|
|
190
|
+
if (!color) return;
|
|
191
|
+
for (let k = 0; k < n; k += 4) {
|
|
192
|
+
this.image[k] = this.image[k] + (color.red - this.image[k]) / it;
|
|
193
|
+
this.image[k + 1] = this.image[k + 1] + (color.green - this.image[k + 1]) / it;
|
|
194
|
+
this.image[k + 2] = this.image[k + 2] + (color.blue - this.image[k + 2]) / it;
|
|
195
|
+
this.image[k + 3] = this.image[k + 3] + (color.alpha - this.image[k + 3]) / it;
|
|
196
|
+
}
|
|
197
|
+
if (it < time) it++
|
|
198
|
+
return this;
|
|
199
|
+
}
|
|
188
200
|
ans.map = (lambda) => {
|
|
189
201
|
const n = this.image.length;
|
|
190
202
|
const w = this.width;
|
package/src/Utils/Fonts.js
CHANGED
|
@@ -14,6 +14,7 @@ try {
|
|
|
14
14
|
const TELA = await import(IS_NODE ? "../Tela/Image.js" : "../Tela/Canvas.js").then(def => def.default)
|
|
15
15
|
// octaviogood fonts documentation: https://www.shadertoy.com/view/llcXRl
|
|
16
16
|
fontImage = await or(
|
|
17
|
+
() => TELA.ofUrl(`../src/Utils/sdf_font.png`),
|
|
17
18
|
() => TELA.ofUrl(`./src/Utils/sdf_font.png`),
|
|
18
19
|
() => TELA.ofUrl(`./node_modules/tela.js/src/Utils/sdf_font.png`)
|
|
19
20
|
);
|