• Stars
    star
    147
  • Rank 243,106 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Color ramp generator using curves within the HSV color model

fette palette

Introducing FettePalette — a color palette generator that takes inspiration from the world of pixel art and illustration. Using curves and hue shifting within the HSV color model, the function creates beautiful and unique color palettes. Check out the demo and docs and elevate your generative color game today!"

Installation

FettePalette is bundled as both UMD and ES on npm. Install it using npm:

npm install fettepalette

You can then import FettePalette into your project:

// CJS style
let generateRandomColorRamp = require("fettepalette");

// ES style: import individual methods
import { generateRandomColorRamp } from "fettepalette";

Usage

import { generateRandomColorRamp } from 'fettepalette';

function generateRandomColorRamp  ({
  total:                10,    // total of base colors in the ramp

  centerHue:            180,   // at what hue should the generation start at

  hueCycle:             0.3,   // hsl spins how much should the hue change over
                               // the curve, 0: not at all, 1: one full rainbow

  offsetTint:           0.1,   // offset for the tints

  offsetShade:          0.1,   // offset of the shades

  curveMethod:         'arc',  // what method is used to draw the curve in the
                               // HSV color model, also takes a function 

  curveAccent:          0,     // how accentuated is the curve
                               // (depends heavily on curveMethod)

  tintShadeHueShift:    0.1,   // defines how shifted the hue is
                               // for the shades and the tints

  offsetCurveModTint:  0.03,   // modifies the tint curve

  offsetCurveModShade: 0.03,   // modifies the shade curve

  minSaturationLight:  [0, 0], // defines the min saturation and light of all
                               // the colors

  maxSaturationLight:  [1, 1], // defines the max saturation and light of all
                               // the colors
  
  colorModel:          'hsl',  // defines the color model of the returned colors
                               // hsv and hsl are supported
});

generateRandomColorRamp(Options{})

Function returns an object containing 4 arrays:

{
    light: [], // tints
    dark: [], // shades
    base: [], // medium colors
    all: [], // all colors
 }

Each array contains every color as an array of HSL coordinates [h,s,l/b] [0…360,0…1,0…1]

Options

  • total int 3… → Amount of base colors.
  • centerHue float 0…1 → 0 Red, 180 Teal etc..
  • hueCycle float 0…1 → How much the color changes over the curve 0: not at all, 1: full rainbow
  • offsetTint float 0…1 → Tint curve difference
  • offsetShade float 0…1 → Shade curve difference
  • curveAccent float 0…1 → How pronounced should the curve be, depends a lot on the curve method
  • tintShadeHueShift float 0…1 → Shifts the colors for the shades and tints
  • curveMethod string 'lamé'|'arc'|'pow'|'powY'|'powX' → method used to generate the curve. It also takes a function (Number(0…1)) => [x,y]
  • offsetCurveModTint float 0…1 → amplifies the curveAccent of the tint colors
  • offsetCurveModShade float 0…1 → amplifies the curveAccent of the shade colors
  • minSaturationLight array [0…1, 0…1] → minium saturation and light of the generated colors
  • maxSaturationLight array [0…1, 0…1] → maximum saturation and light of the generated colors
  • colorModel string 'hsl'|'hsv' → defines the color model of the returned colors hsv might be easier to convert into something else.

Saint Options

To make it easy to integrate with your favourite settings panel (dat.gui, tweakpane …), the script exports generateRandomColorRampParams, an object that contains default and saint options to feed to the main function.

{
  curveMethod: {
    default: 'lamé',
    props: { options: ['lamé', 'arc', 'pow', 'powY', 'powX'] },
  },
  curveAccent: {
    default: 0,
    props: { min: -0.095, max: 1, step: 0.001 },
  },
  total: {
    default: 9,
    props: { min: 3, max: 35, step: 1 },
  },
  centerHue: {
    default: 0,
    props: { min: 0, max: 360, step: 0.1 },
  },
  hueCycle: {
    default: 0.3,
    props: { min: -1.5, max: 1.5, step: 0.001 },
  },
  offsetTint: {
    default: 0.01,
    props: { min: 0, max: 0.4, step: 0.001 },
  },
  offsetShade: {
    default: 0.01,
    props: { min: 0, max: 0.4, step: 0.001 },
  },
  tintShadeHueShift: {
    default: 0.01,
    props: { min: 0, max: 1, step: 0.001 },
  },
  offsetCurveModTint: {
    default: 0.03,
    props: { min: 0, max: 0.4, step: 0.0001  },
  },
  offsetCurveModShade: {
    default: 0.03,
    props: { min: 0, max: 0.4, step: 0.0001  },
  },
  minSaturation: {
    default: 0,
    props: { min: 0, max: 1, step: 0.001  },
  },
  minLight: {
    default: 0,
    props: { min: 0, max: 1, step: 0.001  },
  },
  maxSaturation: {
    default: 1,
    props: { min: 0, max: 1, step: 0.001  },
  },
  maxLight: {
    default: 1,
    props: { min: 0, max: 1, step: 0.001  },
  },
}

Integration with tweakpane

import { generateRandomColorRampParams } from "fettepalette";

const PARAMS = {};

Object.keys(generateRandomColorRampParams).forEach((key) => {
  const param = generateRandomColorRampParams[key];
  PARAMS[key] = param.default;
  pane.addInput(PARAMS, key, param.props);
});

Reading and Inspiration

More Repositories

1

color-names

Large list of handpicked color names 🌈
JavaScript
2,282
star
2

poline

Esoteric Palette Generator Mico-Lib Interpolating HSL Color in cartesian space
TypeScript
644
star
3

farbvelo

"Random" color palette generator, cycles
JavaScript
67
star
4

rampensau

Color palette generation function using hue cycling and simple easing functions.
TypeScript
53
star
5

gotAnewDesignerMac

automate installation of a MAC for a designer
Ruby
47
star
6

color-name-api

Rest API that returns a bunch of color names for a given color-value
JavaScript
45
star
7

sensible

Maintain media-queries where they belong; in the SASS/SCSS and make them available with the same name space in your JS without polluting your HTML.
SCSS
25
star
8

mod_autoindex.oh

Visual enhancement for apache's directory listing.
HTML
23
star
9

ClosestVector

Find the closest Number / Vector / VectorN ∆
JavaScript
23
star
10

palette-aldente

Color palette curation and sharing tool
JavaScript
18
star
11

ticktack.js

requestanimationframe based watch.
JavaScript
17
star
12

bonescss

SCSS/CSS starting-point for every project. Mixes smacss namespaced h5bp things with other stuff I use all the time. It includes all the nice things from H5BP nicely namespaced using SMACSS
CSS
15
star
13

paletter

semantic color name/palette helper
JavaScript
14
star
14

dialog-size

A relative size palette
CSS
14
star
15

dotfiles

I stole my dotfiles all over the place, thank you internet ❤️ 🌎
Shell
10
star
16

elastiq

Elastiq website
HTML
9
star
17

colorparrot-twitter-bot

A bot that tweets random colors and lets you invent new ones
JavaScript
7
star
18

myMindColors

color palettes from https://access.mymind.com/colors
JavaScript
6
star
19

color-name-lists

A collection of color name lists
JavaScript
6
star
20

dialog-typography

Provides a central place to manage typography across multiple breakpoints.
SCSS
6
star
21

cga

Color Palette Generation Assistant
JavaScript
5
star
22

copic-colors

Up to date list of copic colors
JavaScript
5
star
23

sanzoWadaColors

Color palettes from Sanzo Wada's Color Book
JavaScript
4
star
24

sassvg-arrows

generates SVG-Arrows with sass. Large ones, Small ones, red ones.
CSS
4
star
25

dialog-settings

A simple key value store for module settings, to make modules more portable. With the nice side-effect that all settings can be output as native CSS variables.
CSS
4
star
26

webrings

a modern take on webrings
3
star
27

raumgleiter

Raumgleiter Website
Vue
3
star
28

lifx-js

very simple node.js server with sockets to play around with lifx bulbs
JavaScript
2
star
29

waypoint-animation

know if your DOM things are visible or not
JavaScript
2
star
30

color-fanfare

A collection of palettes that I like to reuse
2
star
31

noms-de-couleur

Recueil de noms de couleur en français.
HTML
2
star
32

scroll-width

Tiny optional AMD that returns the browsers scrollbar width
JavaScript
2
star
33

farbnamen

HTML
2
star
34

exalt.biz

http://exalt.biz website
SCSS
1
star
35

cockadoo

A twitter color experiment
1
star
36

color-fan

a pretty color fan
JavaScript
1
star
37

color-roulette

color palette generator function based mainly on chroma.js
1
star
38

wikipedia-color-names

Up to date list of wikipedia color names
HTML
1
star
39

nombres-de-colores

Una lista de nombres de colores en español.
HTML
1
star
40

z43

z43 collective website
HTML
1
star
41

battery-saver

Switches to power-saving Screensaver when not connected to power
Shell
1
star