Tell Processing when screen is full
in
Programming Questions
•
1 month ago
So I have a little program that randomly "walks" (x++, x--, y++, y--) around the screen, creating ellipses of a given radius (int). The walker loop is bounded within the screen. I also have a separate program that counts seconds, and displays them on the screen when the draw loop is ended (noLoop).
What I want to do is stop the loop when the screen has no more black areas (that are, of course, <radius) -- how can I input that into processing?
Walker code:
- class Walker {
- float x;
- float y;
- float change =10;
- Walker() {
- x = width/2;
- y = height/2;
- }
- void display() {
- ellipse (x, y, change, change);
- }
- void step() {
- float r = random(1);
- if (r < 0.25) { //change value to change probability (dont forget to change others)
- // fill(random(255), random (255), random(255)); //RGB - Random:)
- fill(255, 0, 0); //RGB - R color
- x+=change;
- }
- else if (r < 0.5) {
- // fill (random(255),random( 255),random (255)); //RGB - Random:)
- fill (0, 255, 0); //RGB - G color
- x-=change;
- }
- else if (r < 0.75) {
- // fill (random(255), random (255), random (255)); //RGB - Random:)
- fill (0, 0, 255); //RGB - R color
- y+=change;
- }
- else {
- fill (255);
- y-=change;
- }
- if (x>width) { //boundary
- x-=change;
- }
- if (x<0) { //boundary
- x+=change;
- }
- if (y>height) { //boundary
- y-=change;
- }
- if (y<0) { //boundary
- y+=change;
- }
- }
- }
- Walker walker1;
- void setup() {
- size(600, 600);
- background (0);
- walker1 = new Walker();
- }
- void draw() {
- println(millis()/1000); //see how long it takes to fill screen! prints time in seconds;;
- walker1.step();
- walker1.display();
- }
Time Display Code
- int time;
- PFont font;
- String time_string;
- void setup() {
- // All the fun stuff that goes here
- }
- void draw() {
- time = millis()/1000;
- time_string = ""+time;
- if (/*THIS IS WHAT I'M LOOKING FOR*/){
- fill(255,0,0);
- textFont(font, 100);
- text (time_string, width/2 , height/2);
- noLoop();
- }
1