Rect
A rectangle by its top-left corner and its size, never negative, written as SVG writes a viewBox: 0 0 300 200.
Media and visual; not ordered; since Jadpo 0.1.0.
Make one
Build one from its fields, Rect { x: ... y: ... width: ... }.
text.parse(raw, as: Rect) reads one from its text; text that isn't one at all fails malformed, such as 0,0,300,200, 0 0 -1 200 or 0 0 300 -0.5.
Fields
| Field | Type |
|---|---|
x |
Decimal |
y |
Decimal |
width |
Decimal |
height |
Decimal |
Text, JSON and storage
text.from writes its canonical text, the one form text.parse reads back. JSON sends an object of its parts.
| Text | JSON |
|---|---|
0 0 300 200 |
{"x":"0","y":"0","width":"300","height":"200"} |
-10.5 20 300.25 0 |
{"x":"-10.5","y":"20","width":"300.25","height":"0"} |
12 8 0.5 1.50 |
{"x":"12","y":"8","width":"0.5","height":"1.50"} |
It is stored in 4 columns, each named for the field, _ and its suffix. This is -10.5 20 300.25 0:
| Column | Type | Holds |
|---|---|---|
<field>_x |
numeric |
-10.5 |
<field>_y |
numeric |
20 |
<field>_width |
numeric |
300.25 |
<field>_height |
numeric |
0 |
Shown to people
text.format(value, locale:) shows it to people in their locale.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
0 0 300 200 |
0 0 300 200 |
-10.5 20 300.25 0 |
-10.5 20 300.25 0 |
12 8 0.5 1.50 |
12 8 0.5 1.50 |
Operations
It has the contract's own operations: text.parse, text.from, text.format, json.read, json.write and ==. It isn't ordered, so < and sorting don't take it. Every standard type meets one contract says how they work.
Markdown for agents: /docs/types/type-rect.md.Built from Jadpo main at e00e61f.