-
Notifications
You must be signed in to change notification settings - Fork 0
Geometry
Dustin Horne edited this page Mar 5, 2026
·
1 revision
Namespace: ParentElement.RichText.Core.Geometry
Platform-agnostic geometry value types used throughout the editor API. All three types provide SkiaSharp conversion helpers and are interchangeable with their SkiaSharp counterparts at rendering boundaries.
A 2D coordinate in pixel space.
public struct Pointpublic Point(float x, float y)| Property | Type | Description |
|---|---|---|
X |
float |
Horizontal coordinate in pixels |
Y |
float |
Vertical coordinate in pixels |
| Method | Returns | Description |
|---|---|---|
ToSkia() |
SKPoint |
Convert to a SkiaSharp SKPoint
|
FromView(ViewModifier) |
Point |
Transform from view (screen) space into document space |
FromView applies the inverse of the viewport's scale and offset to map a screen-space pointer coordinate to a document-space coordinate:
documentX = screenX / view.Scale.X + view.ScaledOffset.X
documentY = screenY / view.Scale.X + view.ScaledOffset.Y
var screen = new Point(pointerX, pointerY);
var document = screen.FromView(viewModifier);
editor.Click(document);An immutable axis-aligned rectangle defined by its origin and size.
public struct Rectangle| Signature | Description |
|---|---|
Rectangle(float x, float y, float width, float height) |
Explicit position and size |
Rectangle(float width, float height) |
Positioned at the origin (0, 0)
|
Rectangle(Rectangle other) |
Copy constructor |
| Property | Type | Description |
|---|---|---|
X |
float |
X-coordinate of the left edge |
Y |
float |
Y-coordinate of the top edge |
Width |
float |
Width in pixels |
Height |
float |
Height in pixels |
Top |
float |
Alias for Y
|
Bottom |
float |
Y + Height |
Left |
float |
Alias for X
|
Right |
float |
X + Width |
TopLeft |
Point |
Top-left corner |
TopRight |
Point |
Top-right corner |
BottomLeft |
Point |
Bottom-left corner |
BottomRight |
Point |
Bottom-right corner |
Center |
Point |
Center point |
| Method | Returns | Description |
|---|---|---|
Inflate(float) |
Rectangle |
Expand width and height uniformly; position unchanged |
Inflate(float, float) |
Rectangle |
Expand width and height independently; position unchanged |
Deflate(float) |
Rectangle |
Shrink width and height uniformly; position unchanged |
Deflate(float, float) |
Rectangle |
Shrink width and height independently; position unchanged |
ToSkia() |
SKRect |
Convert to a SkiaSharp SKRect
|
Note:
InflateandDeflatedo not move the origin — they grow or shrink the rectangle by adjustingWidthandHeightonly.
var viewport = new Rectangle(0, 0, 800, 600);
// Set visible bounds with a 4px inset
editor.VisibleBounds = viewport.Deflate(4);
// Check if a point is within bounds
bool inside = point.X >= viewport.Left && point.X <= viewport.Right
&& point.Y >= viewport.Top && point.Y <= viewport.Bottom;
// Convert for Skia clipping
canvas.ClipRect(viewport.ToSkia());A width/height pair in pixels.
public struct Sizepublic Size(float width, float height)| Property | Type | Description |
|---|---|---|
Width |
float |
Width component in pixels |
Height |
float |
Height component in pixels |
var pageSize = new Size(816, 1056); // US Letter at 96 dpiSee also: Data-Structures · IDocumentController