text rotation is sucky.
This commit is contained in:
parent
102f7a8aa3
commit
b78f2327aa
8 changed files with 140 additions and 12 deletions
14
box.go
14
box.go
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue