25.04.2025

JavaScript. Canvas. Первое занятие.

<html>
<head>
<title>JavaScript</title>
</head>
<body bgcolor="LightCyan">
<h1>Это canvas</h1>

<canvas id="canvas" width="1500" height="800" style="background: LightYellow"></canvas>

<script>
// неизменяется ------------------------------------
    let canvas = document.querySelector('canvas');
    let ctx = canvas.getContext('2d');
//------------------------------------------

    ctx.beginPath(); //начало рисунка

    ctx.moveTo(200, 100);
    ctx.lineTo(1000, 500);
    ctx.lineTo(750, 500);

    ctx.moveTo(550, 400);
    ctx.lineTo(1000, 200);


    ctx.stroke(); // конец рисунка

</script>


</body>
</html>