func (a Box) Bounds(l, r, b, t float32) []simplex.Constraint { return []simplex.Constraint{ simplex.Constrain(simplex.Coef{1, a.l}).GreaterEq(l), simplex.Constrain(simplex.Coef{1, a.r}).LessEq(r), simplex.Constrain(simplex.Coef{1, a.b}).GreaterEq(b), simplex.Constrain(simplex.Coef{1, a.t}).LessEq(t), } }
func (a Box) Above(b Box, by float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.b}, simplex.Coef{-1, b.t}).GreaterEq(by) }
func (a Box) Before(b Box, by float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, b.l}, simplex.Coef{-1, a.r}).GreaterEq(by) }
func (a Box) After(b Box, by float32) simplex.Constraint { // TODO this is the crux of adaptive layout model, along with a Before method. // Consider how box a would be after box b if room, otherwise box a is below box b. // Note in the latter case, box a should not be aligned after box b when below. return simplex.Constrain(simplex.Coef{1, a.l}, simplex.Coef{-1, b.r}).GreaterEq(by) }
func (a Box) CenterVerticalIn(b Box) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, b.b}, simplex.Coef{1, b.t}, simplex.Coef{-1, a.b}, simplex.Coef{-1, a.t}) }
func (a Box) CenterHorizontalIn(b Box) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, b.l}, simplex.Coef{1, b.r}, simplex.Coef{-1, a.l}, simplex.Coef{-1, a.r}) }
func (a Box) StartIn(b Box, by float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.l}, simplex.Coef{-1, b.l}).GreaterEq(by) }
func (a Box) BottomIn(b Box, by float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.b}, simplex.Coef{-1, b.b}).GreaterEq(by) }
func (a Box) Top(x float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.t}).Equal(x) }
func (a Box) Z(z float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.z}).Equal(z) }
func (a Box) Bottom(x float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.b}).Equal(x) }
func (a Box) End(x float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.r}).Equal(x) }
func (a Box) Start(x float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.l}).Equal(x) }
func (a Box) Height(x float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.t}, simplex.Coef{-1, a.b}).Equal(x) }
func (a Box) Width(x float32) simplex.Constraint { return simplex.Constrain(simplex.Coef{1, a.r}, simplex.Coef{-1, a.l}).Equal(x) }