RectangleExtensionMethods
Extension methods for Eto.Drawing.Rectangle and Eto.Drawing.RectangleF
Methods
Adjust the sides of a rectangle.
public static Rectangle AdjustSides()
this Rectangle
rectangle,
Rectangle to adjust.
amount
Adjustment amount. Positive distances mean outwards growth.
Returns: Adjusted rectangle.
Adjust the sides of a rectangle.
Returns: Adjusted rectangle.
Adjust the sides of a rectangle.
public static Rectangle AdjustSides()
this Rectangle
rectangle,
Rectangle to adjust.
left,
Leftwards adjustment amount. Positive distances mean outwards growth.
top,
Upwards adjustment amount. Positive distances mean outwards growth.
right,
Rightwards adjustment amount. Positive distances mean outwards growth.
bottom
Downwards adjustment amount. Positive distances mean outwards growth.
Returns: Adjusted rectangle.
Adjust the sides of a rectangle.
public static RectangleF AdjustSides()
this RectangleF
rectangle,
Rectangle to adjust.
amount
Offset distance. Positive distances mean outwards offset.
Returns: Adjusted rectangle.
Adjust the sides of a rectangle.
Returns: Adjusted rectangle.
Adjust the sides of a rectangle.
public static RectangleF AdjustSides()
this RectangleF
rectangle,
Rectangle to adjust.
left,
Leftwards adjustment amount. Positive distances mean outwards growth.
top,
Upwards adjustment amount. Positive distances mean outwards growth.
right,
Rightwards adjustment amount. Positive distances mean outwards growth.
bottom
Downwards adjustment amount. Positive distances mean outwards growth.
Returns: Adjusted rectangle.
Move a rectangle so that the indicated edge aligns with the given coordinate.
public static RectangleF Align()
this RectangleF
rectangle,
Rectangle to move.
edge,
Edge to align.
coordinate
Edge coordinate.
Gets the (unsigned) area of a rectangle.
Gets the bounding rectangle for a collection of points.
Returns: Bounding rectangle.
Gets the bounding rectangle for a collection of rectangles.
Returns: Bounding rectangle.
Gets the bounding rectangle for a collection of points.
Returns: Bounding rectangle.
Gets the bounding rectangle for a collection of rectangles.
Returns: Bounding rectangle.
Round a rectangle to the nearest integer coordinates ensuring only ever to grow the rectangle content.
public static RectangleF Ceiling()
this RectangleF
rectangle
Rectangle to round.
Returns: Adjusted rectangle.
Round the width and height of a size to the nearest bigger integer.
public static SizeF Ceiling()
this SizeF
size
Size to round.
Returns: Adjusted size.
Gets the point that best describes the centre of a rectangle.
Returns: Centre point.
Gets the point that best describes the centre of a rectangle.
public static PointF Centre()
this RectangleF
rectangle
Rectangle.
Returns: Centre point.
Project a point onto the interior of a rectangle.
Returns: Point on rectangle closest to the point.
Project a point onto the interior of a rectangle.
public static PointF ClosestPointIn()
this RectangleF
rectangle,
Rectangle to project onto.
PointF
point
Point to project.
Returns: Point on rectangle closest to the point.
Project a point onto the boundary of a rectangle.
Returns: Point on rectangle boundary closest to the point.
Project a point onto the boundary of a rectangle.
public static PointF ClosestPointOn()
this RectangleF
rectangle,
Rectangle to project onto.
PointF
point
Point to project.
Returns: Point on rectangle closest to the point.
Test whether a point is inside a rectangle.
Returns: True if the point is inside the rectangle.
Test whether a point is contained within a rectangle. This method is better than the Eto standard RectangleF.Contains as it correctly checks all edges.
Test whether the point is inside the ellipse bounded by the rectangle.
public static bool ContainsInEllipse()
this Rectangle
rectangle,
Bounding rectangle.
PointF
point
Point to test.
Returns: True if point is inside ellipse.
Test whether the point is inside the ellipse bounded by the rectangle.
public static bool ContainsInEllipse()
this RectangleF
rectangle,
Bounding rectangle.
PointF
point
Point to test.
Returns: True if point is inside ellipse.
Gets the rectangle corners, ordered counter-clockwise starting from the lower left corner.
Returns: An array of 4 points representing the corners of the rectangle.
Gets the rectangle corners, ordered counter-clockwise starting from the lower left corner.
public static PointF[] Corners()
this RectangleF
rectangle
Returns: An array of 4 points representing the corners of the rectangle.
Gets the distance from this rectangle to a point. Any point in or on the rectangle has a distance of zero.
Returns: Distance between point and rectangle.
Gets the distance from this rectangle to a point. Any point in or on the rectangle has a distance of zero.
Returns: Distance between point and rectangle.
Gets the distance from this rectangle to a point. Any point in or on the rectangle has a distance of zero.
Returns: Distance between point and rectangle.
Gets the distance between two rectangles.
Returns: Distance between both rectangles.
Move a rectangle down so that the new top lines up with the old bottom.
public static RectangleF Down()
this RectangleF
rectangle
Gets the edge of a rectangle.
Round a rectangle to the nearest integer coordinates ensuring only ever to shrink the rectangle content.
public static RectangleF Floor()
this RectangleF
rectangle
Rectangle to round.
Returns: Adjusted rectangle.
Round the width and height of a size to the nearest smaller integer.
public static SizeF Floor()
this SizeF
size
Size to round.
Returns: Adjusted size.
Find the point on the rectangle that is furthest from some base point.
Returns: Point on rectangle furthest from base point.
Find the point on the rectangle that is furthest from some base point.
public static PointF FurthestPoint()
this RectangleF
rectangle,
Rectangle.
PointF
point
Point to search from.
Returns: Point on rectangle furthest from base point.
Grow a rectangle until it contains a given point.
public static Rectangle Grow()
Returns: Grown rectangle.
Grow a rectangle until it contains a given point.
public static RectangleF Grow()
this RectangleF
rectangle,
Rectangle to grow.
PointF
point
Point to include.
Returns: Grown rectangle.
Interpolate between two rectangles.
public static RectangleF Interpolate()
this RectangleF
rectangle,
Starting rectangle.
RectangleF
target,
Final rectangle.
motion
Normalised interpolation factor.
Test whether two boxes intersect within tolerance.
Move a rectangle left so that the new right lines up with the old left.
public static RectangleF Left()
this RectangleF
rectangle
Make sure the width and height of a rectangle are increasing.
public static Rectangle MakeIncreasing()
this Rectangle
rectangle
Make sure the width and height of a rectangle are increasing.
public static RectangleF MakeIncreasing()
this RectangleF
rectangle
Move a rectangle.
Returns: Moved rectangle.
Move a rectangle.
Returns: Moved rectangle.
Move this rectangle such that it is entirely within another one, whenever possible.
public static Rectangle MoveInto()
this Rectangle
rectangle,
Rectangle to move.
Rectangle
boundary
Bounding rectangle.
Offset a rectangle.
public static Rectangle3d Offset()
this Rectangle3d
rectangle,
Rectangle.
offset
Offset distance. Positive values offset towards the outside.
Gets the (unsigned) perimeter or circumference of a rectangle.
Gets the point at a rectangle parameter.
Returns: Point at the given coordinates.
Gets the point at a rectangle parameter.
Returns: Point at the given coordinates.
Gets the radius of the rectangle (distance from the centre to a corner).
Returns: Radius of rectangle.
Gets the radius of the rectangle (distance from the centre to a corner).
Returns: Radius of rectangle.
Create a rectangle from normalised coordinates.
Returns: Sub rectangle.
Move a rectangle left so that the new left lines up with the old right.
public static RectangleF Right()
this RectangleF
rectangle
Round the coordinates of a rectangle.
public static RectangleF Round()
Returns: Rectangle with coordinates rounded to a specific number of decimal places.
Round a rectangle to integer coordinates.
public static RectangleF Round()
this RectangleF
rectangle
Rectangle to modify.
Returns: Rectangle with coordinates rounded to nearest integers.
Round the coordinates of a rectangle.
Returns: Size with rounded dimensions.
Round a size to integer coordinates.
public static SizeF Round()
this SizeF
size
Size to modify.
Returns: Size with rounded dimensions.
Scale a rectangle around its centre by a specific factor.
public static RectangleF Scale()
Returns: Scaled rectangle.
Split a rectangle into two.
public static void SplitHorizontal()
this Rectangle
rectangle,
Rectangle to split.
x,
X coordinate to split at.
out Rectangle
left,
Rectangle to left of split.
out Rectangle
right
Rectangle to right of split.
Split a rectangle into two.
public static void SplitHorizontal()
this RectangleF
rectangle,
Rectangle to split.
x,
X coordinate to split at.
out RectangleF
left,
Rectangle to left of split.
out RectangleF
right
Rectangle to right of split.
Split a rectangle into two.
public static void SplitVertical()
this Rectangle
rectangle,
Rectangle to split.
y,
Y coordinate to split at.
out Rectangle
above,
Rectangle above split.
out Rectangle
below
Rectangle below split.
Split a rectangle into two.
public static void SplitVertical()
this RectangleF
rectangle,
Rectangle to split.
y,
Y coordinate to split at.
out RectangleF
above,
Rectangle above split.
out RectangleF
below
Rectangle below split.
Split a rectangle into three.
Create an array (row-by-row) of division rectangles.
Returns: Array of rectangles.
Create the largest possible rectangle inside another rectangle with a specific width/height ratio.
public static Rectangle ToInnerRectangle()
this Rectangle
rectangle,
Rectangle to fit into.
Size
ratio
Ratio of fitted rectangle.
Returns: Fitted rectangle.
Create the largest possible rectangle inside another rectangle with a specific width/height ratio.
public static RectangleF ToInnerRectangle()
this RectangleF
rectangle,
Rectangle to fit into.
SizeF
ratio
Ratio of fitted rectangle.
Returns: Fitted rectangle.
Convert a rectangle to the biggest square that fits inside it.
public static Rectangle ToInnerSquare()
this Rectangle
rectangle
Rectangle to square.
Returns: Biggest square that fits inside rectangle.
Convert a rectangle to the smallest square containing it.
public static RectangleF ToInnerSquare()
this RectangleF
rectangle
Rectangle to square.
Returns: Biggest square that fits inside rectangle.
Create the smallest possible rectangle outside another rectangle with a specific width/height ratio.
public static Rectangle ToOuterRectangle()
this Rectangle
rectangle,
Rectangle to wrap around.
Size
ratio
Ratio of wrapped rectangle.
Returns: Wrapped rectangle.
Create the smallest possible rectangle outside another rectangle with a specific width/height ratio.
public static RectangleF ToOuterRectangle()
this RectangleF
rectangle,
Rectangle to wrap around.
SizeF
ratio
Ratio of wrapped rectangle.
Returns: Wrapped rectangle.
Convert a rectangle to the smallest square containing it.
public static Rectangle ToOuterSquare()
this Rectangle
rectangle
Rectangle to square.
Returns: Smallest square containing rectangle.
Convert a rectangle to the smallest square containing it.
public static RectangleF ToOuterSquare()
this RectangleF
rectangle
Rectangle to square.
Returns: Smallest square containing rectangle.
Convert a RectangleF into a Rectangle.
public static Rectangle ToRectangle()
this RectangleF
rectangle
Rectangle to convert.
Returns: Rectangle.
Convert an Eto rectangle into a Rhino rectangle.
Returns: Rhino rectangle.
Convert an Eto rectangle into a Rhino rectangle.
Returns: Rhino rectangle.
Fillet the corners of a rectangle. The radius is automatically shrunk to avoid self-intersections.
Create a graphicspath that describes slab edges within a rounded rectangle.
public static GraphicsPath ToRoundedEdge()
this RectangleF
rectangle,
Bounding rectangle.
radius,
Radius of edge.
thickness,
Thickness of edge.
edge
Edges.
Returns: Graphicspath describing the edges or null if no edges could be solved.
Create a graphics path that represents a rounded rectangle.
public static GraphicsPath ToRoundedRectangle()
Create a graphics path that represents a rounded rectangle.
public static GraphicsPath ToRoundedRectangle()
Returns: Graphics path.
Create a graphics path that represents a rounded rectangle.
public static GraphicsPath ToRoundedRectangle()
Returns: Graphics path.
Create a graphics path that represents a rounded rectangle.
public static GraphicsPath ToRoundedRectangle()
Returns: Graphics path.