Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. //demo of simple functions
  2. //do not copy this code for assignments: write it out yourself, in your own words, where aplicable.
  3.  
  4. float randStartX =100; //variable for random start location
  5. float randStartY =100; //variable for random start location
  6. float circleDiameter=10; //like it says
  7. float x,y,z;
  8.  
  9. void setup() {
  10.  
  11. size(600, 600); //set screen size
  12. noStroke(); //don't stroke objects
  13. frameRate(20); //limit framerate to 20fps
  14. background(255);
  15. ellipseMode(CENTER); // Set ellipseMode to CENTER
  16. }
  17.  
  18.  
  19.  
  20. void draw() {
  21.  
  22. makeRandomCircle();
  23.  
  24. }
  25.  
  26.  
  27.  
  28. //scroll down
  29.  
  30.  
  31.  
  32.  
  33.  
  34. void makeRandomCircle() { //and here is a function
  35. x= random(255); // store random colour values
  36. y= random(255);
  37. z= random(255);
  38. fill(x,y,z); //set random colour
  39. randStartX=random(width); //pick a start location for X
  40. randStartY=random(height); //pick a start location for Y
  41. ellipse(randStartX,randStartY, circleDiameter,circleDiameter); //draw circle
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement