Here is a basic example of drawing a circle on an HTML5 canvas using JavaScript:
32 chars2 lines
index.tsx235 chars9 lines
This code will create a canvas element with an id of "myCanvas" and draw a circle in the center of the canvas with a radius of 50 pixels. The ctx.beginPath()
method starts a new path, while ctx.arc(x, y, radius, 0, Math.PI * 2)
draws the circle with the specified center (x, y)
, radius, and angle range. Finally, ctx.stroke()
draws the circle's outline.
gistlibby LogSnag