示例#1
0
文件: color.go 项目: dimiro1/faker
// CMYK returns a valid CMYK color
func (f Faker) CMYK() color.CMYK {
	r := uint8(randomIntBetween(0, 255))
	g := uint8(randomIntBetween(0, 255))
	b := uint8(randomIntBetween(0, 255))

	c, m, y, k := color.RGBToCMYK(r, g, b)

	return color.CMYK{C: c, M: m, Y: y, K: k}
}
示例#2
0
文件: color.go 项目: oov/psd
func nCMYKAModel(c color.Color) color.Color {
	if _, ok := c.(NCMYKA); ok {
		return c
	}
	r, g, b, a := c.RGBA()
	cc, mm, yy, kk := color.RGBToCMYK(uint8(r>>8), uint8(g>>8), uint8(b>>8))
	cc = uint8((uint32(cc) * 0xffff) / a)
	mm = uint8((uint32(mm) * 0xffff) / a)
	yy = uint8((uint32(yy) * 0xffff) / a)
	kk = uint8((uint32(kk) * 0xffff) / a)
	return NCMYKA{255 - cc, 255 - mm, 255 - yy, 255 - kk, uint8(a >> 8)}
}