17.09.2019
Posted by 

HTML Tag Reference HTML Event Reference HTML Color Reference HTML Attribute Reference HTML Canvas Reference HTML SVG Reference HTML. SVG Circle - circle The.

I want to draw a filled (or not filled) circle in a canvas on mouseclick, but I can't get my code to work properly, I've tried pretty much everything!

This is my HTML:

and my current script:

The code works just fine if and only if I remove the 'use strict';, but in this assignment I have to make a code that works even with it, which is my problem.

Here is the jsFiddle

Davy KarlssonDavy Karlsson
2521 gold badge4 silver badges11 bronze badges

1 Answer

Stephan
28.4k32 gold badges162 silver badges262 bronze badges
HtmlDavy KarlssonDavy Karlsson
2521 gold badge4 silver badges11 bronze badges
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Html5 Canvas Draw Multiple Circles

Not the answer you're looking for? Browse other questions tagged javascripthtml5html5-canvas or ask your own question.

There are three methods that draw rectangles on the canvas −

Sr.No.Method and Description
1

fillRect(x,y,width,height)

This method draws a filled rectangle.

2

Basichttp binding for dummies. strokeRect(x,y,width,height)

This method draws a rectangular outline.

3

clearRect(x,y,width,height)

This method clears the specified area and makes it fully transparent

Semi Circle Html Canvas Tutorial

Here x and y specify the position on the canvas (relative to the origin) of the top-left corner of the rectangle and width and height are width and height of the rectangle.

Example

Following is a simple example which makes use of above mentioned methods to draw a nice rectangle.

Live Demo

Html Canvas Methods

The above code would draw the following rectangle −