Draws a circle on the provided canvas context.
Supports two different signatures:
(context, x, y, r, drawOptions)
(context, { x, y, r }, drawOptions)
const canvas = document.createElement('canvas');
canvas.width = 500;
canvas.height = 500;
document.body.appendChild(canvas);
const context = canvas.getContext('2d')!;
// Using individual arguments
drawCircle(context, 100, 100, 50, {
fillColor: 'blue',
strokeColor: 'black',
lineWidth: 2,
});
// Using an object for the circle
drawCircle(context, { x: 200, y: 200, r: 75 }, {
strokeColor: 'green',
dashed: true,
dashPattern: [10, 5],
fill: false,
});
The canvas rendering context.
The x-coordinate of the circle's center.
The y-coordinate of the circle's center.
The radius of the circle.
Optional
drawOptions: DrawOptionsOptions for customizing the appearance of the circle.
Draws a circle on the provided canvas context using an object for the circle's dimensions.
The canvas rendering context.
The circle dimensions (x
, y
, and r
).
Optional
drawOptions: DrawOptionsOptions for customizing the appearance of the circle.
Implementation of the
drawCircle
function. Determines which signature is being used and applies the appropriate logic.