We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › adobe color palette loader
Page Index Toggle Pages: 1
adobe color palette loader (Read 577 times)
adobe color palette loader
Jan 5th, 2008, 1:13pm
 
Hey all. I saw this website (http://colorblender.com/) that allows you to blend a color palette with interesting combinations. The site also allows you to download an adobe color palette out of the combination. So I thought, why not use this as a starting point for a palette class that loads in set colors?

This tiny lib allows you to load in .act files downloaded from that site and (presumably!) any adobe color palette files that are .act format. I haven't tested it out with Adobe products yet, but at least it will work with files from that site.

Note: The P5Extend is supposed to make life easier by not having to pass in PApplet to every new object you make for libraries, but I made a silly mistake of misplacing that class into the wrong package. So now, if you tried to use this lib along with my other one (Vertext) the two will fail. This is sad, and I'll have these two fixed soon.

I'll also build a nice little web page for this lib and add features if I think they'll be useful (cycle colors, add EPS color palette support, naming colors, etc).


Download:
http://www.ghost-hack.com/p5/palette/palette_010508.zip

Example:
Code:

import flux.graphics.*;

// make a new window
size(500,50);

// register the plugin
P5Extend.register(this);

// create a new palette from the file
// you can build a quick color palette from sites like:
// http://colorblender.com/
// this site allows you to save and download .act palette files
// place the file in your data folder
Palette palette = new Palette("colorblender_20080105125645.act");

noStroke();

// get the colors
int colors[] = palette.getColors();

// make a bunch of rectangles from the colors
float rectWidth = (float) width / colors.length;
float rectHeight = height;

for(int i=0; i<colors.length; i++){
fill(colors[i]);

float x = (float) i / colors.length * width;
float y = 0;
rect( x , y, rectWidth, rectHeight);
}

Re: adobe color palette loader
Reply #1 - Jan 5th, 2008, 1:18pm
 
One more thing...

Someone can probably hack http://colorblender.com/'s ASP scripts out (from view source) and use their API to directly build ACT files, then use my library to remotely grab and load new colors.

It's probably not very polite to directly use the API from their server though.
Re: adobe color palette loader
Reply #2 - Jan 5th, 2008, 2:54pm
 
Hi I've wrote something similar a while ago. The class loads .act and .cs from colorschemer (http://www.colorschemer.com). Code:

package colorStuff;

import processing.core.*;
import java.util.ArrayList;

public class Palette extends PApplet {
public Integer[] colors;

public Palette(String file, int opacity) {
byte[] b = loadBytes(file);
if (file.endsWith(".cs")) {
createPalette(b, 8, 26, b[2] & 0xff, opacity);
} else if (file.endsWith(".act")) {
createPalette(b, 0, 3, 255, opacity);
}
}

public Palette(String file, int length, int opacity) {
byte[] b = loadBytes(file);
if (file.endsWith(".cs")) {
createPalette(b, 8, 26, length, opacity);
} else if (file.endsWith(".act")) {
print(b);
createPalette(b, 0, 3, length, opacity);
}
}

private void createPalette(byte[] b, int start, int steps, int length, int opacity) {

ArrayList<Integer> c= new ArrayList<Integer>();
for (int i = 0; i < length; i++) {
if (b[start + i * steps] != -1 && b[start + i * steps] != -1 && b[start + i * steps] != -1) {
c.add((opacity << 24) + ((b[start + i * steps]) << 16)
+ ((b[start + i * steps + 1]) << 8)
+ (b[start + i * steps + 2])
);
}
}
colors=(Integer[]) c.toArray();

}
}



I'm also interested in creating a color library for processing similar to the one of nodebox (http://nodebox.net/code/index.php/Colors). So if you're interested in a collaboration let me know.
Page Index Toggle Pages: 1