Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //demo of simple functions
- //do not copy this code for assignments: write it out yourself, in your own words, where aplicable.
- float randStartX =100; //variable for random start location
- float randStartY =100; //variable for random start location
- float circleDiameter=10; //like it says
- float x,y,z;
- void setup() {
- size(600, 600); //set screen size
- noStroke(); //don't stroke objects
- frameRate(20); //limit framerate to 20fps
- background(255);
- ellipseMode(CENTER); // Set ellipseMode to CENTER
- }
- void draw() {
- makeRandomCircle();
- }
- //scroll down
- void makeRandomCircle() { //and here is a function
- x= random(255); // store random colour values
- y= random(255);
- z= random(255);
- fill(x,y,z); //set random colour
- randStartX=random(width); //pick a start location for X
- randStartY=random(height); //pick a start location for Y
- ellipse(randStartX,randStartY, circleDiameter,circleDiameter); //draw circle
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement