modern-canvas 0.4.1 → 0.4.3

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 CHANGED
@@ -7690,7 +7690,8 @@ exports.MaskEffect = class MaskEffect extends exports.Effect {
7690
7690
  QuadUvGeometry.draw(renderer, exports.MaskEffect.material, {
7691
7691
  sampler: 0,
7692
7692
  mask: 1,
7693
- area: context.targetArea
7693
+ area: context.targetArea,
7694
+ rotation: context.target?.globalRotation ?? 0
7694
7695
  });
7695
7696
  renderer.texture.unbind(1);
7696
7697
  });
@@ -7710,6 +7711,20 @@ void main() {
7710
7711
  uniform sampler2D sampler;
7711
7712
  uniform sampler2D mask;
7712
7713
  uniform float area[4];
7714
+ uniform float rotation;
7715
+
7716
+ vec2 rotateUV(vec2 uv, float angle) {
7717
+ uv -= 0.5;
7718
+ float cosAngle = cos(angle);
7719
+ float sinAngle = sin(angle);
7720
+ mat2 rotationMatrix = mat2(
7721
+ cosAngle, -sinAngle,
7722
+ sinAngle, cosAngle
7723
+ );
7724
+ uv = rotationMatrix * uv;
7725
+ uv += 0.5;
7726
+ return uv;
7727
+ }
7713
7728
 
7714
7729
  void main(void) {
7715
7730
  if (
@@ -7723,7 +7738,7 @@ void main(void) {
7723
7738
  (vUv.x - area[0]) / area[2],
7724
7739
  ((1.0 - vUv.y) - area[1]) / area[3]
7725
7740
  );
7726
- vec4 maskColor = texture2D(mask, uv);
7741
+ vec4 maskColor = texture2D(mask, rotateUV(uv, rotation));
7727
7742
  gl_FragColor = mix(vec4(0.), color, maskColor.a);
7728
7743
  } else {
7729
7744
  gl_FragColor = vec4(0.);
@@ -9661,7 +9676,7 @@ exports.Image2D = class Image2D extends exports.Element2D {
9661
9676
  }
9662
9677
  }
9663
9678
  _repaint(batchables) {
9664
- return batchables.map((batchable) => {
9679
+ return super._repaint(batchables).map((batchable) => {
9665
9680
  return {
9666
9681
  ...batchable,
9667
9682
  disableWrapMode: true