Ask Question

Write a program that fills half the canvas with circles in a diagonal formation.

Have Tracy draw circles along the width of the canvas on the bottom row. Have the number of circles decrease by 1 on each iteration until there is only 1 circle on the top row.

+1
Answers (1)
  1. 9 January, 06:13
    0
    function draw ()

    {

    var ctx = document. getElementById ("myCanvas"). getContext ("2d");

    var counter = 0;

    for (var i=0; i<6; i++)

    {

    for (var j=0; j<6; j++)

    {

    //Start from white and goes to black

    ctx. fillStyle = "rgb (" + Math. floor (255-42.5*i) + "," + Math. floor (255-42.5*i) +

    "," + Math. floor (255-42.5*j) + ") ";

    ctx. beginPath ();

    if (i = = = counter && j = = = counter)

    {

    //creates the circles

    ctx. arc (25+j*50,30+i*50,20,0, Math. PI*2, true);

    ctx. fill ();

    //creates a border around the circles so white one will be vissible

    ctx. stroke ();

    }

    }

    counter++;

    }

    }

    draw ();
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a program that fills half the canvas with circles in a diagonal formation. Have Tracy draw circles along the width of the canvas on ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers