Example #1
0
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),
	}
}
Example #2
0
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)
}
Example #3
0
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)
}
Example #4
0
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)
}
Example #5
0
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})
}
Example #6
0
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})
}
Example #7
0
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)
}
Example #8
0
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)
}
Example #9
0
func (a Box) Top(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.t}).Equal(x)
}
Example #10
0
func (a Box) Z(z float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.z}).Equal(z)
}
Example #11
0
func (a Box) Bottom(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.b}).Equal(x)
}
Example #12
0
func (a Box) End(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.r}).Equal(x)
}
Example #13
0
func (a Box) Start(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.l}).Equal(x)
}
Example #14
0
func (a Box) Height(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.t}, simplex.Coef{-1, a.b}).Equal(x)
}
Example #15
0
func (a Box) Width(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.r}, simplex.Coef{-1, a.l}).Equal(x)
}