Question

//Using the canvas element of HTML and JavaScript, draw 5 circular shapes within each other like...

//Using the canvas element of HTML and JavaScript, draw 5 circular shapes within each other like a bullseye but each circle with a different color. Please use a for loop. In the center circle it should say "bulls eye".

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Canvas.html:-

<canvas id='my-canvas' width='800' height='700'>

</canvas>

style.css:-

#my-canvas{
border:1px solid black;
}

BullEye.js:-


var canvasElem = document.getElementById('my-canvas');
var ctx = canvasElem.getContext('2d');
//Starting the function
function drawBullseye(x, y){
  
ctx.fillStyle = 'white';
ctx.beginPath();
ctx.arc(x - 30, y, 40, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = 'red';
ctx.beginPath();
ctx.arc(x - 30, y, 160, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = 'white';
ctx.beginPath();
ctx.arc(x - 30, y, 20, 0, 2 * Math.PI);
ctx.fill();
ctx.fillStyle = 'blue';
ctx.beginPath();
ctx.arc(x - 30, y, 140, 0, 2 * Math.PI);
ctx.fill();
  
  
ctx.fillStyle = 'green';
ctx.beginPath();
ctx.arc(x - 30, y, 110, 0, 2 * Math.PI);
ctx.fill();
  
ctx.fillStyle = 'red';
ctx.beginPath();
ctx.arc(x - 30, y, 90, 0, 2 * Math.PI);
ctx.fill();
  
ctx.fillStyle = 'white';
ctx.beginPath();
ctx.arc(x - 30, y, 60, 0, 2 * Math.PI);
ctx.fill();
  
ctx.fillStyle = 'blue';
ctx.beginPath();
ctx.arc(x - 30, y, 40, 0, 2 * Math.PI);
ctx.fill();
  
ctx.fillStyle = 'white';
ctx.beginPath();
ctx.arc(x - 30, y, 15, 0, 2 * Math.PI);
ctx.fill();}


// Drawing Bulls eye
drawBullseye (400,250)

Add a comment
Know the answer?
Add Answer to:
//Using the canvas element of HTML and JavaScript, draw 5 circular shapes within each other like...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Javascript Let's say there's 40 shapes in a bag, half of them are circles and the...

    Javascript Let's say there's 40 shapes in a bag, half of them are circles and the other half are squares. Using an if/else statement nested in a for loop, how do I use math.random to draw either a square or a circle?

  • Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu:...

    Use Python 3 Create a program that uses Turtle to draw shapes. Show the following menu: Enter Circle Enter Rectangle Remove Shape Draw Shapes Exit Circles – User inputs position, radius, and color. The position is the CENTER of the circle Rectangles – User inputs position, height, width, color. The position is the lower left-hand corner Colors – Allow red, yellow, blue, and green only Remove – Show the number of items in the list and let the user enter...

  • Using HTML and JavaScript. For this assignment you should submit a single zip file that contains...

    Using HTML and JavaScript. For this assignment you should submit a single zip file that contains the following two files: index.html script.js index.html should be a skeleton HTML page. So it should have the following tags: doctype html head meta title body script If you were to open index.html without including the associated JavaScript it should be entirely blank. You should then use JavaScript to create all of the content of this page and append it to the body of...

  • his assignment will help the student by: Create shapes using Java code Using and creating colors...

    his assignment will help the student by: Create shapes using Java code Using and creating colors with Java Coding JFrames and using the Graphics g method Using Loops (to draw) Your program will generate a drawing using java. You should draw an object that makes sense, not just spare shapes and colors. You must use at least 3 different shapes You must use at least 2 different fonts You must use at least 2 predefined java colors and one custom-made...

  • given below are the project description and their Html and css files i need javascript according to the project and other files!

    HTML------------------------------------------------------CSS---------------------------------------------------WEB230 - JavaScript 1 Assignment 7 - FormsSome of these tasks would be better done in HTML or CSS but do them in JavaScript to practice whatwe have learned.1. Select the form element and save it in a variable. From here we can access all of the form fields.2. When the page loads do the following:add the password value "monkey"select the favourite city "New York"clear the textarea3. Add an event handler to the "name" field to change the background color...

  • Using the Graphics object g, create the following shapes 50, 100 5) Now draw that same...

    Using the Graphics object g, create the following shapes 50, 100 5) Now draw that same circle except use 50,100 as its center point

  • This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" />...

    This is my code so far: <!DOCTYPE html> <html> <head> <title>JavaScript is fun</title> <meta charset="utf-8" /> </head> <body> <script type ="text/javascript"> //declare a variable and store text in it var x = "JavaScript is fun"; //write the variable 5 times document.write(x + x + x + x + x); //store 5 as string in variable x x = "5"; //store 3 as string in variable y var y = "3"; //write the value x + y to the document document.write("<br>");...

  • Javascript to edit a HTML file. Where to begin? <!doctype html> <html>    <head>      <meta charset="utf-8">      <title>TODO:...

    Javascript to edit a HTML file. Where to begin? <!doctype html> <html>    <head>      <meta charset="utf-8">      <title>TODO: Change The Title</title>    </head>    <body>      <h1></h1>      <p>First paragraph.</p>      <p class="intro">Second <span>paragraph</span>.</p>      <button id="start">Start</button>      <main> </main>      <!--       Test 6: DOM Programming       You MAY consult the notes for week 7, but you MAY NOT discuss this test or       your code with any other students.  All work must be your own.       Instructions:              1. Put all solution code in a file named solution.js.  When you upload your          solution to...

  • NEED HELP with HTML with Javascript embedding for form validation project below. I have my code...

    NEED HELP with HTML with Javascript embedding for form validation project below. I have my code below but I'm stuck with validation. If anyone can fix it, I'd really appreciate. ****************************************************************************** CODE: <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head> <title>Nice</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> var textFromTextArea; function getWords(){ var text =...

  • import javax.swing.*; import java.awt.*; import java.util.List; import java.util.*; /** * Canvas is a class to allow...

    import javax.swing.*; import java.awt.*; import java.util.List; import java.util.*; /** * Canvas is a class to allow for simple graphical drawing on a canvas. * This is a modification of the general purpose Canvas, specially made for * the BlueJ "shapes" example. * * @author: Bruce Quig * @author: Michael Kolling (mik) * Minor changes to canvas dimensions by William Smith 6/4/2012 * * @version: 1.6 (shapes) */ public class Canvas { // Note: The implementation of this class (specifically the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT