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 › import palette from gimp
Page Index Toggle Pages: 1
import palette from gimp (Read 531 times)
import palette from gimp
Aug 3rd, 2008, 4:22am
 
hi all,

wrote something super simple for myself to import colour palettes from gimp that i thought someone else might get some use out of.

gimp palette tutorial here:
http://carol.gimp.org/gimp/resources/palettes/howto.html

Code:

Gpl2array reds;

void setup() {

size(255,255);

reds = new Gpl2array("Reds.gpl");

//reds.palette = sort(reds.palette);
}

void draw() {

for (int i=0; i<reds.palette.length; i++) {


stroke(reds.palette[i]);


line(0,i,width,i);

}
}

class Gpl2array {
color palette[];
int offset = 4;
Gpl2array(String filename) {
String lines[] = loadStrings(filename);
palette = new color[lines.length-offset];
for (int i=offset; i < lines.length; i++) {
String line[] = splitTokens(lines[i]);
color colour = color( int(line[0]), int(line[1]), int(line[2]) );
palette[i-offset] = colour;
}
}
}
Page Index Toggle Pages: 1