Documentation
ΒΆ
Overview ΒΆ
Package huetension is the public library facade of the huetension color palette toolkit. It re-exports the most useful types and functions from the internal subpackages so external Go programs can use huetension as a library:
import "github.com/leporel/huetension"
pal, err := huetension.Extract(ctx, "photo.jpg", huetension.ExtractOptions{
Method: huetension.MethodSoft,
PaletteSize: 6,
})
if err != nil { ... }
css, _ := huetension.Export(pal, huetension.FormatCSS, huetension.ExportOptions{})
The same internal packages back the CLI, MCP server, and Web UI binaries, so the library and the binaries are guaranteed to stay in sync.
The internal/* subpackages are private and may change between minor versions; use the symbols re-exported here for stable API guarantees.
Index ΒΆ
- Constants
- Variables
- type APCAResult
- type AnalyzeDistanceTarget
- type AnalyzeMetric
- type AnalyzeOptions
- type AnalyzeResult
- type AnalyzeSpace
- type AnalyzeStrip
- type BlindnessKind
- type Color
- type ContrastAlgo
- type ContrastSample
- type ContrastSuggest
- type ContrastSuggested
- type ExportFormat
- type ExportOptions
- type ExtractMethod
- type ExtractOptions
- type GradientOptions
- type GradientSpace
- type HarmonyOptions
- type HarmonyType
- type LUT
- type LUTOptions
- type Metadata
- type Palette
- type SoftPreset
- type SortBy
- type WCAG21Result
Constants ΒΆ
const ( SoftPresetDefault = extract.SoftPresetDefault SoftPresetColorful = extract.SoftPresetColorful SoftPresetBright = extract.SoftPresetBright SoftPresetMuted = extract.SoftPresetMuted SoftPresetDeep = extract.SoftPresetDeep SoftPresetDark = extract.SoftPresetDark )
Soft preset values. Empty string means "no preset" β the legacy HSL-knob behavior stays in effect.
const ( MethodKMeans = extract.MethodKMeans MethodOkKMeans = extract.MethodOkKMeans MethodMedianCut = extract.MethodMedianCut MethodSoft = extract.MethodSoft MethodSoftK = extract.MethodSoftK MethodOctree = extract.MethodOctree MethodPopularity = extract.MethodPopularity MethodWu = extract.MethodWu MethodDBSCAN = extract.MethodDBSCAN MethodWeightedKMeans = extract.MethodWeightedKMeans )
const ( HarmonyComplementary = harmony.Complementary HarmonyAnalogous = harmony.Analogous HarmonyTriadic = harmony.Triadic HarmonySplit = harmony.Split HarmonyTetradic = harmony.Tetradic HarmonySquare = harmony.Square HarmonyDoubleComplementary = harmony.DoubleComplementary HarmonyCompound = harmony.Compound HarmonyMonochromatic = harmony.Monochromatic HarmonyShades = harmony.Shades )
const ( GradientRGB = gradient.SpaceRGB GradientLab = gradient.SpaceLab GradientOkLab = gradient.SpaceOkLab GradientOkLCH = gradient.SpaceOkLCH GradientHSL = gradient.SpaceHSL )
const ( ContrastWCAG21 = contrast.AlgoWCAG21 ContrastAPCA = contrast.AlgoAPCA )
const ( BlindnessProtan = blindness.Protan BlindnessDeutan = blindness.Deutan BlindnessTritan = blindness.Tritan BlindnessAchroma = blindness.Achroma )
const ( FormatJSON = exporter.FormatJSON FormatCSS = exporter.FormatCSS FormatSCSS = exporter.FormatSCSS FormatLESS = exporter.FormatLESS FormatTailwind = exporter.FormatTailwind FormatPlain = exporter.FormatPlain FormatGPL = exporter.FormatGPL FormatGGR = exporter.FormatGGR FormatSVG = exporter.FormatSVG FormatPNG = exporter.FormatPNG FormatJPEG = exporter.FormatJPEG FormatASE = exporter.FormatASE FormatACO = exporter.FormatACO )
const ( MetricHue = analyze.MetricHue MetricLuminance = analyze.MetricLuminance MetricSaturation = analyze.MetricSaturation MetricDistance = analyze.MetricDistance AnalyzeSpaceOkLCH = analyze.SpaceOkLCH AnalyzeSpaceHSL = analyze.SpaceHSL )
const Version = "0.1.0"
Version is the current library version. Wire-format JSON envelopes use the separate "huetension/v1" string from the exporter package; bumping Version here is allowed without bumping the wire contract.
Variables ΒΆ
var ( NewColor = color.New NewColorWithAlpha = color.NewWithAlpha ParseHex = color.ParseHex Parse = color.Parse NewPalette = palette.New RandomPalette = palette.Random )
Color parsers / constructors. Aliasing functions as vars keeps the public surface aware of upstream signature changes.
var ( AllSoftPresets = extract.AllSoftPresets ParseSoftPreset = extract.ParseSoftPreset )
AllSoftPresets is the canonical list of supported soft presets.
var ( BuildGradient = gradient.Build MultiStopGradient = gradient.MultiStop )
var ( WCAG21 = contrast.WCAG21 APCA = contrast.APCA CheckContrast = contrast.Check SuggestContrast = contrast.Suggest )
var ( SimulateBlindness = blindness.Simulate SimulateBlindnessPalette = blindness.SimulatePalette SimulateAllBlindness = blindness.SimulateAll )
var ( AllExportFormats = exporter.AllFormats Export = exporter.Export FileExtension = exporter.FileExtension )
var ( AnalyzeStrips = analyze.Strips AnalyzeAllMetrics = analyze.AllMetrics AnalyzeCombinePNGs = analyze.Combined )
var ( GenerateLUT = lut.Generate EncodeCube = lut.EncodeCube EncodeHaldPNG = lut.EncodeHaldPNG )
var AllExtractMethods = extract.AllMethods
AllExtractMethods is the canonical list of supported extraction methods.
var ExtractFromImage = extract.Extract
ExtractFromImage is the in-memory variant for callers that already decoded the image (e.g. via image.Decode).
var GenerateHarmony = harmony.Generate
GenerateHarmony returns the colors of a harmony around base.
Functions ΒΆ
This section is empty.
Types ΒΆ
type APCAResult ΒΆ
type APCAResult = contrast.APCAResult
Contrast surface β WCAG 2.1 ratio + APCA Lc score, plus an OkLCH lightness-fix search for failing foreground/background pairs.
type AnalyzeDistanceTarget ΒΆ
type AnalyzeDistanceTarget = analyze.DistanceTarget
Image analysis surface β render four colour-distribution strips (hue / luminance / saturation / distance) for an image.
type AnalyzeMetric ΒΆ
Image analysis surface β render four colour-distribution strips (hue / luminance / saturation / distance) for an image.
type AnalyzeOptions ΒΆ
Image analysis surface β render four colour-distribution strips (hue / luminance / saturation / distance) for an image.
type AnalyzeResult ΒΆ
Image analysis surface β render four colour-distribution strips (hue / luminance / saturation / distance) for an image.
type AnalyzeSpace ΒΆ
Image analysis surface β render four colour-distribution strips (hue / luminance / saturation / distance) for an image.
type AnalyzeStrip ΒΆ
Image analysis surface β render four colour-distribution strips (hue / luminance / saturation / distance) for an image.
type BlindnessKind ΒΆ
Blindness surface β Brettel-ViΓ©not-Mollon CVD simulation.
type Color ΒΆ
Core types.
Color is huetension's canonical sRGB color, Palette is the ordered list of colors with provenance metadata.
type ContrastAlgo ΒΆ
Contrast surface β WCAG 2.1 ratio + APCA Lc score, plus an OkLCH lightness-fix search for failing foreground/background pairs.
type ContrastSample ΒΆ added in v0.2.0
type ContrastSample = contrast.SuggestSample
Contrast surface β WCAG 2.1 ratio + APCA Lc score, plus an OkLCH lightness-fix search for failing foreground/background pairs.
type ContrastSuggest ΒΆ added in v0.2.0
type ContrastSuggest = contrast.SuggestResult
Contrast surface β WCAG 2.1 ratio + APCA Lc score, plus an OkLCH lightness-fix search for failing foreground/background pairs.
type ContrastSuggested ΒΆ added in v0.2.0
type ContrastSuggested = contrast.Suggestion
Contrast surface β WCAG 2.1 ratio + APCA Lc score, plus an OkLCH lightness-fix search for failing foreground/background pairs.
type ExportFormat ΒΆ
Exporter surface β render a palette to JSON / CSS / SCSS / Tailwind / plain hex / GIMP .gpl / .ggr / SVG / PNG / JPEG / Adobe .ase / .aco.
type ExportOptions ΒΆ
Exporter surface β render a palette to JSON / CSS / SCSS / Tailwind / plain hex / GIMP .gpl / .ggr / SVG / PNG / JPEG / Adobe .ase / .aco.
type ExtractMethod ΒΆ
Extraction surface β turn an image into a palette. ExtractMethod values are typed string constants suitable for CLI flag parsing.
type ExtractOptions ΒΆ
Extraction surface β turn an image into a palette. ExtractMethod values are typed string constants suitable for CLI flag parsing.
type GradientOptions ΒΆ
Gradient surface β interpolate between two or more colors in a chosen space with optional easing.
type GradientSpace ΒΆ
Gradient surface β interpolate between two or more colors in a chosen space with optional easing.
type HarmonyOptions ΒΆ
Harmony surface β generate complementary / analogous / etc. palettes around a base color.
type HarmonyType ΒΆ
Harmony surface β generate complementary / analogous / etc. palettes around a base color.
type LUTOptions ΒΆ
LUT surface β 3D color-grading lookup tables in Cube and HALD PNG formats.
type Metadata ΒΆ
Core types.
Color is huetension's canonical sRGB color, Palette is the ordered list of colors with provenance metadata.
type Palette ΒΆ
Core types.
Color is huetension's canonical sRGB color, Palette is the ordered list of colors with provenance metadata.
type SoftPreset ΒΆ
type SoftPreset = extract.SoftPreset
SoftPreset is a mood preset for the Soft/SoftK methods.
type WCAG21Result ΒΆ
type WCAG21Result = contrast.WCAG21Result
Contrast surface β WCAG 2.1 ratio + APCA Lc score, plus an OkLCH lightness-fix search for failing foreground/background pairs.
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
huetension
command
huetension is a single-binary CLI: subcommands for palette extraction, harmony / gradient generation, contrast checks, CVD simulation, and export.
|
huetension is a single-binary CLI: subcommands for palette extraction, harmony / gradient generation, contrast checks, CVD simulation, and export. |
|
huetension/cli
Package cli wires the huetension command tree on top of cobra and viper.
|
Package cli wires the huetension command tree on top of cobra and viper. |
|
internal
|
|
|
analyze
Package analyze renders "colour distribution" strips for an image: four horizontal bars showing the image's pixels sorted by hue, luminance, saturation, and distance to a primary colour.
|
Package analyze renders "colour distribution" strips for an image: four horizontal bars showing the image's pixels sorted by hue, luminance, saturation, and distance to a primary colour. |
|
blindness
Package blindness simulates the four common forms of color-vision deficiency: protanopia, deuteranopia, tritanopia, and achromatopsia.
|
Package blindness simulates the four common forms of color-vision deficiency: protanopia, deuteranopia, tritanopia, and achromatopsia. |
|
cliutil
Package cliutil renders palettes and color lists for terminal output.
|
Package cliutil renders palettes and color lists for terminal output. |
|
color
Package color provides huetension's canonical color type and conversions across hex, rgb, hsl, hsv, hls (Python colorsys), lab, lch, oklab, oklch, and CSS named colors.
|
Package color provides huetension's canonical color type and conversions across hex, rgb, hsl, hsv, hls (Python colorsys), lab, lch, oklab, oklch, and CSS named colors. |
|
contrast
Package contrast computes color-contrast scores using two algorithms:
|
Package contrast computes color-contrast scores using two algorithms: |
|
exporter
Package exporter renders a *palette.Palette into one of several formats: JSON (the huetension/v1 wire contract), CSS custom properties, SCSS variables, a Tailwind theme.extend.colors snippet, plain hex per line, the GIMP .gpl palette and .ggr gradient formats, a standalone SVG <linearGradient>, swatch images (PNG / JPEG), and the Adobe .ase / .aco swatch interchange formats.
|
Package exporter renders a *palette.Palette into one of several formats: JSON (the huetension/v1 wire contract), CSS custom properties, SCSS variables, a Tailwind theme.extend.colors snippet, plain hex per line, the GIMP .gpl palette and .ggr gradient formats, a standalone SVG <linearGradient>, swatch images (PNG / JPEG), and the Adobe .ase / .aco swatch interchange formats. |
|
extract
Package extract turns an image into a Palette via one of three algorithms:
|
Package extract turns an image into a Palette via one of three algorithms: |
|
gradient
Package gradient produces interpolated color sequences between two or more endpoints.
|
Package gradient produces interpolated color sequences between two or more endpoints. |
|
harmony
Package harmony generates color harmonies β complementary, analogous, triadic, split-complementary, tetradic / square, double-complementary, compound, monochromatic, and shades β around a base color.
|
Package harmony generates color harmonies β complementary, analogous, triadic, split-complementary, tetradic / square, double-complementary, compound, monochromatic, and shades β around a base color. |
|
httputil
Package httputil holds HTTP transport helpers shared by huetension's network-facing internal packages (mcp, web, serve): thin http.Handler middleware, request-classification predicates, and the shared operational logger constructor.
|
Package httputil holds HTTP transport helpers shared by huetension's network-facing internal packages (mcp, web, serve): thin http.Handler middleware, request-classification predicates, and the shared operational logger constructor. |
|
imageio
Package imageio loads images from a variety of sources (file paths, http URLs, stdin, raw bytes, data URIs) and exposes the helpers extract needs: pixel iteration with optional alpha-mask filtering, and aspect-preserving resize through bild.
|
Package imageio loads images from a variety of sources (file paths, http URLs, stdin, raw bytes, data URIs) and exposes the helpers extract needs: pixel iteration with optional alpha-mask filtering, and aspect-preserving resize through bild. |
|
mcp
Package mcp wires the huetension internal libraries (color, palette, harmony, β¦) up as an MCP server.
|
Package mcp wires the huetension internal libraries (color, palette, harmony, β¦) up as an MCP server. |
|
mcp/tools
Package tools holds the per-feature MCP tool implementations.
|
Package tools holds the per-feature MCP tool implementations. |
|
palette
Package palette holds the ordered-color-list type used everywhere in huetension and its operations: sort, random generation, and (in later slices) extraction-result wrapping and library lookup.
|
Package palette holds the ordered-color-list type used everywhere in huetension and its operations: sort, random generation, and (in later slices) extraction-result wrapping and library lookup. |
|
palette/library
Package library is huetension's curated palette catalogue.
|
Package library is huetension's curated palette catalogue. |
|
sandbox
Package sandbox holds the image-loading security policy shared by every huetension network transport (mcp, web).
|
Package sandbox holds the image-loading security policy shared by every huetension network transport (mcp, web). |
|
serve
Package serve composes huetension's three network frontends β the Vue SPA, the REST API, and the MCP HTTP/SSE transports β behind a single listener.
|
Package serve composes huetension's three network frontends β the Vue SPA, the REST API, and the MCP HTTP/SSE transports β behind a single listener. |
|
web
Package web hosts huetension's REST API and embedded Vue SPA.
|
Package web hosts huetension's REST API and embedded Vue SPA. |
|
Package webdist exposes the built Vue SPA as an embed.FS used by the internal HTTP server (internal/web) to serve the UI from the binary.
|
Package webdist exposes the built Vue SPA as an embed.FS used by the internal HTTP server (internal/web) to serve the UI from the binary. |
