Skip to content

Commit

Permalink
Add a from-file image hint to Image
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed May 9, 2018
1 parent b07e546 commit 5853f6b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ui/canvas/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ type Image struct {
Size ui.Size // The current size of the Image
Position ui.Position // The current position of the Image

PixelColor func(x, y, w, h int) color.RGBA
// one of the following sources will provide our image data
PixelColor func(x, y, w, h int) color.RGBA // Render the image from code
File string // Load the image froma file
}

// CurrentSize returns the current size of this image object
Expand Down Expand Up @@ -44,3 +46,10 @@ func NewRaster(pixelColor func(x, y, w, h int) color.RGBA) *Image {
PixelColor: pixelColor,
}
}

// NewImageFromFile creates a new image from a local file
func NewImageFromFile(file string) *Image {
return &Image{
File: file,
}
}

0 comments on commit 5853f6b

Please sign in to comment.