text rotation is sucky.

This commit is contained in:
Will Charczuk 2016-08-31 22:11:52 -07:00
parent 102f7a8aa3
commit b78f2327aa
8 changed files with 140 additions and 12 deletions

14
box.go
View file

@ -219,3 +219,17 @@ func (b Box) OuterConstrain(bounds, other Box) Box {
}
return newBox
}
// Rotate rotates a box's corners by a given radian rotation angle.
func (b Box) Rotate(radians float64) Box {
cx, cy := b.Center()
ltx, lty := Math.RotateCoordinate(cx, cy, b.Left, b.Top, radians)
rbx, rby := Math.RotateCoordinate(cx, cy, b.Right, b.Bottom, radians)
return Box{
Top: lty,
Left: ltx,
Right: rbx,
Bottom: rby,
}
}