Something went wrong. Try again.
doll.systems community website
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435export const artPalette = [6, 57, 107, 157, 207];export const artAccent = [199, 159, 239];export const accentStrength = 0.45;
export function gradeImage( data, width, height, tones = 0, strength = 0.5, accent = accentStrength,) { const output = Buffer.alloc(width * height * 3); const palette = tones === 2 ? [artPalette[0], artPalette.at(-1)] : artPalette; const steps = tones - 1; for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) { const index = y * width + x; const light = data[index] / 255; const level = tones ? Math.max(0, Math.min(steps, Math.round(light * steps + (bayer8(x, y) - 0.5) * strength))) : 0; const shade = tones === 2 || tones === 5 ? palette[level] : artPalette[0] + (artPalette.at(-1) - artPalette[0]) * (tones ? level / steps : light); const tint = accent * Math.max(0, (light - 0.35) / 0.65); for (let channel = 0; channel < 3; channel++) output[index * 3 + channel] = Math.round(shade + (artAccent[channel] - shade) * tint); } return output;}import { bayer8 } from '../src/lib/dither.mjs';export { bayer8 };