Beispiel #1
0
func (a Box) Bounds(l, r, b, t float32) []simplex.Constraint {
	return []simplex.Constraint{
		simplex.Constrain(simplex.Coef{1, a.l}).GreaterEq(float64(l)),
		simplex.Constrain(simplex.Coef{1, a.r}).LessEq(float64(r)),
		simplex.Constrain(simplex.Coef{1, a.b}).GreaterEq(float64(b)),
		simplex.Constrain(simplex.Coef{1, a.t}).LessEq(float64(t)),
	}
}
Beispiel #2
0
func (a Box) AlignTops(b Box, by float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, b.t}, simplex.Coef{-1, a.t}).GreaterEq(float64(by))
}
Beispiel #3
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(float64(by))
}
Beispiel #4
0
func (a Box) Below(b Box, by float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, b.b}, simplex.Coef{-1, a.t}).GreaterEq(float64(by))
}
Beispiel #5
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})
}
Beispiel #6
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(float64(by))
}
Beispiel #7
0
func (a Box) Z(z float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.z}).Equal(float64(z))
}
Beispiel #8
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})
}
Beispiel #9
0
func (a Box) Top(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.t}).Equal(float64(x))
}
Beispiel #10
0
func (a Box) Bottom(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.b}).Equal(float64(x))
}
Beispiel #11
0
func (a Box) Start(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.l}).Equal(float64(x))
}
Beispiel #12
0
func (a Box) Height(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.t}, simplex.Coef{-1, a.b}).Equal(float64(x))
}
Beispiel #13
0
func (a Box) Width(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.r}, simplex.Coef{-1, a.l}).Equal(float64(x))
}