mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
42 lines
609 B
HTML
42 lines
609 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>canvas path example</title>
|
|
</head>
|
|
<body>
|
|
<canvas width=300 height=300></canvas>
|
|
<script>
|
|
|
|
function drawHouse() {
|
|
|
|
var ctx = document.querySelector("canvas").getContext("2d");
|
|
ctx.fillStyle = 'black';
|
|
ctx.fillRect(0, 0, 300, 300);
|
|
|
|
ctx.fillStyle = 'white';
|
|
ctx.strokeStyle = 'red';
|
|
|
|
// Set line width
|
|
ctx.lineWidth = 10;
|
|
|
|
// Wall
|
|
ctx.strokeRect(75, 140, 150, 110);
|
|
|
|
// Door
|
|
ctx.fillRect(130, 190, 40, 60);
|
|
|
|
// Roof
|
|
ctx.beginPath();
|
|
ctx.moveTo(50, 140);
|
|
ctx.lineTo(150, 60);
|
|
ctx.lineTo(250, 140);
|
|
ctx.closePath();
|
|
ctx.stroke();
|
|
|
|
}
|
|
|
|
drawHouse();
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|