Class RectangleF
A universally compatible RectangleF for .NET 7, .NET 6, .NET 5, and .NET Core. As well as compatibility with Windows, NanoServer, IIS, macOS, Mobile, Xamarin, iOS, Android, Google Compute, Azure, AWS, and Linux.
Works nicely with popular Image RectangleF such as System.Drawing.RectangleF, SkiaSharp.SKRect, SixLabors.ImageSharp.RectangleF, Microsoft.Maui.Graphics.Rect.
Implicit casting means that using this class to input and output RectangleF from public APIs gives full compatibility to all RectangleF type fully supported by Microsoft.
Inheritance
Namespace: IronSoftware.Drawing
Assembly: IronSoftware.Drawing.Common.dll
Syntax
public class RectangleF : Object
Constructors
RectangleF()
Construct a new RectangleF.
Declaration
public RectangleF()
See Also
RectangleF(PointF, SizeF, MeasurementUnits)
Initializes a new instance of the RectangleF struct.
Declaration
public RectangleF(PointF point, SizeF size, MeasurementUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| PointF | point | The Point which specifies the rectangles point in a two-dimensional plane. |
| SizeF | size | The IronSoftware.Drawing.RectangleF.Size which specifies the rectangles height and width. The measurement unit of this RectangleF |
| MeasurementUnits | units |
See Also
RectangleF(Single, Single, Single, Single, MeasurementUnits)
Construct a new RectangleF.
Declaration
public RectangleF(float x, float y, float width, float height, MeasurementUnits units)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | x | The x-coordinate of the upper-left corner of this RectangleF |
| System.Single | y | The y-coordinate of the upper-left corner of this RectangleF |
| System.Single | width | The width of this RectangleF |
| System.Single | height | The height of this RectangleF |
| MeasurementUnits | units | The measurement unit of this RectangleF |
See Also
Properties
Bottom
Gets the y-coordinate of the bottom edge of this RectangleF.
Declaration
public float Bottom { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Height
The height of this RectangleF. The default is 0
Declaration
public float Height { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Left
Gets the x-coordinate of the left edge of this RectangleF.
Declaration
public float Left { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Right
Gets the x-coordinate of the right edge of this RectangleF.
Declaration
public float Right { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Top
Gets the y-coordinate of the top edge of this RectangleF.
Declaration
public float Top { get; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Units
The measurement unit of this RectangleF. The default is Pixels
Declaration
public MeasurementUnits Units { get; set; }
Property Value
| Type | Description |
|---|---|
| MeasurementUnits |
Width
The width of this RectangleF. The default is 0
Declaration
public float Width { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
X
The x-coordinate of the upper-left corner of this RectangleF. The default is 0
Declaration
public float X { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Y
The y-coordinate of the upper-left corner of this RectangleF. The default is 0
Declaration
public float Y { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Single |
Methods
Contains(Int32, Int32)
Determines if the specified point is contained within the rectangular region defined by this RectangleF.
Declaration
public bool Contains(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | x | The x-coordinate of the given point. |
| System.Int32 | y | The y-coordinate of the given point. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
ConvertTo(MeasurementUnits, Int32)
Convert this RectangleF to the specified units of measurement using the specified DPI
Declaration
public RectangleF ConvertTo(MeasurementUnits toUnits, int dpi = 96)
Parameters
| Type | Name | Description |
|---|---|---|
| MeasurementUnits | toUnits | Unit of measurement |
| System.Int32 | dpi | DPI (Dots per inch) for conversion |
Returns
| Type | Description |
|---|---|
| RectangleF | A new RectangleF which uses the desired units of measurement |
Exceptions
| Type | Condition |
|---|---|
| System.NotImplementedException | Conversion not implemented |
Operators
Implicit(RectangleF to Rect)
Implicitly casts to Microsoft.Maui.Graphics.Rect objects from RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support Microsoft.Maui.Graphics.Rect as well.
Declaration
public static implicit operator Rect(RectangleF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | RectangleF | RectangleF is explicitly cast to a Microsoft.Maui.Graphics.Rect. |
Returns
| Type | Description |
|---|---|
| Microsoft.Maui.Graphics.Rect |
Implicit(RectangleF to RectF)
Implicitly casts to Microsoft.Maui.Graphics.RectF objects from RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support Microsoft.Maui.Graphics.RectF as well.
Declaration
public static implicit operator RectF(RectangleF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | RectangleF | RectangleF is explicitly cast to a Microsoft.Maui.Graphics.RectF. |
Returns
| Type | Description |
|---|---|
| Microsoft.Maui.Graphics.RectF |
Implicit(RectangleF to RectangleF)
Implicitly casts to SixLabors.ImageSharp.RectangleF objects from RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support SixLabors.ImageSharp.RectangleF as well.
Declaration
public static implicit operator RectangleF(RectangleF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | RectangleF | RectangleF is explicitly cast to a SixLabors.ImageSharp.RectangleF. |
Returns
| Type | Description |
|---|---|
| SixLabors.ImageSharp.RectangleF |
Implicit(RectangleF to SKRect)
Implicitly casts to SkiaSharp.SKRect objects from RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support SkiaSharp.SKRect as well.
Declaration
public static implicit operator SKRect(RectangleF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | RectangleF | RectangleF is explicitly cast to a SkiaSharp.SKRect. |
Returns
| Type | Description |
|---|---|
| SkiaSharp.SKRect |
Implicit(RectangleF to RectangleF)
Implicitly casts to System.Drawing.RectangleF objects from RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support RectangleF as well.
Declaration
public static implicit operator RectangleF(RectangleF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| RectangleF | RectangleF | RectangleF is explicitly cast to a System.Drawing.RectangleF. |
Returns
| Type | Description |
|---|---|
| System.Drawing.RectangleF |
Implicit(Rect to RectangleF)
Implicitly casts Microsoft.Maui.Graphics.Rect objects to RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support Microsoft.Maui.Graphics.Rect as well.
Declaration
public static implicit operator RectangleF(Rect RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Maui.Graphics.Rect | RectangleF | Microsoft.Maui.Graphics.Rect will automatically be casted to RectangleF. |
Returns
| Type | Description |
|---|---|
| RectangleF |
Implicit(RectF to RectangleF)
Implicitly casts Microsoft.Maui.Graphics.RectF objects to RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support Microsoft.Maui.Graphics.RectF as well.
Declaration
public static implicit operator RectangleF(RectF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Maui.Graphics.RectF | RectangleF | Microsoft.Maui.Graphics.RectF will automatically be casted to RectangleF. |
Returns
| Type | Description |
|---|---|
| RectangleF |
Implicit(RectangleF to RectangleF)
Implicitly casts SixLabors.ImageSharp.RectangleF objects to RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support SixLabors.ImageSharp.RectangleF as well.
Declaration
public static implicit operator RectangleF(RectangleF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| SixLabors.ImageSharp.RectangleF | RectangleF | SixLabors.ImageSharp.RectangleF will automatically be casted to RectangleF. |
Returns
| Type | Description |
|---|---|
| RectangleF |
Implicit(SKRect to RectangleF)
Implicitly casts SkiaSharp.SKRect objects to RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support SkiaSharp.SKRect as well.
Declaration
public static implicit operator RectangleF(SKRect sKRect)
Parameters
| Type | Name | Description |
|---|---|---|
| SkiaSharp.SKRect | sKRect | SkiaSharp.SKRect will automatically be casted to RectangleF. |
Returns
| Type | Description |
|---|---|
| RectangleF |
Implicit(RectangleF to RectangleF)
Implicitly casts System.Drawing.RectangleF objects to RectangleF.
When your .NET Class methods use RectangleF as parameters and return types, you now automatically support RectangleF as well.
Declaration
public static implicit operator RectangleF(RectangleF RectangleF)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Drawing.RectangleF | RectangleF | System.Drawing.RectangleF will automatically be casted to RectangleF. |
Returns
| Type | Description |
|---|---|
| RectangleF |