示例#1
0
        protected PolygonF(Polygon ply)
            : this()
        {
            PolygonF polyf = PolygonF.FromPolygon(ply);

            this.AddRange(polyf._pnts.ToArray());
        }
示例#2
0
 public static PolygonF Scale(PolygonF ply, float width, float height)
 {
     PointF[] p = new PointF[ply._pnts.Count];
     ply._pnts.CopyTo(p);
     using (Matrix mat = new Matrix())
     {
         mat.Scale(width, height);
         mat.TransformPoints(p);
     }
     return(new PolygonF(p));
 }
示例#3
0
 public static PolygonF Offset(PolygonF ply, float x, float y)
 {
     PointF[] p = new PointF[ply._pnts.Count];
     ply._pnts.CopyTo(p);
     for (int i = 0; i < p.Length; i++)
     {
         p[i].X += x;
         p[i].Y += y;
     }
     return(new PolygonF(p));
 }
示例#4
0
 public static PolygonF Rotate(PolygonF ply, float degress, PointF center)
 {
     PointF[] p = new PointF[ply._pnts.Count];
     ply._pnts.CopyTo(p);
     using (Matrix mat = new Matrix())
     {
         mat.RotateAt(degress, center);
         mat.TransformPoints(p);
     }
     return(new PolygonF(p));
 }
示例#5
0
        public virtual void RotateAtCentroid(float degrees)
        {
            PolygonF rotatePly = PolygonF.Rotate(this, degrees, this.Centroid);

            this.Clear();
            this._pnts.AddRange(rotatePly._pnts.ToArray());
            if (this._preCalcBBox)
            {
                this.UpdateMinMax(this._pnts);
            }
            rotatePly.Clear();
        }
示例#6
0
        public virtual void Scale(float width, float height)
        {
            PolygonF scalePly = PolygonF.Scale(this, width, height);

            this.Clear();
            this._pnts.AddRange(scalePly._pnts.ToArray());
            if (this._preCalcBBox)
            {
                this.UpdateMinMax(this._pnts);
            }
            scalePly.Clear();
        }
示例#7
0
        public virtual void Offset(float x, float y)
        {
            PolygonF offsetPly = PolygonF.Offset(this, x, y);

            this.Clear();
            this._pnts.AddRange(offsetPly._pnts.ToArray());
            if (this._preCalcBBox)
            {
                this.UpdateMinMax(this._pnts);
            }
            offsetPly.Clear();
        }
示例#8
0
 public Polygon(params Point[] points)
 {
     this._ply = new PolygonF(points.Select(p => new PointF((float)p.X, (float)p.Y)).ToArray());
 }
示例#9
0
 //***************************************************************************
 // Class Constructors
 //
 public Polygon()
 {
     this._ply = new PolygonF();
 }
示例#10
0
 public static void FillShape(PolygonF ply, Graphics g, Brush b)
 {
     using (GraphicsPath path = ply.GetShape())
         g.FillPath(b, path);
 }
示例#11
0
 public static Polygon Rotate(Polygon ply, float degrees, Point center)
 {
     return(Polygon.Truncate(PolygonF.Rotate(ply._ply, degrees, new PointF((float)center.X, (float)center.Y))));
 }
示例#12
0
 public static void DrawShape(PolygonF ply, Graphics g, Pen p)
 {
     using (GraphicsPath path = ply.GetShape())
         g.DrawPath(p, path);
 }
示例#13
0
 public static PolygonF Scale(PolygonF ply, float width, float height)
 {
     PointF[] p = new PointF[ply._pnts.Count];
     ply._pnts.CopyTo(p);
     using (Matrix mat = new Matrix())
     {
         mat.Scale(width, height);
         mat.TransformPoints(p);
     }
     return new PolygonF(p);
 }
示例#14
0
 public static Polygon Ceiling(PolygonF ply)
 { return new Polygon(ply.GetPoints().Select(p => Point.Ceiling(p)).ToArray()); }
示例#15
0
        public static PointF GetCentroid(PointF[] points)
        {
            float areaDummy;

            return(PolygonF.GetCentroid(points, out areaDummy));
        }
示例#16
0
 public static Polygon Ceiling(PolygonF ply)
 {
     return(new Polygon(ply.GetPoints().Select(p => Point.Ceiling(p)).ToArray()));
 }
示例#17
0
 public static Polygon Offset(Polygon ply, int x, int y)
 {
     return(Polygon.Truncate(PolygonF.Offset(ply._ply, (float)x, (float)y)));
 }
示例#18
0
 public static Polygon Scale(Polygon ply, int width, int height)
 {
     return(Polygon.Truncate(PolygonF.Scale(ply._ply, (float)width, (float)height)));
 }
示例#19
0
 //***************************************************************************
 // Static Methods
 // 
 public static Polygon Round(PolygonF ply)
 { return new Polygon(ply.GetPoints().Select(p => Point.Round(p)).ToArray()); }
示例#20
0
 public static Polygon Truncate(PolygonF ply)
 { return new Polygon(ply.GetPoints().Select(p => Point.Truncate(p)).ToArray()); }
示例#21
0
 //***************************************************************************
 // Class Constructors
 // 
 public Polygon()
 {
     this._ply = new PolygonF();
 }
示例#22
0
 public static PolygonF Rotate(PolygonF ply, float degress, PointF center)
 {
     PointF[] p = new PointF[ply._pnts.Count];
     ply._pnts.CopyTo(p);
     using (Matrix mat = new Matrix())
     {
         mat.RotateAt(degress, center);
         mat.TransformPoints(p);
     }
     return new PolygonF(p);
 }
示例#23
0
 public static Polygon Truncate(PolygonF ply)
 {
     return(new Polygon(ply.GetPoints().Select(p => Point.Truncate(p)).ToArray()));
 }
示例#24
0
 public static PolygonF Offset(PolygonF ply, float x, float y)
 {
     PointF[] p = new PointF[ply._pnts.Count];
     ply._pnts.CopyTo(p);
     for (int i = 0; i < p.Length; i++)
     {
         p[i].X += x;
         p[i].Y += y;
     }
     return new PolygonF(p);
 }
示例#25
0
 public static void DrawShape(PolygonF ply, Graphics g, Pen p)
 {
     using (GraphicsPath path = ply.GetShape())
         g.DrawPath(p, path);
 }
示例#26
0
 public static void FillShape(PolygonF ply, Graphics g, Brush b)
 {
     using (GraphicsPath path = ply.GetShape())
         g.FillPath(b, path);
 }
示例#27
0
 public static Point GetCentroid(Point[] points)
 {
     return(Point.Truncate(PolygonF.GetCentroid(points.Select(p => new PointF((float)p.X, (float)p.Y)).ToArray())));
 }
示例#28
0
 public Polygon(params Point[] points)
 {
     this._ply = new PolygonF(points.Select(p => new PointF((float)p.X, (float)p.Y)).ToArray());
 }
示例#29
0
 //***************************************************************************
 // Static Methods
 //
 public static Polygon Round(PolygonF ply)
 {
     return(new Polygon(ply.GetPoints().Select(p => Point.Round(p)).ToArray()));
 }