Search Results for

    Show / Hide Table of Contents

    Class PointF

    Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional plane.

    Inheritance
    System.Object
    PointF
    Namespace: IronSoftware.Drawing
    Assembly: IronSoftware.Drawing.Common.dll
    Syntax
    public class PointF : Object

    Precise sub-pixel positioning in cross-platform .NET graphics relies on PointF, a lightweight coordinate record that stores an ordered pair of single-precision floating-point values as X and Y. Wherever IronDrawing needs to express a location on a two-dimensional plane, such as a text anchor, a crop origin, or a shape vertex, PointF is the common currency that travels between rendering engines without losing fractional precision.

    Construct a point with new PointF(float x, float y) and read or update its position through the X and Y properties, both of which are mutable. To shift a point relative to its current location, call Offset(float dx, float dy), which adds the supplied deltas directly to X and Y in place. This avoids allocating a replacement instance when only a translation is needed, which is common in layout loops that nudge elements by a fixed margin.

    PointF integrates smoothly with SkiaSharp through a set of implicit conversion operators. An SKPoint converts to PointF automatically, and a PointF converts back to SKPoint, so code that mixes IronDrawing APIs with direct SkiaSharp calls requires no explicit casts. Additional implicit operators cover the System.Drawing.PointF type and related platform point types, meaning a value obtained from one graphics subsystem passes directly into another. Equals and GetHashCode are overridden so that PointF instances compare by coordinate value rather than reference, making them safe to use as dictionary keys or in LINQ distinct operations.

    Because PointF derives from Object and carries no unmanaged resources, no disposal step is required. It is a plain, allocatable value-holder that fits naturally into collections, tuples, and return types throughout the IronDrawing surface.

    using IronSoftware.Drawing;
    
    // Build a point, shift it, then use it as an SKPoint implicitly.
    var origin = new PointF(12.5f, 34.75f);
    origin.Offset(5f, -10f);          // origin is now (17.5, 24.75)
    
    SkiaSharp.SKPoint skPt = origin;  // implicit operator, no cast needed
    Console.WriteLine($"SKPoint: {skPt.X}, {skPt.Y}");

    Explore further with the IronDrawing documentation, the Point & PointF examples, and the Generate AnyBitmap example.

    Constructors

    PointF(Single, Single)

    Initializes a new instance of the PointF struct with the specified coordinates.

    Declaration
    public PointF(float x, float y)
    Parameters
    Type Name Description
    System.Single x
    System.Single y

    Properties

    X

    Gets or sets the x-coordinate of this PointF.

    Declaration
    public float X { get; set; }
    Property Value
    Type Description
    System.Single

    Y

    Gets or sets the y-coordinate of this PointF.

    Declaration
    public float Y { get; set; }
    Property Value
    Type Description
    System.Single

    Methods

    Equals(Object)

    Specifies whether this PointF instance contains the same coordinates as another PointF.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj

    The point to test for equality.

    Returns
    Type Description
    System.Boolean

    true if other has the same coordinates as this point instance.

    GetHashCode()

    Hashing integer based on image raw binary data.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32

    Int

    Offset(Single, Single)

    Translates this PointF by the specified amount.

    Declaration
    public void Offset(float dx, float dy)
    Parameters
    Type Name Description
    System.Single dx

    The amount to offset the x-coordinate.

    System.Single dy

    The amount to offset the y-coordinate.

    Operators

    Implicit(PointF to PointF)

    Implicitly casts PointF objects to Microsoft.Maui.Graphics.Point

    Declaration
    public static implicit operator PointF(PointF point)
    Parameters
    Type Name Description
    PointF point

    PointF will automatically be casted to Microsoft.Maui.Graphics.Point

    Returns
    Type Description
    Microsoft.Maui.Graphics.PointF

    Implicit(PointF to PointF)

    Implicitly casts a PointF object to SixLabors.ImageSharp.PointF

    Declaration
    public static implicit operator PointF(PointF point)
    Parameters
    Type Name Description
    PointF point

    PointF will automatically be casted to SixLabors.ImageSharp.PointF

    Returns
    Type Description
    SixLabors.ImageSharp.PointF

    Implicit(PointF to SKPoint)

    Implicitly casts PointF objects to SkiaSharp.SKPoint

    Declaration
    public static implicit operator SKPoint(PointF point)
    Parameters
    Type Name Description
    PointF point

    PointF will automatically be casted to SkiaSharp.SKPoint

    Returns
    Type Description
    SkiaSharp.SKPoint

    Implicit(PointF to PointF)

    Implicitly casts Microsoft.Maui.Graphics.Point objects to PointF

    Declaration
    public static implicit operator PointF(PointF point)
    Parameters
    Type Name Description
    Microsoft.Maui.Graphics.PointF point

    Microsoft.Maui.Graphics.Point will automatically be casted to PointF

    Returns
    Type Description
    PointF

    Implicit(PointF to PointF)

    Implicitly casts SixLabors.ImageSharp.PointF objects to PointF

    Declaration
    public static implicit operator PointF(PointF point)
    Parameters
    Type Name Description
    SixLabors.ImageSharp.PointF point

    SixLabors.ImageSharp.PointF will automatically be casted to PointF

    Returns
    Type Description
    PointF

    Implicit(SKPoint to PointF)

    Implicitly casts SkiaSharp.SKPoint objects to PointF

    Declaration
    public static implicit operator PointF(SKPoint point)
    Parameters
    Type Name Description
    SkiaSharp.SKPoint point

    SkiaSharp.SKPoint will automatically be casted to PointF

    Returns
    Type Description
    PointF
    ☀
    ☾
    Downloads
    • Download with Nuget
    In This Article
    Back to top
    Install with Nuget