The following arc method draws an arc centered at some point. It takes the following parameters: x, y, radius r, start angle startAngle, end angle endAngle, draw clockwise or counterclockwise direction.

The direction parameter takes the following values: true makes it draw clockwise, false counterclockwise (the default).

The angles in the arc method are measured in radians, not degrees. You can use the following function to convert degrees into radians:

``````function getRadians(degrees) {
return (Math.PI / 180) * degrees;
}``````

## Let’s draw a circle

``<canvas width="200" height="200" style="background: #f4f4f4;"></canvas>``
```let canvas = document.querySelector('canvas');
let ctx = canvas.getContext('2d');
ctx.arc(100, 100, 75, 0, getRadians(360));
ctx.stroke();```

The result of running the code:

## Draw a half circle

`<canvas width="200" height="200" style="background: #f4f4f4;"></canvas>`
```let canvas = document.querySelector('canvas');
let ctx = canvas.getContext('2d');
ctx.arc(100, 100, 75, 0, getRadians(180));
ctx.stroke();```

The result of running the code:

## Drawing half of a circle

`<canvas width="200" height="200" style="background: #f4f4f4;"></canvas>`
```let canvas = document.querySelector('canvas');
let ctx = canvas.getContext('2d');

ctx.arc(100, 100, 75, 0, getRadians(180));
ctx.fill(); // paint the path```

Code result:

## What Is Evented I/O For V8 Javascript

A server-side platform that allows you to create high-performance networked JavaScript applications. To handle a large number of…

## What Is += In Javascript, What Does += Mean In Javascript

++ Increment, always adds +1 to a variable. += is a shortened form. Example num will increase by…

## What Does Return Do In Javascript

Table of Contents Hide Why return is needed in JavaScript functionsReturn a string, number or other data typeReturn…

## How To Clear A Textbox In Javascript

The script clears the form input field when the cursor is clicked on it. The script is made…

## How To Square A Number In JavaScript

Method #1 We can use the double-asterisk operator ** – it is “Exponentiation Operator”. In an Exponentiation Expression,…

## How to clone an object in JavaScript?

Sometimes there is a task in JavaScript to clone some object. And at this point it is not…