SvgRotate.cs 1.43 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;
5
using System.Globalization;
davescriven's avatar
davescriven committed
6
7
8

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

        public float CenterX
        {
            get;
            set;
        }

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

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

41
42
43
44
45
        public override string WriteToString()
        {
            return string.Format(CultureInfo.InvariantCulture, "rotate({0}, {1}, {2})", this.Angle, this.CenterX, this.CenterY);
        }

davescriven's avatar
davescriven committed
46
47
        public SvgRotate(float angle)
        {
48
49
50
51
52
53
54
55
            this.Angle = angle;
        }

        public SvgRotate(float angle, float centerX, float centerY)
            : this(angle)
        {
            this.CenterX = centerX;
            this.CenterY = centerY;
davescriven's avatar
davescriven committed
56
        }
57
58
59
60
61
62


		public override object Clone()
		{
			return new SvgRotate(this.Angle, this.CenterX, this.CenterY);
		}
davescriven's avatar
davescriven committed
63
64
    }
}