peta-clair
YaBB Newbies
Offline
Posts: 16
reading an image; drawing a cross
Oct 27th , 2007, 8:23am
ok... so i really have no idea how to do any scripting but have a uni assignment due on it so i desperately need help!!! at this stage i am looking to initially begin with a grid of crosses ... the cross hopefully will look like this; size (600,600); background (255); noFill (); stroke (222,45,45); line (50, 275, 200, 275); line (200,275,200,325); line (200,325,50,325); line (50,325,50,275); line (275,50,325,50); line (325,50,325,200); line (325,200,275,200); line (275,200,275,50); line (550,275,550,325); line (400,275,400,325); line (550,275,400,275); line (550,325,400,325); line (275,550,275,400); line (325,550,325,400); line (275,550,325,550); line (275,400,325,400); ... but this shape will hopefully be in a grid of say one cross the size of 10 pixels every 30 pixels apart... i have this code for kind of this i think; void setup() { size(400, 400); background(255); for (int x = 15; x < width; x+= 30) { for (int y = 15; y < height; y+= 30) { drawCross(x, y); } } } // draw a cross at (x, y) : void drawCross(int x, int y) { line(x-5, y, x+5, y); line(x, y-5, x, y+5); } but then i want it to be placed against an image that is posterized to two colours (black and white) and if the pixel or pixels are read against the black then they are to be deleted... i have a code at the moment in which I THINK it is reading the image and when the pixel it is white it draws an ecclipse; PImage polarfleece; void setup (){ size (600,600); polarfleece =loadImage("polarfleece.JPG"); image(polarfleece, 0, 0); filter(GRAY); filter(POSTERIZE, 2); } void draw () { polarfleece.loadPixels (); for (int x = 0; x< polarfleece.width; x++) { for (int y=0; y< polarfleece.height; y++) { int i = (y * polarfleece.width + x); if (polarfleece.pixels [i] == color(255) ) { ellipse (x,y,40,40) ; } else if (polarfleece.pixels [i] == color(0) ) { } } } } ... in saying that it doesnt seem to draw an ecclipse on every white pixel .. any enlightenment on this could be helpful as well... SORRY THIS IS SO LONG. i am just terribly confused. any help at all would be greatly appreciated thanks