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

            this.AddRange(polyf._pnts.ToArray());
        }
Example #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));
 }
Example #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));
 }
Example #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));
 }
Example #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();
        }
Example #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();
        }
Example #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();
        }
Example #8
0
 public Polygon(params Point[] points)
 {
     this._ply = new PolygonF(points.Select(p => new PointF((float)p.X, (float)p.Y)).ToArray());
 }
Example #9
0
 //***************************************************************************
 // Class Constructors
 //
 public Polygon()
 {
     this._ply = new PolygonF();
 }
Example #10
0
 public static void FillShape(PolygonF ply, Graphics g, Brush b)
 {
     using (GraphicsPath path = ply.GetShape())
         g.FillPath(b, path);
 }
Example #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))));
 }
Example #12
0
 public static void DrawShape(PolygonF ply, Graphics g, Pen p)
 {
     using (GraphicsPath path = ply.GetShape())
         g.DrawPath(p, path);
 }
Example #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);
 }
Example #14
0
 public static Polygon Ceiling(PolygonF ply)
 { return new Polygon(ply.GetPoints().Select(p => Point.Ceiling(p)).ToArray()); }
Example #15
0
        public static PointF GetCentroid(PointF[] points)
        {
            float areaDummy;

            return(PolygonF.GetCentroid(points, out areaDummy));
        }
Example #16
0
 public static Polygon Ceiling(PolygonF ply)
 {
     return(new Polygon(ply.GetPoints().Select(p => Point.Ceiling(p)).ToArray()));
 }
Example #17
0
 public static Polygon Offset(Polygon ply, int x, int y)
 {
     return(Polygon.Truncate(PolygonF.Offset(ply._ply, (float)x, (float)y)));
 }
Example #18
0
 public static Polygon Scale(Polygon ply, int width, int height)
 {
     return(Polygon.Truncate(PolygonF.Scale(ply._ply, (float)width, (float)height)));
 }
Example #19
0
 //***************************************************************************
 // Static Methods
 // 
 public static Polygon Round(PolygonF ply)
 { return new Polygon(ply.GetPoints().Select(p => Point.Round(p)).ToArray()); }
Example #20
0
 public static Polygon Truncate(PolygonF ply)
 { return new Polygon(ply.GetPoints().Select(p => Point.Truncate(p)).ToArray()); }
Example #21
0
 //***************************************************************************
 // Class Constructors
 // 
 public Polygon()
 {
     this._ply = new PolygonF();
 }
Example #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);
 }
Example #23
0
 public static Polygon Truncate(PolygonF ply)
 {
     return(new Polygon(ply.GetPoints().Select(p => Point.Truncate(p)).ToArray()));
 }
Example #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);
 }
Example #25
0
 public static void DrawShape(PolygonF ply, Graphics g, Pen p)
 {
     using (GraphicsPath path = ply.GetShape())
         g.DrawPath(p, path);
 }
Example #26
0
 public static void FillShape(PolygonF ply, Graphics g, Brush b)
 {
     using (GraphicsPath path = ply.GetShape())
         g.FillPath(b, path);
 }
Example #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())));
 }
Example #28
0
 public Polygon(params Point[] points)
 {
     this._ply = new PolygonF(points.Select(p => new PointF((float)p.X, (float)p.Y)).ToArray());
 }
Example #29
0
 //***************************************************************************
 // Static Methods
 //
 public static Polygon Round(PolygonF ply)
 {
     return(new Polygon(ply.GetPoints().Select(p => Point.Round(p)).ToArray()));
 }