Perceptual interpolation toward o by t (clamped 0..1), blended in Oklab so midtones stay vivid. Use mix for a different space.
Example
-- Blended in Oklab: halfway from black to white is the gray that-- looks halfway, darker than sRGB 0.5.local black = datumhue.color("#000000")
local white = datumhue.color("#ffffff")
print(string.format("%.2f", black:lerp(white, 0.5).r)) --> 0.39-- t is clamped to 0..1.print(black:lerp(white, 2) == black:lerp(white, 1)) --> true
Interpolate toward o by t (clamped 0..1) in the given color space.
Example
local red = datumhue.color("#ff0000")
local blue = datumhue.color("#0000ff")
print(red:mix(blue, 0.5, "srgb")) --> color(0.5, 0.0, 0.5, 1.0)-- Around the hue wheel: halfway from red to blue is magenta.print(red:mix(blue, 0.5, "hsl")) --> color(1.0, 0.0, 1.0, 1.0)
Perceptually darken by amount (subtracted from Oklab lightness, 0..1); alpha unchanged.
Example
-- The amount comes off Oklab lightness, which runs 0 to 1.local leaf = datumhue.color("#a7c080")
local before = leaf:to_oklch()
local after = leaf:darken(0.2):to_oklch()
print(string.format("%.2f", before - after)) --> 0.20
Rotate the hue by degrees — hue is the API's one angle in degrees (the CSS convention), matching color.hsl; every other angle is radians.
Example
-- Degrees. A color made from a hex string or r, g, b turns around-- the perceptual (Oklch) hue wheel.local leaf = datumhue.color("#a7c080")
local _, _, hue = leaf:to_oklch()
local _, _, turned = leaf:rotate_hue(120):to_oklch()
print(string.format("%.0f", turned - hue)) --> 120