duande9301
duande9301
2019-03-06 07:13
浏览 283
已采纳

在Go中使用color.RGBA结构类型创建新颜色时,出现错误,指出整数格式错误

I am trying to create a color pallete using

var palette = []color.Color{color.RGBA{0xRR, 0xGG, 0xBB, 0xff},color.Black}

but I am getting this error:

./lissajous.go:13:40: malformed integer constant: 0x
./lissajous.go:13:42: malformed hex constant
./lissajous.go:13:42: syntax error: unexpected RR, expecting comma or }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douxiapi4381
    douxiapi4381 2019-03-06 07:31
    已采纳

    Invalid value 0xRR, 0XGG in Original code. Not a number literal.

    example is

    palette := []color.Color{color.RGBA{255, 0, 0, 255}, color.Black}
    

    color.RGBA type has uint8. so has valid values 0 <= C <= A.

    golang.org/pkg/image/color/#RGBA

    点赞 评论

相关推荐