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.
| Member | Type | Description |
|---|---|---|
| X | float | Horizontal coordinate |
| Y | float | Vertical coordinate |
| Point(float x, float y) | ctor | Construct from X and Y |
| ToSkia() | SKPoint | Convert to SkiaSharp SKPoint |
| FromView(ViewModifier view) | Point | Convert 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
structAn axis-aligned rectangle in document space. Used for the viewport bounds and image bounding rects.
| Member | Type | Description |
|---|---|---|
| X, Y | float | Top-left corner coordinates |
| Width, Height | float | Dimensions |
| Top, Bottom, Left, Right | float | Computed edge coordinates |
| TopLeft, TopRight, BottomLeft, BottomRight, Center | Point | Corner and center points |
| Rectangle(float x, float y, float w, float h) | ctor | Full constructor |
| Rectangle(float width, float height) | ctor | Width/height with origin at (0, 0) |
| Inflate(float w, float h) | Rectangle | Returns a new rectangle expanded by the given amounts on each axis |
| Inflate(float amount) | Rectangle | Expand equally on both axes |
| Deflate(float w, float h) | Rectangle | Returns a new rectangle shrunk by the given amounts |
| Deflate(float amount) | Rectangle | Shrink equally on both axes |
| ToSkia() | SKRect | Convert to SkiaSharp SKRect |
// Set the viewport when the control is resized
controller.VisibleBounds = new Rectangle(
(float)Bounds.Width,
(float)Bounds.Height
);
Size
structA simple width × height pair with no position information.
| Member | Type | Description |
|---|---|---|
| Width | float | Width component |
| Height | float | Height component |
| Size(float width, float height) | ctor | Construct 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.
| Member | Type | Description |
|---|---|---|
| Scale | Vector2 | Current zoom scale (default: 1, 1) |
| Offset | Vector2 | Current scroll offset in pixels |
| ScaledOffset | Vector2 | Computed: Offset / Scale — use for coordinate conversion |