fix Canvas.Draw

This commit is contained in:
faiface 2017-04-12 16:02:39 +02:00
parent c9e0f7262d
commit c61b677fa9
1 changed files with 4 additions and 2 deletions

View File

@ -54,8 +54,6 @@ func NewCanvas(bounds pixel.Rect) *Canvas {
}) })
c.shader = shader c.shader = shader
c.sprite = pixel.NewSprite(c, c.Bounds())
return c return c
} }
@ -121,7 +119,11 @@ func (c *Canvas) SetComposeMethod(cmp pixel.ComposeMethod) {
// 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.
func (c *Canvas) SetBounds(bounds pixel.Rect) { func (c *Canvas) SetBounds(bounds pixel.Rect) {
c.gf.SetBounds(bounds) c.gf.SetBounds(bounds)
if c.sprite == nil {
c.sprite = pixel.NewSprite(nil, pixel.Rect{})
}
c.sprite.Set(c, c.Bounds()) c.sprite.Set(c, c.Bounds())
c.sprite.SetMatrix(pixel.IM.Moved(c.Bounds().Center()))
} }
// Bounds returns the rectangular bounds of the Canvas. // Bounds returns the rectangular bounds of the Canvas.