示例#1
0
func avgColor(neighbours ...image.RGBAColor) (image.Color, os.Error) {
	weight := len(neighbours)
	var R, G, B, A int
	var avg image.RGBAColor
	if weight != 0 {
		for _, c := range neighbours {
			R += int(c.R)
			G += int(c.G)
			B += int(c.B)
			A += int(c.A)
		}
		avg.R = uint8(R / weight)
		avg.G = uint8(G / weight)
		avg.B = uint8(B / weight)
		avg.A = uint8(A / weight)
		return avg, nil
	}
	return avg, os.NewError("zero arguments")
}
示例#2
0
文件: line.go 项目: twolfe18/sudoku
func (l Line) Draw(img draw.Image, c image.RGBAColor) {
	for _, wp := range l.WeightedIterator() {
		c.A = uint8(wp.W * 255.0)
		img.Set(wp.P.X, wp.P.Y, c)
	}
}