Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup ()
- {
- size(620,470); // screen
- background(100);
- rect(50,20,550,400); // graph space
- //x(begin),y(begin),delta(x),delta(y)
- //Font assignment
- PFont font = loadFont("TrebuchetMS-13.vlw");
- textFont(font,13);
- fill(0); // set filling color
- text("Some Random Graph",260,15);
- // X-axis
- text("Number of samples ago",260,455);
- for(int i= 550; i>=0; i -=50)
- {
- text(i,600-i,430);
- }
- //Y-axis
- text("PWM",5,185);
- text("%",15,205);
- for(int j=0; j<= 100; j+=10)
- {
- text(j,35,420-4*j);
- }
- }
- void draw()
- {
- color black = color(0);
- color white = color(255);
- int y = (int)random(400);
- int[] values = new int[550];
- for(int p=548; p>=0;p--) { // move all elements
- values[p] = (int)random(100)+100
- }
- while(true)
- {
- if (y => 400) {
- y = 399;
- } else if (y <= 1) {
- y = 2;
- } else {
- y += (round(random(1))*2)-1;
- }
- for(int p=548; p>=0;p--) // move all elements
- {
- values[p+1]=values[p];
- }
- values[0]=y; // add new element
- for(int q=0, foo; q<550;q++) // print pixels
- {
- set(600-q,values[q],color(0)); //set(x,y,color)
- /*if (q == 100)
- {
- delay(10000);
- }*/
- }
- delay(10);
- rect(50,20,550,400) // paste a clean sheet over the points
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement