<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Functions: Task 2</title>
</head>
<body>
<section class="preview">
</section>
<canvas width="480" height="320">
</canvas>
<script>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
const x = 50;
const y = 60;
const width = 100;
const height = 75;
const color = 'blue';
// Add your code here
function drawRectangle() {
ctx.clearRect(x, y, width, height);
ctx.stokeStyle = 'blue';
//ctx.fillStyle = rgba(0, 255, 0, 0.5);
ctx.beginPath();
ctx.rect(x, y, width, height, color);
ctx.stroke();
}
drawRectangle();
// Don't edit the code below here!
const section = document.querySelector('section');
</script>
</body>
</html>
<style>
* {
box-sizing: border-box;
}
p {
color: purple;
margin: 0.5em 0;
}
canvas {
border: 1px solid black;
}
</style>
<script>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
const x = 50;
const y = 60;
const width = 100;
const height = 75;
const color = 'blue';
// Add your code here
function drawRectangle() {
ctx.clearRect(x, y, width, height);
//ctx.fillStyle = rgba(0, 255, 0, 0.5);
ctx.beginPath();
ctx.rect(x, y, width, height, 'blue');
ctx.stroke();
}
drawRectangle();
// Don't edit the code below here!
const section = document.querySelector('section');
</script>
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.