leonelgalan's notebooks

  • Tinycolor's monochromatic palette - /leonelgalan/tinycolor-monochromatic-palette
    Last edited 4 months ago
    const _ = require("lodash") const tinycolor = require("tinycolor2"); const color = 'blue'; const number = 10 const offset = Math.round(number / 2); const monochromaticByLuminance = (color, steps) => { const hsl = color.toHsl(); const { s, h } = hsl; let { l } = hsl; const modification = 1 / steps; const ret = []; _.times(steps, () => { ret.push(tinycolor({ h, s, l })); l = (l + modification) % 1; }); return ret; }; _(monochromaticByLuminance(tinycolor(color), number)) .sortBy(color => color.toHsl().l) .reverse() .map((color, index) => { const hsl = color.toHsl(); const { s, l } = hsl; let { h } = color.toHsl(); h = (h + 6 * index - (number / 2)) % 255; //console.log({h, l, color: tinycolor({ h, s, l }).toHexString()}); return tinycolor({ h, s, l }).toHexString(); }).value();
  • Name to Color - /leonelgalan/name-to-color
    Last edited a year ago
    const tinycolor = require("tinycolor2") const stringHash = require("string-hash"); const faker = require('faker'); const _ = require('lodash'); const baseColor = tinycolor('#25bcca'); const hsv = baseColor.toHsv(); _.times(40, () => { const name = faker.name.findName(); const hash = stringHash(name); const h = 175 + (hash % 155); const color = tinycolor({ h, s: 82 + (hash % 10), v: 83 + (hash % 10) }); const initial = name[0].toUpperCase(); return({h, initial, color: color.toHexString(), name}); });