Skip to main content

Install once, then call it from SQL

The extension adds ordinary SQL functions, with nothing to import at the call site. Install it once (left), then use the functions anywhere a DuckDB function is allowed (right).

duckdb
-- once per installation, then once per session
INSTALL duckfn_palette FROM community;
LOAD duckfn_palette;
duckdb
SELECT plt_to_hex(plt_convert(plt_srgb(1, 0.5, 0), 'oklch')); -- #ff8000
SELECT plt_contrast(plt_named('white'), plt_named('black')); -- 21.0
SELECT to_json(list_transform(plt_colorous_palette('viridis', 3), lambda x: plt_to_hex(x)));
-- ["#440154","#20908c","#fde725"]

The comments are what each call returns — a converted color, a WCAG contrast ratio, and a three-stop gradient sampled as hex.

The full function reference