tela.js 1.2.20 → 1.2.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tela.js",
3
- "version": "1.2.20",
3
+ "version": "1.2.22",
4
4
  "author": "Pedroth",
5
5
  "repository": {
6
6
  "type": "git",
@@ -74,7 +74,10 @@ export default class Camera2D {
74
74
 
75
75
  toWorldCoord(x, canvas) {
76
76
  const size = Vec2(canvas.width, canvas.height);
77
- return x.div(size).mul(this.box.diagonal)
77
+ return Vec2(
78
+ (x.x / size.x) * this.box.diagonal.x + this.box.min.x,
79
+ (x.y / size.y) * this.box.diagonal.y + this.box.min.y
80
+ );
78
81
  }
79
82
 
80
83
  static deserialize(json) {
@@ -125,7 +128,7 @@ function rasterTriangle(triangle, camera, canvas) {
125
128
  const alpha = - (v.x * p.y - v.y * p.x) * invDet;
126
129
  const beta = (u.x * p.y - u.y * p.x) * invDet;
127
130
  const gamma = 1 - alpha - beta;
128
-
131
+
129
132
  // compute color
130
133
  let c = Color.ofRGB(
131
134
  c1[0] * gamma + c2[0] * alpha + c3[0] * beta,
@@ -1,7 +1,6 @@
1
1
 
2
2
  import Vec from "../Vector/Vector.js";
3
3
  import { argmin, hashStr } from "../Utils/Utils.js";
4
- import Box from "../Geometry/Box.js";
5
4
 
6
5
  export default class NaiveScene {
7
6
  constructor() {
@@ -16,7 +16,8 @@ try {
16
16
  fontImage = await or(
17
17
  () => TELA.ofUrl(`../src/Utils/sdf_font.png`),
18
18
  () => TELA.ofUrl(`./src/Utils/sdf_font.png`),
19
- () => TELA.ofUrl(`./node_modules/tela.js/src/Utils/sdf_font.png`)
19
+ () => TELA.ofUrl(`./node_modules/tela.js/src/Utils/sdf_font.png`),
20
+ () => TELA.ofUrl(`https://cdn.jsdelivr.net/npm/tela.js/src/Utils/sdf_font.png`)
20
21
  );
21
22
  fontImageWidth = fontImage.width;
22
23
  fontImageHeight = fontImage.height;