Skip to content

Instantly share code, notes, and snippets.

@200sc
Created November 13, 2017 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 200sc/db6f2a3d857c4879b24f93a87846a459 to your computer and use it in GitHub Desktop.
Save 200sc/db6f2a3d857c4879b24f93a87846a459 to your computer and use it in GitHub Desktop.
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