Reputation: 11
i tried making a program that will create a visual every time you click, but it didnt work so i stripped down the code to a sample of what didnt work. at first i thought that the problem was that i didnt have a draw function so processing didnt search for events but when i added the println it still didnt trigger...
can you help me find where i was wrong??
void setup(){
size(500, 400);
}
void draw(){;} // listens to events
void mouseClicked(){
println("d");
}
edit1: goldenCucumber told me to get rid of two curly braces, i forgot to delete them (i dont think this is the problem)
edit2: people asked for the full code:
void setup(){
size(500, 400);
colorMode(HSB, 100);
draw_gradients();
}
void draw_gradients(){
color c1 = color(random(100), 100, 100);
color c2 = color(random(100), 100, 30);
for(int y = 0; y < height;y++){
float n = map(y, 0, height, 0, 1);
color newc = lerpColor(c1, c2, n);
stroke(newc);
line(0, y, width, y);
n += 0.01;
}
}
void draw(){;} // listens to events
void mouseClicked(){
println("d");
draw_gradients();
}
Upvotes: 0
Views: 208
Reputation: 54
If you remove two unnecessary "}" signs after "size(500, 400);" it works correctly, just tested. I am not sure though if you are aware that println() function only prints text to Processing console in the bottom of the code window. It does not draw it in animation window.
Upvotes: 2