Analysis
Characterize any material palette — warm woods vs cool stones, muted linens vs vibrant textiles. Every metric is proportion-weighted and OKLab-native.
Material
Click to select. Click another to compare side-by-side.
import { analyzePalette, paletteTemperature, paletteMood } from "colorscope/analysis";Functions
analyzePalette
Compute all palette analysis metrics at once.
function analyzePalette(colors: readonly QuantizedColor[]): PaletteAnalysis| Param | Type | Description |
|---|---|---|
colors | readonly QuantizedColor[] | Palette to analyze |
Returns: PaletteAnalysis with temperature, vibrancy, brightness, complexity, dominantFamily, and mood.
const analysis = analyzePalette(leatherPalette);
// {
// temperature: 0.72, // warm
// vibrancy: 0.65, // vivid
// brightness: 0.31, // dark
// complexity: 0.28, // low — narrow hue range
// dominantFamily: "orange",
// mood: "muted"
// }paletteTemperature
function paletteTemperature(colors: readonly QuantizedColor[]): numberPalette temperature from -1 (cool) to 1 (warm). Uses the OKLab b axis (blue-yellow) weighted by proportion.
paletteVibrancy
function paletteVibrancy(colors: readonly QuantizedColor[]): numberPalette vibrancy from 0 (desaturated) to 1 (vivid). Based on OKLCH chroma weighted by proportion.
paletteBrightness
function paletteBrightness(colors: readonly QuantizedColor[]): numberPalette brightness from 0 (dark) to 1 (light). Uses OKLab perceptual lightness weighted by proportion.
paletteComplexity
function paletteComplexity(colors: readonly QuantizedColor[]): numberPalette complexity from 0 (single color) to 1 (diverse). Combines color count (40% weight, log scale) with average pairwise OKLab distance (60% weight).
dominantFamily
function dominantFamily(colors: readonly QuantizedColor[]): HueFamilyDetermine the dominant hue family. Colors with saturation ≤15 are counted as "neutral".
paletteMood
function paletteMood(colors: readonly QuantizedColor[]): PaletteMoodClassify palette mood. Classification logic:
"monochrome"— Single hue family, low complexity"colorful"— High vibrancy + 3+ hues"vibrant"— High vibrancy"light"— Brightness > 0.7"dark"— Brightness < 0.3"muted"— Default fallback
Types
PaletteAnalysis
interface PaletteAnalysis {
temperature: number; // -1 (cool) to 1 (warm)
vibrancy: number; // 0 (desaturated) to 1 (vivid)
brightness: number; // 0 (dark) to 1 (light)
complexity: number; // 0 (single color) to 1 (diverse)
dominantFamily: HueFamily;
mood: PaletteMood;
}PaletteMood
type PaletteMood = "vibrant" | "muted" | "dark" | "light" | "monochrome" | "colorful"HueFamily
type HueFamily = "red" | "orange" | "yellow" | "green" | "cyan" | "blue" | "purple" | "pink" | "neutral"