Example #1
0
func newSimpleSetFunc(p image.Image) func(x, y int, c color.Color) {
	switch p := p.(type) {
	case draw.Image:
		return p.Set
	case *image.YCbCr:
		return func(x, y int, c color.Color) {
			c1 := color.YCbCrModel.Convert(c).(color.YCbCr)
			yi := p.YOffset(x, y)
			ci := p.COffset(x, y)
			p.Y[yi] = c1.Y
			p.Cb[ci] = c1.Cb
			p.Cr[ci] = c1.Cr
		}
	case *image.Uniform:
		return func(x, y int, c color.Color) {
			p.C = c
		}
	default:
		return nil
	}
}