Working with Random
in
Programming Questions
•
3 years ago
I have written a little program that takes some simple shapes with nice alpha values, and some simple text.
I want them to appear in random locations each time I run the program. It would also be nice to change the colors keeping the alpha values random times.
I got this far but am stuck, I don't know how to make the for statement with the random codes for this .
Here is the code.
I know this is easy for some people, but I have spent hours and hours and just can't do it.
size (500, 500);
background(255);
noStroke();
smooth();
fill(242, 204, 47, 50);
ellipse(27, 66, 44, 44);
fill(174, 221, 60, 80);
triangle(22, 40, 27, 10, 43, 36);
fill(116, 193, 206, 100);
rect(7, 9, 14, 24);
fill(242, 204, 47, 10);
ellipse(46, 56, 84, 84);
PFont font; //Declares the font variable
font = loadFont("GiddyupStd-18.vlw"); //loads the font into the data file
textFont (font); //sets the current text font
fill (180);
text("Triangle", 0, 140);
text("Ellipse", 0, 170);
text ("Rectangle", 0, 200);
I want them to appear in random locations each time I run the program. It would also be nice to change the colors keeping the alpha values random times.
I got this far but am stuck, I don't know how to make the for statement with the random codes for this .
Here is the code.
I know this is easy for some people, but I have spent hours and hours and just can't do it.
size (500, 500);
background(255);
noStroke();
smooth();
fill(242, 204, 47, 50);
ellipse(27, 66, 44, 44);
fill(174, 221, 60, 80);
triangle(22, 40, 27, 10, 43, 36);
fill(116, 193, 206, 100);
rect(7, 9, 14, 24);
fill(242, 204, 47, 10);
ellipse(46, 56, 84, 84);
PFont font; //Declares the font variable
font = loadFont("GiddyupStd-18.vlw"); //loads the font into the data file
textFont (font); //sets the current text font
fill (180);
text("Triangle", 0, 140);
text("Ellipse", 0, 170);
text ("Rectangle", 0, 200);
1