Skip to content

zjhsd2007/color

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Color Conversion Library

Go language-based color model conversion library that supports mutual conversion between multiple color formats, compliant with W3C color specifications.

Core Features

  • Supports RGB/RGBA, HEX, HSL/HSLA, HSV, CMYK color models
  • Provides unified interface Color for color operations (see interface.go)
  • Precision assurance: Color values use uint8/uint16, opacity uses float32
  • Error handling: All parsing functions return (result, error)

Installation

go get github.com/zjhsd2007/color

Usage Example

package main

import (
	"github.com/zjhsd2007/color"
)

func main() {
	hex, _ := color.StrToHex("#ff0000")
	rgb, _ := hex.ToRGB()
	rgbStr := rgb.String() // "rgb(255,0,0)"
}

Design Characteristics

  • Performance optimization: Avoid redundant calculations, integer operations take precedence over floating-point operations
  • Extensibility: Modular design allows adding new color models by implementing base interface
  • Test coverage: Comprehensive unit tests verify conversion accuracy (see color_test.go)

About

color convert

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages