We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I edited this question since originally I was using the Hype framework to colorize stuff, but then found a perfect example of what I'm trying to do on the Processing site itself. This takes an image, builds out a grid just as I want, and colors things. I try printing "c" since I believe that to be the color but I'm not recognizing the format. Since it's in black and white, I'd love to see it in the range of 0 to 255.
1.) My goal is to print out the color that it's using to build the grid...just once.
Here's a snippet of the first few values I get:
6447715-3684409-2960686-3487030-2631721-3750202
I'm using this exact code from the website (https://processing.org/tutorials/pixels/) but I'll post the code here:
PImage img; // The source image
int cellsize = 34; // Dimensions of each cell in the grid
int cols, rows; // Number of columns and rows in our system
void setup() {
size(900, 900, P3D);
img = loadImage("black_and_white.jpg"); // Load the image
cols = width/cellsize; // Calculate # of columns
rows = height/cellsize; // Calculate # of rows
}
void draw() {
background(0);
loadPixels();
// Begin loop for columns
for ( int i = 0; i < cols;i++) {
// Begin loop for rows
for ( int j = 0; j < rows;j++) {
int x = i*cellsize + cellsize/2; // x position
int y = j*cellsize + cellsize/2; // y position
int loc = x + y*width; // Pixel array location
color c = img.pixels[loc]; // Grab the color
// Calculate a z position as a function of mouseX and pixel brightness
float z = (mouseX/(float)width) * brightness(img.pixels[loc]) - 200.0;
// Translate to the location, set fill and stroke, and draw the rect
pushMatrix();
translate(x,y,z);
fill(c);
noStroke();
rectMode(CENTER);
rect(0,0,cellsize,cellsize);
print(c);
popMatrix();
}
}
}
Answers
Here is a link to Processing Reference: Color
I hop ethis helps,
Kf
https://Processing.org/reference/hex_.html
This definitely gives me more to work and play with. Thanks!