去画在图像蒙版上

I am trying to draw over an image using a template, the template image is the following

enter image description here

I want to colorize the image red, green, blue and yellow colors with custom colors and achieve something like this:

enter image description here

In order to achieve this I currently use this image as a base

enter image description here

And then draw over the template using draw.Draw(outfitImage, outfitImage.Bounds(), generatorImage, image.ZP, draw.Over)

This however gives a very weird result (nothing near the expected result), this is how I replace pixels

func paintPixels(img *image.NRGBA, base color.Color, dst color.Color) {
    br, bg, bb, ba := base.RGBA()
    dr, dg, db, _ := dst.RGBA()
    for x := 0; x < img.Bounds().Dx(); x++ {
        for y := 0; y < img.Bounds().Dy(); y++ {
            r, g, b, a := img.At(x, y).RGBA()
            if br == r && bg == g && bb == b && ba == a {
                img.Set(x, y, color.RGBA{uint8(dr), uint8(dg), uint8(db), 255})
            }
        }
    }
}

enter image description here

The result can vary depending on the alpha value I use when colorizing the image template. So I cant think of a way to achieve the expected result, I guess I should use a mask with draw.DrawMask but I have no clue where to start or how to achieve the result I am looking for

You look like you're just replacing pixels with the colour if all components match. If you look at the compositing methods in bild/blend you should find one that suits you for combining images - you probably want Opacity or Multiply modes and could extract code from this file:

https://github.com/anthonynsimon/bild/blob/master/blend/blend.go