Thisassignment must be done in Khan Academy. New project link for Khan Academy below, https://www.khanacademy.org/computer-programming/new/pjs Please see attached videos to understand the output of...

1 answer below »

Thisassignment must be done in Khan Academy.


New project link for Khan Academy below,


https://www.khanacademy.org/computer-programming/new/pjs






Please see attached videos to understand the output of the assignment






Starter code is given below,






Thank you








  • Start with a random # of randomly colored circles., then remove one circle at a time in draw() - so we need to clear the canvas area and redraw the remaining circles every time. Once the # of remaining circles become 0, restart the whole process - restart with another random # of colored circles and start removing one circle at a time.




  • Please look at the video1 for more clarity




  • The second part of the assignment is- once the # of remaining circles become 0 pause for few seconds before restart the whole process.Please look at the video2 for more clarity




The starter code is given here


/*
Start with a random # (1 to 100) of randomly colored circles., then keep removing one circle at a time: we need to use draw() and clear the canvas area and redraw the remaining circles every time. Once the # of remaining circles become 0, restart the whole process - restart with another random # of colored circles and start removing one circle at a time....


1. setupCircles will be a function that will start with a random number of circles 2. Wait until numCircles reaches certain negative value
3. Restart fresh by calling setupCircles again


*/
var x = [], y = [], colors = [];
var numCircles = 0;
var rate = 10;
frameRate(rate); // 10 frames per second


var setupCircles = function() { //decide # of circles
numCircles = floor(random(1,100));


//let us empty the circles' data first. x = [];
y = [];
colors = [];


//populate the data for that many circles! };


draw = function() { //clear canvas background(255);


};

Answered 1 days AfterApr 14, 2021

Answer To: Thisassignment must be done in Khan Academy. New project link for Khan Academy below,...

Prasun Kumar answered on Apr 16 2021
124 Votes
colton/part1.js
/**
* Programming assignment - Part 1
* Runs on Khan Academy Processing JS
* By Col
ton Fults
*/
// initializing all the variables
var x = [], y = [], colors = [];
var numCircles = 0;
var rate = 10;
frameRate(rate);
var i;
/**
* resetting function
* it will reset all variables
* and generate random (x, y) coordinates
* and (r, g, b) colors of circles
*/
var setupCircles = function() {
    numCircles = floor(random(1, 100));
    x = [];
    y = [];
    colors = [];
for (i = 0; i < numCircles; i++ ) {
x.push(floor(random(0,399)));
y.push(floor(random(0,399)));
colors.push(
[floor(random(0,255)),
floor(random(0,255)),
floor(random(0,255))]);
}
};
// this function runs repeatedly
draw = function() {
// if the number of circles is zero, call the reset function
if (numCircles===0) {
setupCircles();
}
// setupCircles();
    background(255);
// draw all the circles & fill color
for (i = 0; i < numCircles; i++...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here