Esempio n. 1
0
        public TextEditWidget(string Text, RectDouble <T> bounds, T CapitalHeight)
        {
            Bounds = bounds;

            m_TextWidget = new TextWidget <T>(Text, M.Zero <T>(), M.Zero <T>(), CapitalHeight);
            AddChild(m_TextWidget);

            m_CharIndexToInsertBefore = Text.Length;

            IAffineTransformMatrix <T> transform = GetTransform();
            IVector <T> v1 = transform.TransformVector(MatrixFactory <T> .CreateVector2D(bounds.x1, bounds.y1));
            IVector <T> v2 = transform.TransformVector(MatrixFactory <T> .CreateVector2D(bounds.x2, bounds.y2));

            SetTransform(transform);

            m_BorderSize = CapitalHeight.Multiply(.2);
            m_Thickness  = CapitalHeight.Divide(8);
            m_CapsHeight = CapitalHeight;

            FixBarPosition(true);

            UndoData newUndoData = new UndoData(this);

            m_UndoBuffer.Add(newUndoData, "Initial", UndoBuffer.MergeType.NotMergable);
        }
Esempio n. 2
0
        public static void Transform <T>(this IAffineTransformMatrix <T> m, ref T x, ref T y)
            where T : IEquatable <T>, IComparable <T>, IComputable <T>, IConvertible, IFormattable, ICommonNumericalOperations <T>, ITrigonometricOperations <T>
        {
            IVector <T> v1 = m.TransformVector(MatrixFactory <T> .CreateVector2D(x, y));

            x = v1[0];
            y = v1[1];
        }
Esempio n. 3
0
        //used to Transform the sweepers vertices prior to rendering
        public void WorldTransform(List <IVector <T> > sweeper)
        {
            ////create the world transformation matrix
            //Matrix4X4 matTransform = new Matrix4X4();

            ////scale
            //matTransform.Scale(m_dScale, m_dScale, 1);

            ////rotate
            //matTransform.AddRotate(2, (double)m_dRotation);

            ////and translate
            //matTransform.AddTranslate(m_vPosition.x, m_vPosition.y, 0);

            ////now Transform the ships vertices
            //for (int i = 0; i < sweeper.Count; i++)
            //{
            //    Vector3D Temp = sweeper[i];
            //    matTransform.TransformVector(ref Temp);
            //    sweeper[i] = Temp;
            //}

            //create the world transformation matrix
            IAffineTransformMatrix <T> matTransform = MatrixFactory <T> .NewIdentity(VectorDimension.Three);

            //scale
            matTransform.Scale(MatrixFactory <T> .CreateVector3D(m_dScale, m_dScale, M.One <T>()));

            //rotate
            //matTransform.AddRotate(2, (double)m_dRotation);
            IVector <T> axis = null;/// need to work out which axis this should be

            matTransform.RotateAlong(axis, m_dRotation);


            //and translate
            matTransform.Translate(MatrixFactory <T> .CreateVector3D(m_vPosition[0], m_vPosition[1], M.Zero <T>()));

            //now Transform the ships vertices
            for (int i = 0; i < sweeper.Count; i++)
            {
                IVector <T> Temp = sweeper[i];
                Temp       = matTransform.TransformVector(Temp);
                sweeper[i] = Temp;
            }
        }
Esempio n. 4
0
        public void Transform(IAffineTransformMatrix <T> trans, uint path_id)
        {
            uint num_ver = m_vertices.TotalVertices();

            for (; path_id < num_ver; path_id++)
            {
                T    x, y;
                uint PathAndFlags = m_vertices.Vertex(path_id, out x, out y);
                if (Path.IsStop(PathAndFlags))
                {
                    break;
                }
                if (Path.IsVertex(PathAndFlags))
                {
                    //trans.Transform(ref x, ref y);
                    //m_vertices.ModifyVertex(path_id, x, y);
                    IVector <T> v1 = trans.TransformVector(MatrixFactory <T> .CreateVector2D(x, y));
                    m_vertices.ModifyVertex(path_id, v1[0], v1[1]);
                }
            }
        }
Esempio n. 5
0
        public void WorldTransform(List <IVector <T> > VBuffer, IVector <T> vPos)
        {
            //create the world transformation matrix
            //Matrix4X4 matTransform = new Matrix4X4();

            IAffineTransformMatrix <T> matTransform = MatrixFactory <T> .NewIdentity(VectorDimension.Three);

            //scale
            matTransform.Scale(MatrixFactory <T> .CreateVector2D(m_MineScale, m_MineScale));

            //translate
            matTransform.Translate(MatrixFactory <T> .CreateVector2D(vPos[0], vPos[1]));

            //Transform the ships vertices
            for (int i = 0; i < VBuffer.Count; i++)
            {
                IVector <T> Temp = VBuffer[i];
                Temp       = matTransform.TransformVector(Temp);
                VBuffer[i] = Temp;
            }
        }
Esempio n. 6
0
 public static void Transform <T>(this IAffineTransformMatrix <T> m, ref IVector <T> vector)
     where T : IEquatable <T>, IComparable <T>, IComputable <T>, IConvertible, IFormattable, ICommonNumericalOperations <T>, ITrigonometricOperations <T>
 {
     vector = m.TransformVector(vector);
 }
Esempio n. 7
0
        public void Begin(T x, T y, uint len)
        {
            // Calculate transformed coordinates at x1,y1
            //double xt = x;
            //double yt = y;
            //m_trans_dir.Transform(ref xt, ref yt);
            IVector <T> v1 = m_trans_dir.TransformVector(MatrixFactory <T> .CreateVector2D(x, y));

            T xt = v1[0], yt = v1[1];

            int x1 = Basics.RoundInt(xt.Multiply((double)subpixel_scale));
            int y1 = Basics.RoundInt(yt.Multiply((double)subpixel_scale));

            T      dx;
            T      dy;
            double delta = 1 / (double)subpixel_scale;

            // Calculate scale by X at x1,y1
            dx = xt.Add(delta);
            dy = yt;

            //m_trans_inv.Transform(ref dx, ref dy);
            IVector <T> v2 = m_trans_inv.TransformVector(MatrixFactory <T> .CreateVector2D(dx, dy));

            dx = v2[0];
            dy = v2[1];

            dx.SubtractEquals(x);
            dy.SubtractEquals(y);
            int sx1 = (int)Basics.RoundUint(M.New <T>(subpixel_scale).Divide(M.Length(dx, dy)).ToInt()) >> subpixel_shift;

            // Calculate scale by Y at x1,y1
            dx = xt;
            dy = yt.Add(delta);
            // m_trans_inv.Transform(ref dx, ref dy);
            IVector <T> v3 = m_trans_inv.TransformVector(MatrixFactory <T> .CreateVector2D(dx, dy));

            dx = v3[0];
            dy = v3[1];
            dx.SubtractEquals(x);
            dy.SubtractEquals(y);
            int sy1 = (int)Basics.RoundUint(M.New <T>((double)subpixel_scale).Divide(M.Length(dx, dy)).ToInt()) >> subpixel_shift;

            // Calculate transformed coordinates at x2,y2
            x.AddEquals(len);
            xt = x;
            yt = y;
            //m_trans_dir.Transform(ref xt, ref yt);
            IVector <T> v4 = m_trans_dir.TransformVector(MatrixFactory <T> .CreateVector2D(xt, yt));

            xt = v4[0];
            yt = v4[1];

            int x2 = Basics.RoundInt(xt.Multiply((double)subpixel_scale));
            int y2 = Basics.RoundInt(yt.Multiply((double)subpixel_scale));

            // Calculate scale by X at x2,y2
            dx = xt.Add(delta);
            dy = yt;

            //m_trans_inv.Transform(ref dx, ref dy);
            IVector <T> v5 = m_trans_inv.TransformVector(MatrixFactory <T> .CreateVector2D(dx, dy));

            dx = v5[0];
            dy = v5[1];

            dx.SubtractEquals(x);
            dy.SubtractEquals(y);
            int sx2 = (int)Basics.RoundUint(M.New <T>((double)subpixel_scale).Divide(M.Length(dx, dy)).ToInt()) >> subpixel_shift;

            // Calculate scale by Y at x2,y2
            dx = xt;
            dy = yt.Add(delta);
            //m_trans_inv.Transform(ref dx, ref dy);
            IVector <T> v6 = m_trans_inv.TransformVector(MatrixFactory <T> .CreateVector2D(dx, dy));

            dx = v6[0];
            dy = v6[1];

            dx.SubtractEquals(x);
            dy.SubtractEquals(y);
            int sy2 = (int)Basics.RoundUint(M.New <T>((double)subpixel_scale).Divide(M.Length(dx, dy)).ToInt()) >> subpixel_shift;

            // Initialize the interpolators
            m_coord_x = new Dda2LineInterpolator(x1, x2, (int)len);
            m_coord_y = new Dda2LineInterpolator(y1, y2, (int)len);
            m_scale_x = new Dda2LineInterpolator(sx1, sx2, (int)len);
            m_scale_y = new Dda2LineInterpolator(sy1, sy2, (int)len);
        }