示例#1
0
文件: Space3D.cs 项目: mdsoftware/m3d
        /// <summary>
        /// Text 3D
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="text"></param>
        public void Text(int tag, Text3D text, Text3DLocation location, Text3DFlip flip, int x, int y, int coordinate)
        {
            int px0 = 0;
            int py0 = 0;

            for (int i = 0; i < text.Count; i++)
            {
                Text3DPoint tp = text.Points[i];

                int px1 = x;
                int py1 = y;
                if ((flip & Text3DFlip.X) == 0)
                {
                    px1 += tp.X;
                }
                else
                {
                    px1 -= tp.X;
                }
                if ((flip & Text3DFlip.Y) == 0)
                {
                    py1 += tp.Y;
                }
                else
                {
                    py1 -= tp.Y;
                }

                if (tp.Type == Text3DPointType.LineTo)
                {
                    switch (location)
                    {
                    case Text3DLocation.XY:
                        this.Line(tag, px0, py0, coordinate, px1, py1, coordinate);
                        break;

                    case Text3DLocation.XZ:
                        this.Line(tag, px0, coordinate, py0, px1, coordinate, py1);
                        break;

                    case Text3DLocation.YZ:
                        this.Line(tag, coordinate, px0, py0, coordinate, px1, py1);
                        break;
                    }
                }
                px0 = px1;
                py0 = py1;
            }
        }
示例#2
0
        public static Text3D FromString(string s, Font font, double height, FontStyle style, int flatFactor)
        {
            GraphicsPath path = new GraphicsPath();
            int          h    = Point3D.MmToInt(height);

            path.AddString(s, font.FontFamily, (int)style, h, new RectangleF(0, 0, Single.MaxValue, Single.MaxValue), StringFormat.GenericDefault);
            if (flatFactor <= 0)
            {
                flatFactor = 100;
            }
            path.Flatten(null, (Single)h / (Single)flatFactor);
            PathData pd = path.PathData;

            Text3D t = new Text3D();

            int px  = 0;
            int py  = 0;
            int px0 = 0;
            int py0 = 0;

            for (int i = 0; i < pd.Points.Length; i++)
            {
                int px1 = (int)pd.Points[i].X;
                int py1 = (int)pd.Points[i].Y;

                switch ((byte)((int)pd.Types[i] & 0x07))
                {
                case (byte)PathPointType.Line:
                    t.points.Add(new Text3DPoint(Text3DPointType.LineTo, px1, py1));
                    break;

                case (byte)PathPointType.Start:
                    px0 = px1;
                    py0 = py1;
                    t.points.Add(new Text3DPoint(Text3DPointType.StartPoint, px1, py1));
                    break;
                }
                if (((int)pd.Types[i] & (int)PathPointType.CloseSubpath) != 0)
                {
                    t.points.Add(new Text3DPoint(Text3DPointType.LineTo, px0, py0));
                }

                px = px1;
                py = py1;
            }

            return(t);
        }
示例#3
0
文件: Space3D.cs 项目: mdsoftware/m3d
 /// <summary>
 /// Text 3D
 /// </summary>
 /// <param name="tag"></param>
 /// <param name="text"></param>
 /// <param name="location"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="coordinate"></param>
 public void Text(int tag, Text3D text, Text3DLocation location, Text3DFlip flip, float x, float y, float coordinate)
 {
     this.Text(tag, text, location, flip, Point3D.MmToInt(x), Point3D.MmToInt(y), Point3D.MmToInt(coordinate));
 }