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.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 {
|