...
Source file
src/tawesoft.co.uk/go/ximage/xcolor/rg.go
Documentation:
src/tawesoft.co.uk/go/ximage/xcolor/rg.go
1
2
3
4
5
6 package xcolor
7
8 import (
9 "image/color"
10 )
11
12
13 type RG struct {
14 R uint8
15 G uint8
16 }
17
18 func (c RG) RGBA() (r, g, b, a uint32) {
19 r = uint32(c.R)
20 r |= r << 8
21 g = uint32(c.G)
22 g |= g << 8
23 return r, g, 0, 0xFFFF
24 }
25
26 var RGModel color.Model = color.ModelFunc(func (c color.Color) color.Color {
27 if _, ok := c.(color.RGBA); ok {
28 return c
29 }
30 r, g, _, _ := c.RGBA()
31 return RG{uint8(r >> 8), uint8(g >> 8)}
32 })
33
View as plain text