Exemplo n.º 1
0
		internal static SvgTransform CreateRotate(SvgAngle angle, float cx, float cy)
		{
			var rad = angle.ValueAsRadian;
			var cos = Math.Cos(rad);
			var sin = Math.Sin(rad);
			return new SvgTransform(SvgTransformType.Rotate, new SvgMatrix(cos, sin, -sin, cos, -cx * cos + cy * sin + cx, -cx * sin - cy * cos + cy));
		}
Exemplo n.º 2
0
		internal static SvgTransform CreateRotate(SvgAngle angle)
		{
			var rad = angle.ValueAsRadian;
			var cos = Math.Cos(rad);
			var sin = Math.Sin(rad);
			return new SvgTransform(SvgTransformType.Rotate, new SvgMatrix(cos, sin, -sin, cos, 0.0, 0.0));
		}
Exemplo n.º 3
0
 public void TestRadValues()
 {
     angle = new SvgAngle("2rad", null, false);
     Assert.AreEqual(2 * 180 / Math.PI, angle.Value);
     Assert.AreEqual(2, angle.ValueInSpecifiedUnits);
     Assert.AreEqual("2rad", angle.ValueAsString);
     Assert.AreEqual(SvgAngleType.Rad, angle.UnitType);
 }
Exemplo n.º 4
0
 public void TestGradValues()
 {
     angle = new SvgAngle("200grad", null, false);
     Assert.AreEqual(180, angle.Value);
     Assert.AreEqual(200, angle.ValueInSpecifiedUnits);
     Assert.AreEqual("200grad", angle.ValueAsString);
     Assert.AreEqual(SvgAngleType.Grad, angle.UnitType);
 }
Exemplo n.º 5
0
 public void TestDegValues()
 {
     angle = new SvgAngle("90deg", null, false);
     Assert.AreEqual(90, angle.Value);
     Assert.AreEqual(90, angle.ValueInSpecifiedUnits);
     Assert.AreEqual("90deg", angle.ValueAsString);
     Assert.AreEqual(SvgAngleType.Deg, angle.UnitType);
 }
Exemplo n.º 6
0
        public void TestSettingValues()
        {
            angle = new SvgAngle("100grad", null, false);
            Assert.AreEqual(90, angle.Value);

            angle.Value = 45;
            Assert.AreEqual(45, angle.Value);
            Assert.AreEqual("50grad", angle.ValueAsString);
            Assert.AreEqual(50, angle.ValueInSpecifiedUnits);
            Assert.AreEqual(SvgAngleType.Grad, angle.UnitType);

            angle.ValueInSpecifiedUnits = 300;
            Assert.AreEqual(270, angle.Value);
            Assert.AreEqual("300grad", angle.ValueAsString);
            Assert.AreEqual(300, angle.ValueInSpecifiedUnits);
            Assert.AreEqual(SvgAngleType.Grad, angle.UnitType);

            angle.ValueAsString = "180deg";
            Assert.AreEqual(180, angle.Value);

            angle.NewValueSpecifiedUnits(SvgAngleType.Rad, Math.PI);
            Assert.AreEqual(180, angle.Value);
            Assert.AreEqual(Math.PI.ToString(SvgNumber.Format) + "rad", angle.ValueAsString);

            angle.NewValueSpecifiedUnits(SvgAngleType.Unspecified, 270);
            Assert.AreEqual(270, angle.Value);
            Assert.AreEqual("270", angle.ValueAsString);

            angle.ConvertToSpecifiedUnits(SvgAngleType.Grad);
            Assert.AreEqual(270, angle.Value);
            Assert.AreEqual(300, angle.ValueInSpecifiedUnits);
            Assert.AreEqual("300grad", angle.ValueAsString);

            // test default value
            angle = new SvgAngle("", "90deg", false);
            Assert.AreEqual(90, angle.Value);
        }
Exemplo n.º 7
0
		internal static SvgTransform CreateSkewY(SvgAngle angle) => new SvgTransform(SvgTransformType.SkewY, new SvgMatrix(1.0, Math.Tan(angle.ValueAsRadian), 0.0, 1.0, 0.0, 0.0));
Exemplo n.º 8
0
		internal SvgTransform(SvgTransformType type, SvgMatrix matrix, SvgAngle angle)
		{
			this.Type = type;
			this.Matrix = matrix;
			this.Angle = angle;
		}