color

package
v12.15.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package color provides methods for working with colors

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HSB2RGB

func HSB2RGB(h, s, b int) (int, int, int)

HSB2RGB convert HSB (HSV) color to RGB

Example
r, g, b := HSB2RGB(331, 81, 50)

fmt.Printf("r:%d g:%d b:%d\n", r, g, b)
Output:

r:128 g:24 b:74

func Hex2RGB

func Hex2RGB(h int) (int, int, int)

Hex2RGB convert Hex color to RGB

Example
r, g, b := Hex2RGB(0x7F194B)

fmt.Printf("r:%d g:%d b:%d\n", r, g, b)
Output:

r:127 g:25 b:75

func Hex2RGBA

func Hex2RGBA(h int64) (int, int, int, int)

Hex2RGBA convert Hex color to RGBA

Example
r, g, b, a := Hex2RGBA(0x7F194BCC)

fmt.Printf("r:%d g:%d b:%d a:%d\n", r, g, b, a)
Output:

r:127 g:25 b:75 a:204

func IsRGBA

func IsRGBA(h int64) bool

IsRGBA if Hex coded color has alpha channel info

Example
fmt.Println(IsRGBA(0xAABBCC))
fmt.Println(IsRGBA(0xAABBCCDD))
Output:

false
true

func RGB2HSB

func RGB2HSB(r, g, b int) (int, int, int)

RGB2HSB convert RGB color to HSB (HSV)

Example
h, s, v := RGB2HSB(127, 25, 75)

fmt.Printf("h:%d s:%d v:%d\n", h, s, v)
Output:

h:331 s:81 v:50

func RGB2Hex

func RGB2Hex(r, g, b int) int

RGB2Hex convert RGB color to Hex

Example
fmt.Printf("%x\n", RGB2Hex(127, 25, 75))
Output:

7f194b

func RGB2Term

func RGB2Term(r, g, b int) int

RGB2Term convert rgb color to terminal color code https://misc.flogisoft.com/bash/tip_colors_and_formatting#colors1

func RGBA2Hex

func RGBA2Hex(r, g, b, a int) int64

RGBA2Hex convert RGBA color to Hex

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL