fix consistency in Canvas.SetBounds

This commit is contained in:
faiface 2017-03-14 19:27:28 +01:00
parent cb3276493d
commit 07ecae706d
1 changed files with 2 additions and 4 deletions

View File

@ -159,14 +159,12 @@ func (c *Canvas) SetColorMask(col color.Color) {
// SetBounds resizes the Canvas to the new bounds. Old content will be preserved. // SetBounds resizes the Canvas to the new bounds. Old content will be preserved.
// //
// If the new Bounds fit into the Original capacity bounds, no new Canvas will be allocated. // If the new Bounds fit into the Original borders, no new Canvas will be allocated.
func (c *Canvas) SetBounds(bounds pixel.Rect) { func (c *Canvas) SetBounds(bounds pixel.Rect) {
c.bounds = bounds c.bounds = bounds
// if this bounds fit into the original bounds, no need to reallocate // if this bounds fit into the original bounds, no need to reallocate
borX, borY, borW, borH := intBounds(c.orig.borders) if c.orig.borders.Contains(bounds.Min) && c.orig.borders.Contains(bounds.Max) {
bndX, bndY, bndW, bndH := intBounds(bounds)
if borX <= bndX && bndX+bndW <= borX+borW && borY <= bndY && bndY+bndH <= borY+borH {
return return
} }