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.mjs
CHANGED
|
@@ -5125,20 +5125,17 @@ class GradientTexture extends Texture2D {
|
|
|
5125
5125
|
const h = height;
|
|
5126
5126
|
const cx = w / 2;
|
|
5127
5127
|
const cy = h / 2;
|
|
5128
|
-
const
|
|
5129
|
-
const
|
|
5130
|
-
const
|
|
5131
|
-
const
|
|
5132
|
-
const
|
|
5133
|
-
const
|
|
5134
|
-
const
|
|
5135
|
-
const
|
|
5136
|
-
const
|
|
5137
|
-
const
|
|
5138
|
-
|
|
5139
|
-
gradient.addColorStop(stop.offset, stop.color);
|
|
5140
|
-
});
|
|
5141
|
-
ctx.fillStyle = gradient;
|
|
5128
|
+
const A = (angle + 90) * Math.PI / 180;
|
|
5129
|
+
const dx = Math.sin(A);
|
|
5130
|
+
const dy = -Math.cos(A);
|
|
5131
|
+
const L = Math.abs(w * Math.sin(A)) + Math.abs(h * Math.cos(A));
|
|
5132
|
+
const x0 = cx - dx * (L / 2);
|
|
5133
|
+
const y0 = cy - dy * (L / 2);
|
|
5134
|
+
const x1 = cx + dx * (L / 2);
|
|
5135
|
+
const y1 = cy + dy * (L / 2);
|
|
5136
|
+
const g = ctx.createLinearGradient(x0, y0, x1, y1);
|
|
5137
|
+
for (const s of stops) g.addColorStop(s.offset, s.color);
|
|
5138
|
+
ctx.fillStyle = g;
|
|
5142
5139
|
ctx.fillRect(0, 0, w, h);
|
|
5143
5140
|
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
5144
5141
|
return {
|
|
@@ -14425,21 +14422,31 @@ class Engine extends SceneTree {
|
|
|
14425
14422
|
const canvas1 = document.createElement("canvas");
|
|
14426
14423
|
canvas1.width = imageData.width;
|
|
14427
14424
|
canvas1.height = imageData.height;
|
|
14428
|
-
canvas1.getContext("2d")
|
|
14425
|
+
const ctx1 = canvas1.getContext("2d");
|
|
14426
|
+
if (ctx1) {
|
|
14427
|
+
ctx1.fillStyle = "rgba(0, 0, 0, 0)";
|
|
14428
|
+
ctx1.clearRect(0, 0, canvas1.width, canvas1.height);
|
|
14429
|
+
ctx1.putImageData(imageData, 0, 0);
|
|
14430
|
+
}
|
|
14429
14431
|
const canvas2 = document.createElement("canvas");
|
|
14430
14432
|
canvas2.width = this.width;
|
|
14431
14433
|
canvas2.height = this.height;
|
|
14432
|
-
canvas2.getContext("2d")
|
|
14433
|
-
|
|
14434
|
-
0,
|
|
14435
|
-
0,
|
|
14436
|
-
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14434
|
+
const ctx2 = canvas2.getContext("2d");
|
|
14435
|
+
if (ctx2) {
|
|
14436
|
+
ctx2.fillStyle = "rgba(0, 0, 0, 0)";
|
|
14437
|
+
ctx2.clearRect(0, 0, canvas2.width, canvas2.height);
|
|
14438
|
+
ctx2.drawImage(
|
|
14439
|
+
canvas1,
|
|
14440
|
+
0,
|
|
14441
|
+
0,
|
|
14442
|
+
canvas1.width,
|
|
14443
|
+
canvas1.height,
|
|
14444
|
+
0,
|
|
14445
|
+
0,
|
|
14446
|
+
canvas2.width,
|
|
14447
|
+
canvas2.height
|
|
14448
|
+
);
|
|
14449
|
+
}
|
|
14443
14450
|
return canvas2;
|
|
14444
14451
|
}
|
|
14445
14452
|
}
|