-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolor.go
More file actions
40 lines (32 loc) · 793 Bytes
/
color.go
File metadata and controls
40 lines (32 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package math
import (
"image/color"
"math"
)
var (
ColorBlack = Color{R: 0, G: 0, B: 0, A: math.MaxUint16}
ColorWhite = Color{R: math.MaxUint16, G: math.MaxUint16, B: math.MaxUint16, A: math.MaxUint16}
)
type Color struct {
color.Color
R uint16
G uint16
B uint16
A uint16
}
func (col *Color) RGBA() (r, g, b, a uint32) {
return uint32(col.R), uint32(col.G), uint32(col.B), uint32(col.A)
}
func (col *Color) Clone() *Color {
newCol := *col
return &newCol
}
func (col *Color) SetIntensity(intensity float32) *Color {
col.R = uint16(float32(col.R) * intensity)
col.G = uint16(float32(col.G) * intensity)
col.B = uint16(float32(col.B) * intensity)
return col
}
func (col *Color) GetRGBVector() *Vector3 {
return NewVector3(float32(col.R), float32(col.G), float32(col.B))
}