js draw ellipse on canvas
HTML[Edit]
+
0
-
0
js draw ellipse on canvas
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34<!doctype html> <html> <head> <style> #my-canvas { border: 1px solid gray; } </style> </head> <body> <canvas id="my-canvas" width="200" height="200"></canvas> <script> var canvas = document.querySelector('#my-canvas'); var context = canvas.getContext('2d'); function drawCircle(x, y, radiusX, radiusY, rotation) { context.beginPath(); context.ellipse(x, y, radiusX, radiusY, rotation, 0, 2 * Math.PI); context.stroke(); } var deg = 20; var rad = deg * (Math.PI / 180.0); // Eclipse paramters: // x=100; y=100; // width=80; height=40; // clockwiseRotation=20 degrees // rotation according to point (x, y) drawCircle(100, 100, 80, 40, rad); </script> </body> </html>