modern-canvas 0.8.6 → 0.8.8
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/dist/index.cjs +33 -26
- package/dist/index.js +10 -10
- package/dist/index.mjs +33 -26
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5131,20 +5131,17 @@ class GradientTexture extends Texture2D {
|
|
|
5131
5131
|
const h = height;
|
|
5132
5132
|
const cx = w / 2;
|
|
5133
5133
|
const cy = h / 2;
|
|
5134
|
-
const
|
|
5135
|
-
const
|
|
5136
|
-
const
|
|
5137
|
-
const
|
|
5138
|
-
const
|
|
5139
|
-
const
|
|
5140
|
-
const
|
|
5141
|
-
const
|
|
5142
|
-
const
|
|
5143
|
-
const
|
|
5144
|
-
|
|
5145
|
-
gradient.addColorStop(stop.offset, stop.color);
|
|
5146
|
-
});
|
|
5147
|
-
ctx.fillStyle = gradient;
|
|
5134
|
+
const A = (angle + 90) * Math.PI / 180;
|
|
5135
|
+
const dx = Math.sin(A);
|
|
5136
|
+
const dy = -Math.cos(A);
|
|
5137
|
+
const L = Math.abs(w * Math.sin(A)) + Math.abs(h * Math.cos(A));
|
|
5138
|
+
const x0 = cx - dx * (L / 2);
|
|
5139
|
+
const y0 = cy - dy * (L / 2);
|
|
5140
|
+
const x1 = cx + dx * (L / 2);
|
|
5141
|
+
const y1 = cy + dy * (L / 2);
|
|
5142
|
+
const g = ctx.createLinearGradient(x0, y0, x1, y1);
|
|
5143
|
+
for (const s of stops) g.addColorStop(s.offset, s.color);
|
|
5144
|
+
ctx.fillStyle = g;
|
|
5148
5145
|
ctx.fillRect(0, 0, w, h);
|
|
5149
5146
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
5150
5147
|
return {
|
|
@@ -14431,21 +14428,31 @@ class Engine extends SceneTree {
|
|
|
14431
14428
|
const canvas1 = document.createElement("canvas");
|
|
14432
14429
|
canvas1.width = imageData.width;
|
|
14433
14430
|
canvas1.height = imageData.height;
|
|
14434
|
-
canvas1.getContext("2d")
|
|
14431
|
+
const ctx1 = canvas1.getContext("2d");
|
|
14432
|
+
if (ctx1) {
|
|
14433
|
+
ctx1.fillStyle = "rgba(0, 0, 0, 0)";
|
|
14434
|
+
ctx1.clearRect(0, 0, canvas1.width, canvas1.height);
|
|
14435
|
+
ctx1.putImageData(imageData, 0, 0);
|
|
14436
|
+
}
|
|
14435
14437
|
const canvas2 = document.createElement("canvas");
|
|
14436
14438
|
canvas2.width = this.width;
|
|
14437
14439
|
canvas2.height = this.height;
|
|
14438
|
-
canvas2.getContext("2d")
|
|
14439
|
-
|
|
14440
|
-
0,
|
|
14441
|
-
0,
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14440
|
+
const ctx2 = canvas2.getContext("2d");
|
|
14441
|
+
if (ctx2) {
|
|
14442
|
+
ctx2.fillStyle = "rgba(0, 0, 0, 0)";
|
|
14443
|
+
ctx2.clearRect(0, 0, canvas2.width, canvas2.height);
|
|
14444
|
+
ctx2.drawImage(
|
|
14445
|
+
canvas1,
|
|
14446
|
+
0,
|
|
14447
|
+
0,
|
|
14448
|
+
canvas1.width,
|
|
14449
|
+
canvas1.height,
|
|
14450
|
+
0,
|
|
14451
|
+
0,
|
|
14452
|
+
canvas2.width,
|
|
14453
|
+
canvas2.height
|
|
14454
|
+
);
|
|
14455
|
+
}
|
|
14449
14456
|
return canvas2;
|
|
14450
14457
|
}
|
|
14451
14458
|
}
|