Created
November 28, 2016 13:35
-
-
Save NetguruGist/e6530f0dccbee5690b03aba8e7f20213 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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