+
Skip to content

Foxcapades/golour

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Colors!

Go wrappers and converters for various color formats with no standard library dependency (outside of unit tests).

Intended for use with alternative compilers such as TinyGo for use with JS/WASM build targets.

Currently, golour supports HSV/HSB, HSL, and RGB color formats and can translate between these types.

Each color type can additionally render itself in one or more JS/CSS friendly formats, such as hex strings or CSS color functions.

Examples

RGB From Hex String
package main

import (
	"fmt"
	"github.com/foxcapades/golour/v1/pkg/colors"
)

func main() {
  rgb := colors.NewRGBFromHex("#FFEEDD")
  fmt.Println(rgb)              // Outputs: rgba(255, 238, 221, 255)
  fmt.Println(rgb.HexRGB())     // Outputs: #FFEEDD
  fmt.Println(rgb.CSSFuncRGB()) // Outputs: rgb(255, 238, 221)
  fmt.Println(rgb.ToHSL())      // Outputs: hsla(30, 100%, 93.3%, 1)
}

About

Color format handling and translation library.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载