Skip to content

bubblestudent/gocolournamer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Colour Namer

Using this project

Install the package

$ go get github.com/bubblestudent/gocolournamer

Then add the import to the top of whichever file you want to use the package in

import "github.com/bubblestudent/gocolournamer"

All of the packages functionality is exposed in one method. ToNearestColour is called with a valid hex colour and returns the named struct and an error.

named, err := gocolournamer.ToNearestColour(hexstring)

Additional documentation available on godoc: http://godoc.org/github.com/bubblestudent/gocolournamer

Example program

package main

import (
	"encoding/json"
	"fmt"

	"github.com/bubblestudent/gocolournamer"
)

func main() {
	hex := "#905E26" //hash is optional
	named, err := gocolournamer.ToNearestColour(hex)
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	out, _ := json.Marshal(named)
	fmt.Printf("%s", string(out))
}

The above program outputs

{"hex":"905E26","colour":"Afghan Tan","hue":"Yellow","huehex":"FFFF00"}

Inpsiration

Idea and colour list from http://chir.ag/projects/ntc/ javascript implementation.

Lisence

Distributed free for any use under an MIT licence.

About

Package to get specific and general shade / hue of a colour in Go (Golang)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages