David_Benque
YaBB Newbies
Offline
Posts: 5
Star Making Help
Aug 17th , 2005, 5:16pm
Hello, this is my first processing script, I would like to create images like this: http://www.magueule.net/processing (i made this in photoshop by layering outputs of the previous version of the script that was just saving a TIFF when you clicked) the center of the star and the color are set by the mouse position, Do you have any idea how i could make the whole image in Processing, clicking everytime I want to add a star (with a blending of the colors) to the background. and keep on going I tried something but right now the program just gets stuck whenever I click Thanks a lot <code> void setup() { size(200,200); rectMode(CENTER); } void draw() { background(255); star(mouseX,mouseY); } void mousePressed() { // This part seems to be the problem color c = color(mouseX,mouseY,width-mouseX); loadPixels(); for (int i=0; i<width; i++){ for (int j=0; j<height; j++){ color pixel = get(i,j); color newcolor = blend(pixel, c, BLEND); set(i,j,newcolor); updatePixels(); } } } void star(int x, int y) { noStroke(); fill(mouseX,mouseY,width-mouseX); beginShape(POLYGON); vertex(0,0); vertex(width/4,0); vertex(x,y); vertex(0,0); endShape(); beginShape(POLYGON); vertex(width/2,0); vertex(width*0.75,0); vertex(mouseX,mouseY); vertex(width/2,0); endShape(); // Top right corner beginShape(POLYGON); vertex(width,0); vertex(width,height/4); vertex(x,y); vertex(width,0); endShape(); beginShape(POLYGON); vertex(width,height/2); vertex(width,height*0.75); vertex(x,y); vertex(width,height/2); endShape(); // Bottom right corner beginShape(POLYGON); vertex(width*0.75,height); vertex(width,height); vertex(x,y); vertex(width*0.75,height); endShape(); beginShape(POLYGON); vertex(width/4,height); vertex(width/2,height); vertex(x,y); vertex(width/4,height); endShape(); // Bottom left corner beginShape(POLYGON); vertex(0,height/4); vertex(0,height/2); vertex(x,y); vertex(0,height/4); endShape(); beginShape(POLYGON); vertex(0,height*0.75); vertex(0,height); vertex(x,y); vertex(0,height*0.75); endShape(); } </code>