Can you put the code together by matching the code to the algorithm described in the comments?
Copy and paste the comments into a new JavaScript Graphics sandbox program, then copy and paste the code to match the comments.
Test your program, then put a screenshot of the output at the bottom of your Colorful Design page.
// This program draws some balloons
//Two global variables set the largest and smallest possible size of each balloon
//One global variable determines the total number of balloons
// Two global variables will hold values to show where each balloon is positioned
// One global variable will hold a value for the size of each individual balloon
// Two global variables will hold the position of the end of all strings 2/3 of the way down the center of the canvas
function start( ){
// Repeat this code once for each balloon // pick a random balloon size // pick a random center location for a balloon // call the drawString function // call the drawBalloon function } } function drawString(){ // create a new line to the center of the balloon // make the string black // add the string to the picture } function drawBalloon(){ // create a circle for the balloon // pick a randome color for the balloon // add the balloon to the picture }
var NUM_BALLOONS = 25; add(balloon); add(string); var MIN_RADIUS = 20; balloonRadius = Randomizer.nextInt(MIN_RADIUS,MAX_RADIUS); var MAX_RADIUS = 40; drawBalloon(); var string = new Line(stringX, stringY,centerX, centerY); var centerX; centerX = Randomizer.nextInt(getWidth()/6,getWidth()*5/6); var centerY; centerY = Randomizer.nextInt(getHeight()/6,getHeight()*2.5/6); var balloon = new Circle(balloonRadius); var balloonRadius; balloon.setPosition(centerX, centerY); var stringX = getWidth()/2; var stringY = getHeight()*2/3; drawString(); for(var i=0;i<NUM_BALLOONS;i++){ string.setColor(Color.black); balloon.setColor(Randomizer.nextColor());