Don't know how else to put it. When I run this (errorless) code, sometimes there is a blank sketch window, next time perhaps a drawn line or two -- or even many, next time, a
black sketch window, then back to white with or without lines.
The background is never redrawn. I don't know where to look for this kind of problem event.
I am happy with the code which I am just beginning to work with. I want to expand it, but I want to solve this problem first.
You can easily see it by repeatedly clicking run and stop, run and stop. Even if you happen to get a line or two the first time, keep on clicking stop and run. (Oh, it never does start over either, although it does get into the last section, as you can see by the comment.) Thank you much!
The background is never redrawn. I don't know where to look for this kind of problem event.
I am happy with the code which I am just beginning to work with. I want to expand it, but I want to solve this problem first.
You can easily see it by repeatedly clicking run and stop, run and stop. Even if you happen to get a line or two the first time, keep on clicking stop and run. (Oh, it never does start over either, although it does get into the last section, as you can see by the comment.) Thank you much!
- float unkn = 0.09;
- int cpx1 = width/4;
- int cpy1 = height/4;
- int cpx2 = width/4;
- int cpy2 = height/4;
- int x = round(cpx1+=unkn);
- int y = cpy2+=random(10, 390);
- int k;
- int m;
- int x2, y2;
- int i = 0;
- void setup( )
- {
- size(400, 600);
- background(255);
- smooth();
- noFill();
- stroke(0);
- }
- void draw( )
- {
- // for (int i = 0; i<=200; i++) { // went to while loop, but problem remains
- while (i != 200) {
- beginShape();
- k = int(random(30, 80));
- m = int(random(20, 120));
- vertex(30, 70); // first point
- bezierVertex(cpx1, cpy1, cpx2, cpy2, 50, 100);
- x2 = cpx2;
- y2 = cpy2;
- bezierVertex(x2, y2, cpx2+=k, cpy2+=m, 100, 75);
- x2 = cpx2;
- y2 = cpy2;
- stroke(random(255), random(255), random(255));
- endShape();
- i++;
- if (i == 200){ // makes no difference if this code is within Shape or here
- i = 0;
- x2 = cpx2;
- y2 = cpy2;
- // - I had a println here and it ALWAYS printed
- }
- }
- }
1