Пример #1
0
        public override void OnKeyDown(AGG.UI.KeyEventArgs keyEvent)
        {
            if (keyEvent.KeyCode == Keys.Space)
            {
                T cx = m_quad.xn(0).Add(m_quad.xn(1)).Add(m_quad.xn(2)).Add(m_quad.xn(3)).Divide(4);
                T cy = m_quad.yn(0).Add(m_quad.yn(1)).Add(m_quad.yn(2)).Add(m_quad.yn(3)).Divide(4);
                IAffineTransformMatrix <T> tr = MatrixFactory <T> .NewTranslation(cx.Negative(), cy.Negative());

                tr.RotateAlong(MatrixFactory <T> .CreateVector2D(0, 0), (Math.PI / 2.0));
                tr.Translate(MatrixFactory <T> .CreateVector2D(cx, cy));
                T xn0 = m_quad.xn(0); T yn0 = m_quad.yn(0);
                T xn1 = m_quad.xn(1); T yn1 = m_quad.yn(1);
                T xn2 = m_quad.xn(2); T yn2 = m_quad.yn(2);
                T xn3 = m_quad.xn(3); T yn3 = m_quad.yn(3);
                tr.Transform(ref xn0, ref yn0);
                tr.Transform(ref xn1, ref yn1);
                tr.Transform(ref xn2, ref yn2);
                tr.Transform(ref xn3, ref yn3);
                m_quad.SetXN(0, xn0); m_quad.SetYN(0, yn0);
                m_quad.SetXN(1, xn1); m_quad.SetYN(1, yn1);
                m_quad.SetXN(2, xn2); m_quad.SetYN(2, yn2);
                m_quad.SetXN(3, xn3); m_quad.SetYN(3, yn3);
                force_redraw();
            }

            base.OnKeyDown(keyEvent);
        }
Пример #2
0
        //----------------------------------------------------------------
        public void Begin(T x, T y, uint len)
        {
            T tx;
            T ty;

            tx = x;
            ty = y;
            m_trans.Transform(ref tx, ref ty);
            int x1 = Basics.RoundInt(tx.Multiply((double)subpixel_scale_e.subpixel_scale));
            int y1 = Basics.RoundInt(ty.Multiply((double)subpixel_scale_e.subpixel_scale));

            tx = x.Add(len);
            ty = y;
            m_trans.Transform(ref tx, ref ty);
            int x2 = Basics.RoundInt(tx.Multiply((double)subpixel_scale_e.subpixel_scale));
            int y2 = Basics.RoundInt(ty.Multiply((double)subpixel_scale_e.subpixel_scale));

            m_li_x = new Dda2LineInterpolator(x1, x2, (int)len);
            m_li_y = new Dda2LineInterpolator(y1, y2, (int)len);
        }
Пример #3
0
        public void TransformTest()
        {
            IAffineTransformMatrix <DoubleComponent> a = MatrixFactory <DoubleComponent> .NewIdentity(VectorDimension.Two);

            a.Translate(MatrixFactory <DoubleComponent> .CreateVector2D(10, 20));

            DoubleComponent x    = 10;
            DoubleComponent y    = 20;
            DoubleComponent newx = 0;
            DoubleComponent newy = 0;

            a.Transform(ref newx, ref newy);
            Assert.AreEqual((double)x, (double)newx, .001);
            Assert.AreEqual((double)y, (double)newy, .001);
        }
 public static void Transform <T>(this IAffineTransformMatrix <T> m, ref RectDouble <T> rect)
     where T : IEquatable <T>, IComparable <T>, IComputable <T>, IConvertible, IFormattable, ICommonNumericalOperations <T>, ITrigonometricOperations <T>
 {
     m.Transform(ref rect.x1, ref rect.y1);
     m.Transform(ref rect.x2, ref rect.y2);
 }