util

package
v0.0.0-...-34c5bf1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorToHex

func ColorToHex(c color.RGBA) string

ColorToHex turns a color.RGBA into a hexadecimal color code e.g. #FBEE13. The alpha value is ignored.

func ExactlyOne

func ExactlyOne(bs ...bool) bool

ExactlyOne returns true iff one of the given booleans is true

func HexToColor

func HexToColor(s string) (c color.RGBA, err error)

HexToColor turns a hexadecimal color code (e.g. #FBEE13) into a color.RGBA.

func RemoveWhitespaceStrings

func RemoveWhitespaceStrings(a []string) []string

RemoveWhitespaceStrings removes any strings from the input slice that contain only whitespace and trims whitespace from the remaining lines.

func UniqueStr

func UniqueStr(slice []string) []string

UniqueStr removes duplicates from a string slice

Types

type RGB

type RGB color.RGBA

RGB is an alias for color.RGBA but with JSON marshaling methods that convert to & from hexadecimal color codes.

func (*RGB) MarshalJSON

func (r *RGB) MarshalJSON() ([]byte, error)

MarshalJSON converts the RGB color into a hex value (e.g. "#FBEE13")

func (*RGB) ToHex

func (r *RGB) ToHex() string

ToHex returns the hexadecimal representation of the RGB value, e.g. #FBEE13. The alpha value is ignored.

func (*RGB) UnmarshalJSON

func (r *RGB) UnmarshalJSON(b []byte) error

UnmarshalJSON converts a hex value (e.g. "#FF0000") to an RGB struct

Jump to

Keyboard shortcuts

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