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