Created
November 13, 2017 22:02
-
-
Save 200sc/db6f2a3d857c4879b24f93a87846a459 to your computer and use it in GitHub Desktop.
This file contains 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
package render | |
func Recolor(cMap[color.Color]color.Color) Modification { | |
return func(rgba image.Image) *image.RGBA { | |
bds := rgba.Bounds() | |
newRgba := image.NewRGBA(bds) | |
for x := 0; x < bds.Max.X; x++ { | |
for y :=0; y < bds.Max.Y; y++ { | |
c := rgba.At(x,y) | |
if c2, ok := cMap[c]; ok { | |
c = c2 | |
} | |
newRgba.Set(x,y,c) | |
} | |
} | |
return newRgba | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment