image: Cache size

This commit is contained in:
Hajime Hoshi 2015-02-18 04:01:11 +09:00
parent e366e1c6f3
commit 95316a1de5

View File

@ -30,11 +30,16 @@ type Image struct {
framebuffer *graphics.Framebuffer
texture *graphics.Texture
pixels []uint8
width int
height int
}
// Size returns the size of the image.
func (i *Image) Size() (width, height int) {
return i.framebuffer.Size()
if i.width == 0 {
i.width, i.height = i.framebuffer.Size()
}
return i.width, i.height
}
// Clear resets the pixels of the image into 0.