diff --git a/src/Avalonia.Visuals/Media/RotateTransform.cs b/src/Avalonia.Visuals/Media/RotateTransform.cs index 653d38eb45..126bb7c274 100644 --- a/src/Avalonia.Visuals/Media/RotateTransform.cs +++ b/src/Avalonia.Visuals/Media/RotateTransform.cs @@ -14,6 +14,18 @@ namespace Avalonia.Media public static readonly StyledProperty AngleProperty = AvaloniaProperty.Register(nameof(Angle)); + /// + /// Defines the property. + /// + public static readonly StyledProperty CenterXProperty = + AvaloniaProperty.Register(nameof(CenterX)); + + /// + /// Defines the property. + /// + public static readonly StyledProperty CenterYProperty = + AvaloniaProperty.Register(nameof(CenterY)); + /// /// Initializes a new instance of the class. /// @@ -32,18 +44,52 @@ namespace Avalonia.Media Angle = angle; } + /// + /// Initializes a new instance of the class. + /// + /// The angle, in degrees. + /// The x-coordinate of the center point for the rotation. + /// The y-coordinate of the center point for the rotation. + public RotateTransform(double angle, double centerX, double centerY) + : this() + { + Angle = angle; + CenterX = centerX; + CenterY = centerY; + } + /// /// Gets or sets the angle of rotation, in degrees. /// public double Angle { - get { return GetValue(AngleProperty); } - set { SetValue(AngleProperty, value); } + get => GetValue(AngleProperty); + set => SetValue(AngleProperty, value); + } + + /// + /// Gets or sets the x-coordinate of the rotation center point. The default is 0. + /// + public double CenterX + { + get => GetValue(CenterXProperty); + set => SetValue(CenterXProperty, value); + } + + /// + /// Gets or sets the y-coordinate of the rotation center point. The default is 0. + /// + public double CenterY + { + get => GetValue(CenterYProperty); + set => SetValue(CenterYProperty, value); } /// /// Gets the transform's . /// - public override Matrix Value => Matrix.CreateRotation(Matrix.ToRadians(Angle)); + public override Matrix Value => Matrix.CreateTranslation(-CenterX, -CenterY) * + Matrix.CreateRotation(Matrix.ToRadians(Angle)) * + Matrix.CreateTranslation(CenterX, CenterY); } }