aboutsummaryrefslogtreecommitdiffstats
path: root/lay/strain/bound.go
diff options
context:
space:
mode:
Diffstat (limited to 'lay/strain/bound.go')
-rw-r--r--lay/strain/bound.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/lay/strain/bound.go b/lay/strain/bound.go
new file mode 100644
index 0000000..f1d4488
--- /dev/null
+++ b/lay/strain/bound.go
@@ -0,0 +1,28 @@
+package strain
+
+import "golang.org/x/exp/shiny/unit"
+
+// Bounds places the inclusive lower and upper bounds [Min, Max]
+// on a dimension. A negative value means there is no bound.
+// If both Min and Max are non-negative, then it is well formed if
+// Min <= Max.
+type Bounds struct {
+ Min, Max unit.Value
+}
+
+// BoundedPoint is a point with bounds on its horizontal/vertical
+// position.
+type BoundedPoint struct {
+ X, Y Bounds
+}
+
+// Free returns an unconstrained value (negative Min and Max).
+func Free() Bounds {
+ return Bounds{unit.Pixels(-1), unit.Pixels(-1)}
+}
+
+// FreePoint returns an unconstrained point (negative Min and Max
+// in both dimensions).
+func FreePoint() BoundedPoint {
+ return BoundedPoint{Free(), Free()}
+}