SvgRotate.cs 1.09 KB
Newer Older
davescriven's avatar
davescriven committed
1
2
3
using System;
using System.Collections.Generic;
using System.Text;
4
using System.Drawing.Drawing2D;
davescriven's avatar
davescriven committed
5
6
7

namespace Svg.Transforms
{
8
    public sealed class SvgRotate : SvgTransform
davescriven's avatar
davescriven committed
9
10
11
    {
        public float Angle
        {
12
13
14
15
16
17
18
19
20
21
22
23
24
25
            get;
            set;
        }

        public float CenterX
        {
            get;
            set;
        }

        public float CenterY
        {
            get;
            set;
davescriven's avatar
davescriven committed
26
27
        }

28
        public override Matrix Matrix
davescriven's avatar
davescriven committed
29
30
31
        {
            get
            {
32
33
                Matrix matrix = new Matrix();
                matrix.Translate(this.CenterX, this.CenterY);
davescriven's avatar
davescriven committed
34
                matrix.Rotate(this.Angle);
35
                matrix.Translate(-this.CenterX, -this.CenterY);
davescriven's avatar
davescriven committed
36
37
38
39
40
41
                return matrix;
            }
        }

        public SvgRotate(float angle)
        {
42
43
44
45
46
47
48
49
            this.Angle = angle;
        }

        public SvgRotate(float angle, float centerX, float centerY)
            : this(angle)
        {
            this.CenterX = centerX;
            this.CenterY = centerY;
davescriven's avatar
davescriven committed
50
51
52
        }
    }
}