image/draw

Guided tour · Image · pkg.go.dev →

Compose images: copy, blend, mask. The building block for simple image manipulation.

Draw operations

Copy (Src) vs blend (Over)

draw.Draw(dst, dst.Bounds(), src, image.Point{}, draw.Src)  // replace
draw.Draw(dst, dst.Bounds(), src, image.Point{}, draw.Over) // alpha blend

Solid fill

draw.Draw(img, img.Bounds(), &image.Uniform{color.White}, image.Point{}, draw.Src)

Masked draw

draw.DrawMask(dst, r, src, image.Point{}, mask, image.Point{}, draw.Over)