- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to draw a line with lineTo() in HTML5?
59 Lectures 8.5 hours
68 Lectures 8 hours
To draw a line in HTML, use the canvas element. With canvas, use the lineTo() method to draw a line. The lineTo() method includes x and y parameter values, which positions the line.
You can try to run the following code to draw a line with lineTo() in HTML5 −
<!DOCTYPE html> <html> <head> <title>HTML Canvas</title> </head> <body> <canvas id="newCanvas" width="300" height="150" style="border:1px solid #000000;"></canvas> <script> var c = document.getElementById("newCanvas"); var ctxt = c.getContext("2d"); ctxt.beginPath(); ctxt.moveTo(70, 50); ctxt.lineTo(50, 120); ctxt.stroke(); </script> </body> </html>
- How to draw a line in HTML5 SVG?
- How to draw a circle with arc() in HTML5?
- How to draw a text with fillText() in HTML5?
- How to draw a text with strokeText() in HTML5?
- Draw a shadow with HTML5 Canvas
- How to draw a Bezier Curve with HTML5 Canvas?
- How to draw a line in Android?
- How to draw sine waves with HTML5 SVG?
- How to draw an Image with drawImage() in HTML5?
- How to draw a 3D sphere in HTML5?
- How to draw a linear gradient in HTML5?
- How to draw a circular gradient in HTML5?
- How to draw a circle in HTML5 SVG?
- How to draw a rectangle in HTML5 SVG?
- How to draw a polygon in HTML5 SVG?