Point

struct

A 2D point in document (canvas) coordinate space. All pointer events received from the UI layer must be converted to document Point before being passed to DocumentController.

MemberTypeDescription
XfloatHorizontal coordinate
YfloatVertical coordinate
Point(float x, float y)ctorConstruct from X and Y
ToSkia()SKPointConvert to SkiaSharp SKPoint
FromView(ViewModifier view)PointConvert from view (screen) coordinates to document coordinates accounting for scroll and zoom
// In an Avalonia pointer handler:
var avPos = e.GetPosition(this);
var docPos = new Point((float)avPos.X, (float)avPos.Y);
controller.Click(docPos);

Rectangle

struct

An axis-aligned rectangle in document space. Used for the viewport bounds and image bounding rects.

MemberTypeDescription
X, YfloatTop-left corner coordinates
Width, HeightfloatDimensions
Top, Bottom, Left, RightfloatComputed edge coordinates
TopLeft, TopRight, BottomLeft, BottomRight, CenterPointCorner and center points
Rectangle(float x, float y, float w, float h)ctorFull constructor
Rectangle(float width, float height)ctorWidth/height with origin at (0, 0)
Inflate(float w, float h)RectangleReturns a new rectangle expanded by the given amounts on each axis
Inflate(float amount)RectangleExpand equally on both axes
Deflate(float w, float h)RectangleReturns a new rectangle shrunk by the given amounts
Deflate(float amount)RectangleShrink equally on both axes
ToSkia()SKRectConvert to SkiaSharp SKRect
// Set the viewport when the control is resized
controller.VisibleBounds = new Rectangle(
    (float)Bounds.Width,
    (float)Bounds.Height
);

Size

struct

A simple width × height pair with no position information.

MemberTypeDescription
WidthfloatWidth component
HeightfloatHeight component
Size(float width, float height)ctorConstruct from dimensions

ViewModifier

struct

Tracks the viewport's scroll offset and zoom scale, used to convert between screen and document coordinates. DocumentController maintains this internally; you rarely need to construct one yourself.

MemberTypeDescription
ScaleVector2Current zoom scale (default: 1, 1)
OffsetVector2Current scroll offset in pixels
ScaledOffsetVector2Computed: Offset / Scale — use for coordinate conversion