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

namespace Svg.Transforms
{
9
    public sealed class SvgScale : SvgTransform
davescriven's avatar
davescriven committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    {
        private float scaleFactorX;
        private float scaleFactorY;

        public float X
        {
            get { return this.scaleFactorX; }
            set { this.scaleFactorX = value; }
        }

        public float Y
        {
            get { return this.scaleFactorY; }
            set { this.scaleFactorY = value; }
        }

        public override System.Drawing.Drawing2D.Matrix Matrix
        {
            get
            {
Eric Domke's avatar
Eric Domke committed
30
                var matrix = new System.Drawing.Drawing2D.Matrix();
davescriven's avatar
davescriven committed
31
32
33
34
35
                matrix.Scale(this.X, this.Y);
                return matrix;
            }
        }

36
37
        public override string WriteToString()
        {
Eric Domke's avatar
Eric Domke committed
38
            if (this.X == this.Y) return string.Format(CultureInfo.InvariantCulture, "scale({0})", this.X);
39
40
41
            return string.Format(CultureInfo.InvariantCulture, "scale({0}, {1})", this.X, this.Y);
        }

davescriven's avatar
davescriven committed
42
43
44
45
46
47
48
        public SvgScale(float x) : this(x, x) { }

        public SvgScale(float x, float y)
        {
            this.scaleFactorX = x;
            this.scaleFactorY = y;
        }
49
50
51
52
53

		public override object Clone()
		{
			return new SvgScale(this.X, this.Y);
		}
davescriven's avatar
davescriven committed
54
55
    }
}