devuiGuideDemosAPIGitHub

Colour

The picker (click a swatch):

Colour spaces, HDR and the clipboard.

Ramps and palettes. For trying colour schemes quickly:

import { gui, ramp } from '@haxiomic/devui';

const look = gui.folder('Look').params({
  heat: ramp(['#0d0887', '#cc4778', '#f0f921']),     // a colour ramp, sampled by your code
  palette: ['#203040', '#408080', '#e0c060', '#f0a050'], // a list of colours: edited in place
});
look.heat.hex(0.3);          // '#rrggbb' at t: the colour alone
look.heat.sample(t);         // linear RGBA, alpha straight
look.heat.colors(5);         // 5 colours, end to end, as '#rrggbb'
look.heat.lut(256);          // Float32Array, RGBA linear, alpha straight
look.heat.gradient();        // a CSS linear-gradient(…), with alpha

Your own gradients. A gradient your code already has is edited in place, and your code draws it as it did, with nothing of devui's:

const look = gui.folder('Look').params({
  sky: [{ offset: 0, color: '#1b2a4a' }, { offset: 1, color: '#ffd9a8' }],   // stops
  banner: 'linear-gradient(to right, #2bd9a5, #c43f70)',                       // CSS
});
for (const s of look.sky) grad.addColorStop(s.offset, s.color);   // canvas, as before
el.style.background = look.banner;

Common tasks:

glsl const float size = 256.0; // rampTexture's size vec4 colour = texture(ramp, vec2((t * (size - 1.0) + 0.5) / size, 0.5));