Table of Contents

Class RectangleMathExtensions

Namespace
Splat
Assembly
Splat.dll

Extension methods to help with operations associated with the RectangleF struct.

public static class RectangleMathExtensions
Inheritance
RectangleMathExtensions

Methods

Center(RectangleF)

Determine the center of a Rectangle.

public static PointF Center(this RectangleF value)

Parameters

value RectangleF

The rectangle to perform the calculation against.

Returns

PointF

The point of the center of the rectangle.

Copy(RectangleF, float?, float?, float?, float?, float?, float?)

Creates a new RectangleF as a Copy of an existing one .

value is useful when you have a rectangle that is almost what you want, but you just want to change a couple properties.

public static RectangleF Copy(this RectangleF value, float? x = null, float? y = null, float? width = null, float? height = null, float? top = null, float? bottom = null)

Parameters

value RectangleF

The rectangle to perform the calculation against.

x float?

Optional new x coordinate of the rectangle to use.

y float?

Optional new y coordinate of the rectangle to use.

width float?

Optional new width of the rectangle to use.

height float?

Optional new height of the rectangle to use.

top float?

Optional new top of the rectangle to use.

bottom float?

Optional new bottom of the rectangle to use.

Returns

RectangleF

The copied rectangle.

Divide(RectangleF, float, RectEdge)

Divide the specified Rectangle into two component rectangles.

public static Tuple<RectangleF, RectangleF> Divide(this RectangleF value, float amount, RectEdge fromEdge)

Parameters

value RectangleF

The rectangle to perform the calculation against.

amount float

Amount to move away from the given edge.

fromEdge RectEdge

The edge to create the slice from.

Returns

Tuple<RectangleF, RectangleF>

The set of rectnagles that are generated.

DivideWithPadding(RectangleF, float, float, RectEdge)

Divide the specified Rectangle into two component rectangles, adding a padding between them.

public static Tuple<RectangleF, RectangleF> DivideWithPadding(this RectangleF value, float sliceAmount, float padding, RectEdge fromEdge)

Parameters

value RectangleF

The rectangle to perform the calculation against.

sliceAmount float

Amount to move away from the given edge.

padding float

The amount of padding that is in neither rectangle.

fromEdge RectEdge

The edge to create the slice from.

Returns

Tuple<RectangleF, RectangleF>

The set of rectangles that are generated.

InvertWithin(RectangleF, RectangleF)

Vertically inverts the coordinates of the rectangle within containingRect.

value can effectively be used to change the coordinate system of a rectangle. For example, if `rect` is defined for a coordinate system starting at the top-left, the result will be a rectangle relative to the bottom-left.

public static RectangleF InvertWithin(this RectangleF value, RectangleF containingRect)

Parameters

value RectangleF

The rectangle to perform the calculation against.

containingRect RectangleF

The containing rectangle.

Returns

RectangleF

The inverted rectangle.