Removing Objets from Array float
in
Programming Questions
•
9 months ago
Hi all,
I was messing around with some code just to obtain a better understanding of Processing. I am trying to reset the image drawn when I press '5'. Although clearing the background works for me, the subsequent lines that I draw appear skewed and weird, as such could someone please guide me as to how I can go about removing the entire line when I press '5' altogether and start drawing a new one? Thanks so much!
Here is the code:
float[][] a=new float[255][2];
boolean cilck = false;
float r = random(255);
float g = random(255);
float b = random(255);
void setup() {
size(600, 600);
background(255);
}
void draw() {
if (mousePressed) {
cilck = true;
}
else {
cilck = false;
}
a[0][0]=mouseX;
a[0][1]=mouseY;
if (cilck) {
for (int i=1;i<255;i++)
{
stroke(r, g, b, i*4);
line(a[i][0], a[i][1], a[i][0]+=(a[i-1][0]-a[i][0])/i, a[i][1]+=(a[i-1][1]-a[i][1])/i);
}
}
}
void keyPressed() {
if (key == '5') {
}
if (key == 's' || key == 'S') saveFrame();
}
1