Beispiel #1
0
        /// <summary>
        /// Determines if this polygon intersects with another polygon.
        /// </summary>
        /// <param name="polygon">The polygon to test against.</param>
        /// <returns>A value indicating if the two polygons intersect.</returns>
        public bool IntersectsWith(GsPolygon polygon)
        {
            GsRectangle boxA = GsRectangle.FromLTRB(this.mMinX, this.mMinY, this.mMaxX, this.mMaxY);
            GsRectangle boxB = GsRectangle.FromLTRB(polygon.mMinX, polygon.mMinY, polygon.mMaxX, polygon.mMaxY);

            return(boxA.IntersectsWith(boxB));
        }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            if (!(obj is GsRectangle))
            {
                return(false);
            }

            GsRectangle ef = (GsRectangle)obj;

            return(ef.X == this.X && ef.Y == this.Y && ef.Width == this.Width && ef.Height == this.Height);
        }
Beispiel #3
0
 public bool Contains(GsRectangle rect)
 {
     return((X <= rect.X) && (rect.Right <= Right) && (Y <= rect.Y) && (rect.Bottom <= Bottom));
 }
Beispiel #4
0
 public bool IntersectsWith(GsRectangle rect)
 {
     return((rect.X < (Right)) && (X < (rect.Right)) && (rect.Y < (Bottom)) && (Y < (rect.Bottom)));
 }
Beispiel #5
0
 public static GsRectangle Offset(GsRectangle box, GsVector offset)
 {
     return(new GsRectangle(box.Location + offset, box.Size));
 }
Beispiel #6
0
 public static GsRectangle Offset(GsRectangle box, float dx, float dy)
 {
     return(new GsRectangle(box.X + dx, box.Y + dy, box.Width, box.Height));
 }
Beispiel #7
0
        public static IEnumerable <GsVector> CreateRoundRect(GsRectangle rect, float radius, RectangleCorners corners)
        {
            float l = rect.Left;
            float t = rect.Top;
            float r = rect.Right;
            float b = rect.Bottom;

            float lr = rect.Left + radius;
            float tr = rect.Top + radius;
            float rr = rect.Right - radius;
            float br = rect.Bottom - radius;

            List <GsVector> polygon = new List <GsVector>();

            // upper-left
            if ((corners & RectangleCorners.TopLeft) != 0)
            {
                GsVector[] upleft_corner = new GsVector[3]
                {
                    new GsVector(l, tr),
                    new GsVector(l, t),
                    new GsVector(lr, t),
                };
                polygon.AddRange(CreateBezier(upleft_corner));
            }
            else
            {
                polygon.Add(new GsVector(l, t));
            }

            // upper-right
            if ((corners & RectangleCorners.TopRight) != 0)
            {
                GsVector[] upright_corner = new GsVector[3]
                {
                    new GsVector(rr, t),
                    new GsVector(r, t),
                    new GsVector(r, tr),
                };
                polygon.AddRange(CreateBezier(upright_corner));
            }
            else
            {
                polygon.Add(new GsVector(r, t));
            }

            // bottom-right
            if ((corners & RectangleCorners.BottomRight) != 0)
            {
                GsVector[] bottomright_corner = new GsVector[3]
                {
                    new GsVector(r, br),
                    new GsVector(r, b),
                    new GsVector(rr, b),
                };
                polygon.AddRange(CreateBezier(bottomright_corner));
            }
            else
            {
                polygon.Add(new GsVector(r, b));
            }

            // bottom-left
            if ((corners & RectangleCorners.BottomLeft) != 0)
            {
                GsVector[] bottomleft_corner = new GsVector[3]
                {
                    new GsVector(lr, b),
                    new GsVector(l, b),
                    new GsVector(l, br),
                };
                polygon.AddRange(CreateBezier(bottomleft_corner));
            }
            else
            {
                polygon.Add(new GsVector(l, b));
            }

            // close it up
            polygon.Add(polygon[0]);

            // return it!
            return(polygon);
        }
 public static void FillRectangle(this IGsGraphics graphics, GsColor color, GsRectangle rect)
 {
     graphics.FillRectangle(color, rect.X, rect.Y, rect.Width, rect.Height);
 }