+ 2
Javascript Polygon?
I would like to be able to create shapes(including custom) in JavaScript, but I don't not know how to so this. I have tried Googling but that has been more confusing for me. Can someone demonstrate how a js shape would be made?
2 odpowiedzi
+ 2
Look at this code I made a few weeks ago:
https://code.sololearn.com/W5O7AK3ypWhI/?ref=app
The function is at JS lines 135 to 147.
It takes five parameters: x position, y position, radius/size, how many sides the polygon has, and the rotation.
Note that you’ll have to set the fillStyle() first.
You’ll need to use the <canvas> element for that.
Note: If you’re going to use the function, please put credit in a comment.
+ 2
Learn that here..
https://www.w3schools.com/html/html5_canvas.asp