hexcolor

package module
v0.0.0-...-344c8d4 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 4 Imported by: 0

README

Hex Color Library for Go

Test GoDoc Go Report Card

Features:

  • Normalize/Parse hex color
  • convert from/to color.RGBA

ToDo

  • Predefine standard colors (red, blue, ... based on CSS colors)

Usage

Download: go get -u github.com/6543/go-hexcolor

Example:

import (
	"fmt"
	"github.com/6543/go-hexcolor"
)

func main() {
	c, err := hexcolor.NewHexColor("#adf")
	if err != nil {
		panic(err)
	}
	fmt.Println(c.ToString())
}

Contribution

Fork repository, clone it, make changes, push to new branch and submit a pull request.

Documentation

Overview

Package hexcolor is a simple hexcolor normalizer

Installation

go get -u github.com/6543/go-hexcolor

Example

```go
package main

import (
	"fmt"
	"github.com/6543/go-hexcolor"
)

func main() {
	c, err := hexcolor.NewHexColor("#adf")
	if err != nil {
		panic(err)
	}
	fmt.Println(c.ToString())
}
```

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HexColor

type HexColor struct {
	// contains filtered or unexported fields
}

HexColor represents a single hex color

func NewHexColor

func NewHexColor(hc string) (*HexColor, error)

NewHexColor convert string into a HexColor

func ToHexColor

func ToHexColor(c *color.RGBA) *HexColor

ToHexColor convert RGBA to HexColor

func (*HexColor) ToRGBA

func (c *HexColor) ToRGBA() (*color.RGBA, error)

ToRGBA return RGBA color

func (*HexColor) ToString

func (c *HexColor) ToString() string

ToString return normalized hex code of color

Jump to

Keyboard shortcuts

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