示例#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),
	}
}
示例#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)
}
示例#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)
}
示例#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)
}
示例#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})
}
示例#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})
}
示例#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)
}
示例#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)
}
示例#9
0
func (a Box) Top(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.t}).Equal(x)
}
示例#10
0
func (a Box) Z(z float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.z}).Equal(z)
}
示例#11
0
func (a Box) Bottom(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.b}).Equal(x)
}
示例#12
0
func (a Box) End(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.r}).Equal(x)
}
示例#13
0
func (a Box) Start(x float32) simplex.Constraint {
	return simplex.Constrain(simplex.Coef{1, a.l}).Equal(x)
}
示例#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)
}
示例#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)
}