Browse Source

Merge pull request #11020 from AvaloniaUI/fixes/direction-degrees

DropShadowEffect Direction is in degrees, not radians
pull/11024/head
Nikita Tsukanov 4 years ago
committed by GitHub
parent
commit
1188a189a0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/Avalonia.Base/Media/Effects/DropShadowEffect.cs
  2. 4
      src/Avalonia.Base/Media/Effects/IDropShadowEffect.cs

6
src/Avalonia.Base/Media/Effects/DropShadowEffect.cs

@ -18,7 +18,7 @@ public abstract class DropShadowEffectBase : Effect
}
public static readonly StyledProperty<Color> ColorProperty = AvaloniaProperty.Register<DropShadowEffectBase, Color>(
nameof(Color));
nameof(Color), Colors.Black);
public Color Color
{
@ -97,8 +97,8 @@ public class DropShadowDirectionEffect : DropShadowEffectBase, IDirectionDropSha
set => SetValue(DirectionProperty, value);
}
public double OffsetX => Math.Cos(Direction) * ShadowDepth;
public double OffsetY => Math.Sin(Direction) * ShadowDepth;
public double OffsetX => Math.Cos(Direction * Math.PI / 180) * ShadowDepth;
public double OffsetY => Math.Sin(Direction * Math.PI / 180) * ShadowDepth;
public IImmutableEffect ToImmutable() => new ImmutableDropShadowDirectionEffect(OffsetX, OffsetY, BlurRadius, Color, Opacity);
}

4
src/Avalonia.Base/Media/Effects/IDropShadowEffect.cs

@ -67,8 +67,8 @@ public class ImmutableDropShadowDirectionEffect : IDirectionDropShadowEffect, II
Opacity = opacity;
}
public double OffsetX => Math.Cos(Direction) * ShadowDepth;
public double OffsetY => Math.Sin(Direction) * ShadowDepth;
public double OffsetX => Math.Cos(Direction * Math.PI / 180) * ShadowDepth;
public double OffsetY => Math.Sin(Direction * Math.PI / 180) * ShadowDepth;
public double Direction { get; }
public double ShadowDepth { get; }
public double BlurRadius { get; }

Loading…
Cancel
Save