Ejemplo n.º 1
0
        public void Test_TransformOrigin()
        {
            DrawableAffine affine = new DrawableAffine();

            affine.TransformOrigin(4.0, 2.0);

            Assert.AreEqual(1.0, affine.ScaleX);
            Assert.AreEqual(1.0, affine.ScaleY);
            Assert.AreEqual(0.0, affine.ShearX);
            Assert.AreEqual(0.0, affine.ShearY);
            Assert.AreEqual(4.0, affine.TranslateX);
            Assert.AreEqual(2.0, affine.TranslateY);
        }
Ejemplo n.º 2
0
        public void Test_TransformRatation()
        {
            DrawableAffine affine = new DrawableAffine();

            affine.TransformRotation(45.0);

            Assert.AreEqual(0.7071, affine.ScaleX, 0.0001);
            Assert.AreEqual(0.7071, affine.ScaleY, 0.0001);
            Assert.AreEqual(-0.7071, affine.ShearX, 0.0001);
            Assert.AreEqual(0.7071, affine.ShearY, 0.0001);
            Assert.AreEqual(0.0, affine.TranslateX);
            Assert.AreEqual(0.0, affine.TranslateY);
        }
Ejemplo n.º 3
0
        public void Test_Constructor_Matrix()
        {
            Matrix matrix = null;

            ExceptionAssert.Throws <ArgumentNullException>(() =>
            {
                new DrawableAffine(matrix);
            });

            matrix = new Matrix(11, 12, 21, 22, 0, 1);
            DrawableAffine affine = new DrawableAffine(matrix);

            Assert.AreEqual(11, affine.ScaleX);
            Assert.AreEqual(12, affine.ScaleY);
            Assert.AreEqual(21, affine.ShearX);
            Assert.AreEqual(22, affine.ShearY);
            Assert.AreEqual(0, affine.TranslateX);
            Assert.AreEqual(1, affine.TranslateY);
        }
Ejemplo n.º 4
0
            public void ShouldSetThePropertiesToTheDefaultValue()
            {
                var affine = new DrawableAffine();

                affine.ScaleX     = 2.0;
                affine.ScaleY     = 3.0;
                affine.ShearX     = 4.0;
                affine.ShearY     = 5.0;
                affine.TranslateX = 6.0;
                affine.TranslateY = 7.0;

                affine.Reset();

                Assert.Equal(1.0, affine.ScaleX);
                Assert.Equal(1.0, affine.ScaleY);
                Assert.Equal(0.0, affine.ShearX);
                Assert.Equal(0.0, affine.ShearY);
                Assert.Equal(0.0, affine.TranslateX);
                Assert.Equal(0.0, affine.TranslateY);
            }
Ejemplo n.º 5
0
        public void Test_TransformSkew()
        {
            DrawableAffine affine = new DrawableAffine();

            affine.TransformSkewX(4.0);

            Assert.Equal(1.0, affine.ScaleX);
            Assert.Equal(1.0, affine.ScaleY);
            Assert.InRange(affine.ShearX, 0.0699, 0.0700);
            Assert.Equal(0.0, affine.ShearY);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);

            affine.TransformSkewY(2.0);

            Assert.Equal(1.0, affine.ScaleX);
            Assert.InRange(affine.ScaleY, 1.0024, 1.0025);
            Assert.InRange(affine.ShearX, 0.0699, 0.0700);
            Assert.InRange(affine.ShearY, 0.0349, 0.0350);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);
        }
Ejemplo n.º 6
0
        public void Test_TransformSkew()
        {
            DrawableAffine affine = new DrawableAffine();

            affine.TransformSkewX(4.0);

            Assert.AreEqual(1.0, affine.ScaleX);
            Assert.AreEqual(1.0, affine.ScaleY);
            Assert.AreEqual(0.0699, affine.ShearX, 0.0001);
            Assert.AreEqual(0.0, affine.ShearY);
            Assert.AreEqual(0.0, affine.TranslateX);
            Assert.AreEqual(0.0, affine.TranslateY);

            affine.TransformSkewY(2.0);

            Assert.AreEqual(1.0, affine.ScaleX);
            Assert.AreEqual(1.0024, affine.ScaleY, 0.0001);
            Assert.AreEqual(0.0699, affine.ShearX, 0.0001);
            Assert.AreEqual(0.0349, affine.ShearY, 0.0001);
            Assert.AreEqual(0.0, affine.TranslateX);
            Assert.AreEqual(0.0, affine.TranslateY);
        }
Ejemplo n.º 7
0
        public void Test_Reset()
        {
            DrawableAffine affine = new DrawableAffine();

            Assert.Equal(1.0, affine.ScaleX);
            Assert.Equal(1.0, affine.ScaleY);
            Assert.Equal(0.0, affine.ShearX);
            Assert.Equal(0.0, affine.ShearY);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);

            affine.ScaleX = 2.0;
            Assert.Equal(2.0, affine.ScaleX);
            Assert.Equal(1.0, affine.ScaleY);
            Assert.Equal(0.0, affine.ShearX);
            Assert.Equal(0.0, affine.ShearY);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);

            affine.ScaleY = 3.0;
            Assert.Equal(2.0, affine.ScaleX);
            Assert.Equal(3.0, affine.ScaleY);
            Assert.Equal(0.0, affine.ShearX);
            Assert.Equal(0.0, affine.ShearY);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);

            affine.ShearX = 4.0;
            Assert.Equal(2.0, affine.ScaleX);
            Assert.Equal(3.0, affine.ScaleY);
            Assert.Equal(4.0, affine.ShearX);
            Assert.Equal(0.0, affine.ShearY);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);

            affine.ShearY = 5.0;
            Assert.Equal(2.0, affine.ScaleX);
            Assert.Equal(3.0, affine.ScaleY);
            Assert.Equal(4.0, affine.ShearX);
            Assert.Equal(5.0, affine.ShearY);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);

            affine.TranslateX = 6.0;
            Assert.Equal(2.0, affine.ScaleX);
            Assert.Equal(3.0, affine.ScaleY);
            Assert.Equal(4.0, affine.ShearX);
            Assert.Equal(5.0, affine.ShearY);
            Assert.Equal(6.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);

            affine.TranslateY = 7.0;
            Assert.Equal(2.0, affine.ScaleX);
            Assert.Equal(3.0, affine.ScaleY);
            Assert.Equal(4.0, affine.ShearX);
            Assert.Equal(5.0, affine.ShearY);
            Assert.Equal(6.0, affine.TranslateX);
            Assert.Equal(7.0, affine.TranslateY);

            affine.Reset();
            Assert.Equal(1.0, affine.ScaleX);
            Assert.Equal(1.0, affine.ScaleY);
            Assert.Equal(0.0, affine.ShearX);
            Assert.Equal(0.0, affine.ShearY);
            Assert.Equal(0.0, affine.TranslateX);
            Assert.Equal(0.0, affine.TranslateY);
        }