HTML5 CANVAS | Sololearn: Learn to code for FREE!

+1

HTML5 CANVAS

Does anyone know how to trace an arc/circle in the canvas with other arcs/circles ?

3/16/2019 12:03:34 PM

Lucy

6 Answers

New Answer

+7

A simple arc can be drawn using arc method. ctx.beginPath() ctx.arc(x,y,radius,startAngle,endAngle) ctx.closePath() What did you actually mean by "with other arcs"?

+5

https://www.google.com/url?sa=t&source=web&rct=j&url=https://www.w3schools.com/tags/canvas_arc.asp&ved=2ahUKEwi_r8He44bhAhU_UhUIHbmqBhYQFjAAegQIAxAB&usg=AOvVaw3Zz5M8eGcxdT4uq9RVsJRN // it may help you😉

+3

To make an object move in circular motion, you need to keep on update the x, y position using cos function for x change and sin function for y change. Eg. In the update function // move in circular this.rad += this.speed this.x += Math.cos(this.rad) * circularSize this.y += Math.sin(this.rad) * circularSize Check out thus code https://code.sololearn.com/W8806jRe6N7p/?ref=app

+1

Its Kontol

0

you just need to do this in peace no wahala

0

This.rad+= this.speed