pigment

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 1 Imported by: 0

README

pigment 🧪🎨

Pigment is a fast, clean, and idiomatic Go library for color management across multiple color spaces. It supports RGB, HSL, HSV, and CMYK models — each as its own subpackage for modular clarity and speed.

Built for performance, readability, and robots who love colors.


Features

  • 📦 Modular design: import only the color spaces you need
  • 🔁 Convert between RGB, HSL, HSV, and CMYK
  • 🎯 Precise color component control and clamping
  • 🧪 Built for extensibility and testing

Installation

go get github.com/monkeysfoot/pigment

Example

package main

import (
    "fmt"

    "github.com/monkeysfoot/pigment/rgb"
    "github.com/monkeysfoot/pigment/hsl"
)

func main() {
    r := rgb.New(255, 128, 64)
    h := hsl.FromRGB(r)

    fmt.Printf("RGB: %v → HSL: %.2f°, %.2f%%, %.2f%%\n", r, h.H, h.S*100, h.L*100)
}

Package Layout

rgb – Red-Green-Blue color space

hsl – Hue-Saturation-Lightness

hsv – Hue-Saturation-Value

cmyk – Cyan-Magenta-Yellow-Key (Black)

color.intf.go – Common interface for all color types

floatclamp.go – Utility for safe float math

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp01

func Clamp01(x float64) float64

Clamp01 restricts a float64 value to the range [0.0, 1.0].

func ClampDegrees

func ClampDegrees(x float64) float64

ClampDegrees normalizes a float64 representing a float to the range [0.0, 360.0].

Types

type Colorer

type Colorer interface {
	RGB() (r, g, b uint8)
	SetRGB(r, g, b uint8)
	Hex() string
	SetHex(hex string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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