Giter VIP home page Giter VIP logo

nice-color-palettes's Introduction

Nice Color Palettes for Processing

A JSON of the top color palettes on ColourLovers.com for Processing. Inspired by nice-color-palettes.

nice-color-palettes

How to use it

Installation

Download the library from GitHub and install it in the sketchbook folder inside the folder name libraries. If you have any trouble you can read the official documentation.

Use the library

Once you've installed the library, open Processing and import it into your sketch:

import nice.palettes.*;

Then you have to declare the main ColorPalette object.

ColorPalette palette;

In the void setup() function initialize the object and pass a reference to the current PApplet

palette = new ColorPalette(this);

Get a random color palette

Now you can call the getPalette() method to get an array of five different colors that work well together and are chosen randomly:

 // Import the library
import nice.palettes.*;

// Declare the main ColorPalette object
ColorPalette palette;

void setup() {
  // Initialize it, passing a reference to the current PApplet 
  palette = new ColorPalette(this);
  
  // Get a random color palette
  printArray(palette.getPalette());
}

void draw() {
}

Get specific palette

You can recall a palette by passing a number to the method getPalette. For example: getPalette(5) will always return the same color palette.

 // Import the library
import nice.palettes.*;

// Declare the main ColorPalette object
ColorPalette palette;

void setup() {
  // Initialize it, passing a reference to the current PApplet 
  palette = new ColorPalette(this);
  
  // Print an array of integers of the color palette
  // Calling getPalette() with parameters will always return the same palette
  printArray(palette.getPalette(5));
}

void draw() {
}

Get the numbers of palette available

You can call the function getPaletteCount() to have the numbers of available palettes

// Import the library
import nice.palettes.*;

// Declare the main ColorPalette object
ColorPalette palette;

void setup() {
  // Initialize it, passing a reference to the current PApplet 
  palette = new ColorPalette(this);
  
  palette.getPalette();
 
  // Calling getPaletteCount() to return the number of palettes available
  println(palette.getPaletteCount());
}

void draw() {
}

Get the colors inside a palette

You can get the colors of a palette directly.

palette.colors[0];

Please remember that each palette array only contains five colors so palette.colors[5]; will return an error. If you wan to pick a random color inside the palette you can use this code:

palette.colors[(int)random(4)]

You can also assign the colors to a variable:

colors[] c = palette.getPalette();
printArray(c);

Download a new JSON from ColourLovers

You can download an updated version of the top palettes on ColourLovers by calling the function refresh(). The JSON file will be downloaded into the sketch's data folder and saved with the name nice-color-palettes.json.

palette.refresh();

By default the function refresh() will download 20 results. But you use a parameter if you need more results (max 100) palette.refresh(100).

nice-color-palettes's People

Contributors

federico-pepe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.