image path helper functions
This commit is contained in:
@@ -8,13 +8,18 @@ import (
|
||||
)
|
||||
|
||||
type Render struct {
|
||||
Image string
|
||||
Width int
|
||||
Height int
|
||||
Visible bool
|
||||
Image string
|
||||
Width int
|
||||
Height int
|
||||
Visible bool
|
||||
cachedImage image.Image
|
||||
}
|
||||
|
||||
func (ro *Render) GetImage() image.Image {
|
||||
if ro.cachedImage != nil {
|
||||
return ro.cachedImage
|
||||
}
|
||||
|
||||
file, err := ioutil.ReadFile(ro.Image)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -24,5 +29,6 @@ func (ro *Render) GetImage() image.Image {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ro.cachedImage = img
|
||||
return img
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user