13 changed files with 228 additions and 11 deletions
@ -0,0 +1,34 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="RotateTransform.cs" company="Steven Kirk">
|
|||
// Copyright 2013 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Media |
|||
{ |
|||
public class RotateTransform : Transform |
|||
{ |
|||
public static readonly PerspexProperty<double> AngleProperty = |
|||
PerspexProperty.Register<RotateTransform, double>("Angle"); |
|||
|
|||
public RotateTransform() |
|||
{ |
|||
} |
|||
|
|||
public RotateTransform(double angle) |
|||
{ |
|||
this.Angle = angle; |
|||
} |
|||
|
|||
public double Angle |
|||
{ |
|||
get { return this.GetValue(AngleProperty); } |
|||
set { this.SetValue(AngleProperty, value); } |
|||
} |
|||
|
|||
public override Matrix Value |
|||
{ |
|||
get { return Matrix.Rotation(Matrix.ToRadians(this.Angle)); } |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="Transform.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Media |
|||
{ |
|||
public abstract class Transform : PerspexObject |
|||
{ |
|||
public abstract Matrix Value { get; } |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="Origin.cs" company="Steven Kirk">
|
|||
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex |
|||
{ |
|||
using System; |
|||
using System.Globalization; |
|||
|
|||
public enum OriginUnit |
|||
{ |
|||
Percent, |
|||
Pixels, |
|||
} |
|||
|
|||
public struct Origin |
|||
{ |
|||
public static readonly Origin Default = new Origin(0.5, 0.5, OriginUnit.Percent); |
|||
|
|||
private Point point; |
|||
|
|||
private OriginUnit unit; |
|||
|
|||
public Origin(double x, double y, OriginUnit unit) |
|||
: this(new Point(x, y), unit) |
|||
{ |
|||
} |
|||
|
|||
public Origin(Point point, OriginUnit unit) |
|||
{ |
|||
this.point = point; |
|||
this.unit = unit; |
|||
} |
|||
|
|||
public Point Point |
|||
{ |
|||
get { return this.point; } |
|||
} |
|||
|
|||
public OriginUnit Unit |
|||
{ |
|||
get { return this.unit; } |
|||
} |
|||
|
|||
public Point ToPixels(Size size) |
|||
{ |
|||
return this.unit == OriginUnit.Pixels ? |
|||
point : |
|||
new Point(point.X * size.Width, point.Y * size.Height); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue