package mainimport ("fmt""image/color" )// 定义一个RGBA颜色 type MyColor struct {R, G, B, A uint8 }// 实现color.Color接口 func (c MyColor) RGBA() (r, g, b, a uint32) {r = uint32(c.R)r |= r << 8g = uint32(c.G)g |= g << 8b = uint32(c.B)b |= b << 8a = uint32(c.A)a |= a << 8return }func main() {// 创建一个自定义颜色customColor := MyColor{R: 255, G: 0, B: 0, A: 255} // 红色// 打印颜色的RGBA值fmt.Printf("Custom Color: RGBA(%d, %d, %d, %d)\n", customColor.R, customColor.G, customColor.B, customColor.A)// 使用color.RGBA来创建颜色officialColor := color.RGBA{R: 0, G: 255, B: 0, A: 255} // 绿色fmt.Printf("Official Color: RGBA(%d, %d, %d, %d)\n", officialColor.R, officialColor.G, officialColor.B, officialColor.A) }