hm, actually it must be
color c = img.get(j, i);
int r = int(red(c));
int g = int(green(c));
int b = int(blue(c));
and you will see little bit,
and then need in setup() a
noStroke();
voila
because actually you read the black canvas content
and filled this black into circles,
and print these with black stroke
but your code might have worked better if you would have not disabled the image line
this could be the next step? pixelation?
PImage img;
int gap = 4; //1 pixelation
void setup() {
size(640, 480);
noLoop();
noStroke();
img = loadImage("data/moonwalk.jpg");
}
void draw() {
background(0);
drawcircles();
}
void drawcircles(){
//image(img, 0, 0);
for(int i = 0; i < img.height; i+=gap) {
for(int j = 0; j < img.width; j+=gap) {
color c = img.get(j, i);
int r = int(red(c));
int g = int(green(c));
int b = int(blue(c));
//println("r "+r," g "+g+" b "+b);
fill(r, g, b);
circle(j, i, gap); // Write the pixel color values to the canvas.
}
}
}
with operation?
PImage img;
int gap = 1; // pixelation
color c;
float cr,cg,cb; // original pixel color RGB
float r=1,g=1,b=1; // MWPP color tuner
void setup() {
size(640, 480);
//noLoop();
noStroke();
img = loadImage("data/moonwalk.jpg");
println("use : MWPP press key and turn mouse wheel\nkey [r] Red, [g] Green [b] Blue tune color\nkey [p] pixelation");
}
void draw() {
background(0);
drawcircles();
}
void drawcircles(){
for(int i = 0; i < img.height; i+=gap) {
for(int j = 0; j < img.width; j+=gap) {
c = img.get(j, i);
cr = red(c);
cg = green(c);
cb = blue(c);
//println("r "+cr," g "+cg+" b "+cb);
cr = constrain(cr * r, 0, 255 ); // tune each color by MWPP
cg = constrain(cg * g, 0, 255 );
cb = constrain(cb * b, 0, 255 );
fill(cr, cg, cb);
circle(j, i, gap); // Write the pixel color values to the canvas.
}
}
}
void mouseWheel(MouseEvent event) { // Mouse Wheel Plus Plus Color sliders
float e = event.getCount(); //println(e);
if ( keyPressed && key == 'r' ) {
r += e/50;
r=constrain(r, 0, 2);
println(" key r: r "+r);
}
if ( keyPressed && key == 'g' ) {
g += e/50;
g=constrain(g, 0, 2);
println(" key g: g "+g);
}
if ( keyPressed && key == 'b' ) {
b += e/50;
b=constrain(b, 0, 2);
println(" key b: b "+b);
}
if ( keyPressed && key == 'p' ) {
gap += e;
gap=constrain(gap, 1, 20);
println(" key p: gap "+gap);
}
}