Skip to content

Instantly share code, notes, and snippets.

@NetguruGist
Created November 28, 2016 13:35
Show Gist options
  • Save NetguruGist/e6530f0dccbee5690b03aba8e7f20213 to your computer and use it in GitHub Desktop.
Save NetguruGist/e6530f0dccbee5690b03aba8e7f20213 to your computer and use it in GitHub Desktop.
func (s *Scene) EachPixel(colorFunction func(int, int) color.RGBA) {
for x := 0; x < s.Width; x++ {
for y := 0; y < s.Height; y++ {
s.setPixel(x, y, colorFunction(x, y))
}
}
}
func TestSceneEachPixelSetsEachPixelToTheProvidedFunctionReturn(t *testing.T) {
scene := NewScene(4, 4)
c := randomColor()
scene.EachPixel(func(x, y int) color.RGBA { return c })
img := generateImage(4, 4, c)
assert.True(t, assert.ObjectsAreEqualValues(img, scene.Img),
"sets every pixel of the image to the provided values")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment