Some Questions about JS canvas | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Some Questions about JS canvas

Could somebody tell me how canvas.beginpath() work? I searched it and found that if I had use canvas.translate() than it didn't goto (0,0). And if I use canvas.moveTo() without canvas.beginpath() it also can return to (0,0). And use canvas.strokeStyle it may use the last color,I'm very comfused now... Thanks for helping me :) Forgive my poor Eng Orz... 中文版: canvas.beginpath()是重置回哪裡? canvas.moveTo()是不是不影響是否有canvas.beginpath()存在? canvas.translate()的改變配canvas.beginpath()無法回去未改變前? canvas.strokeStyle是以最後的顏色來判定對嗎? 或許這樣講比較直接>< Where I trying from:https://www.w3schools.com/tags/canvas_beginpath.asp https://code.sololearn.com/WOhZeaN0sHrR/?ref=app

15th Sep 2017, 8:05 AM
同學說他喜歡上課可是他沒來
同學說他喜歡上課可是他沒來 - avatar
4 Answers
+ 6
What helped me was a YouTube video about the canvas. You can watch it here https://www.youtube.com/watch?v=eL1X8urHJmA That's just an introduction, so watch their other videos too. Sometimes you need a lecturer to explain things better to you. This is my greatest canvas work so far, https://code.sololearn.com/W0ZF06THFF8O/?ref=app
15th Sep 2017, 7:57 AM
Ghauth Christians
Ghauth Christians - avatar
+ 6
You start a path with canvas.beginPath() and the end it with canvas.stroke() or canvas.fill()
15th Sep 2017, 9:15 AM
Ghauth Christians
Ghauth Christians - avatar
+ 3
Uhhhhh Also sorry to unable to understand what you doubt Can you show your code beside?
15th Sep 2017, 7:42 AM
Yanothai Chaitawat
Yanothai Chaitawat - avatar
+ 1
So after i watch the video is that canvas.beginpath() is used to reset the start point ,and tell compiler that i want to draw a path?,maybe it is not necessary? (I didn't watch them all.....)
15th Sep 2017, 8:35 AM
同學說他喜歡上課可是他沒來
同學說他喜歡上課可是他沒來 - avatar