Files
JavaScript-from-Beginner-to…/Chapter 14/Code Samples/ch14-canvas-lines.html
T
2021-11-25 14:40:42 +01:00

24 lines
445 B
HTML
Executable File

<html>
<head>
<style>
#canvas1 {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="canvas1"></canvas>
<script>
var canvas = document.getElementById("canvas1");
var ctx = canvas.getContext("2d");
canvas.width = 100;
canvas.height = 100;
ctx.lineWidth = 2;
ctx.moveTo(0, 20);
ctx.lineTo(50, 100);
ctx.stroke();
</script>
</body>
</html>