modern-canvas 0.8.6 → 0.8.7
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 +11 -14
- package/dist/index.js +9 -9
- package/dist/index.mjs +11 -14
- 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 {
|