<button onclick="draw()">Draw Square</button>
<canvas height="400" id="canvas" width="500">
</canvas>
<script>
function draw() {
const canvas = document.querySelector('#canvas');
if (!canvas.getContext) {
return;
}
const ctx = canvas.getContext('2d');
// set line stroke and line width
ctx.strokeStyle = 'red';
ctx.lineWidth = 5;
// draw a red line
ctx.beginPath();
ctx.moveTo(100, 100);
ctx.lineTo(300, 100);
ctx.lineTo(300, 300);
ctx.lineTo(100, 300);
ctx.lineTo(100, 100);
ctx.stroke();
}
</script>
Computer Methods in Science Course
Subscribe to:
Post Comments (Atom)
NaCl.xyz Generator with Interactive 3D Visualization
NaCl.xyz Generator with Interactive 3D Visualization NaCl.xyz Generator with Interactive 3D Visualization ...
-
<button onclick="drawX()">Draw X</button> <!-- Button to call the 'drawX' function when clicked --> <...
-
#include <iostream> #include <fstream> using namespace std; // Function to sort an array of integers using Selection Sort void ...
-
In mathematics, Pascal's triangle is a triangular array of the binomial coefficients Coasters (Set of 4) $13.91 #MOVING #EYE #ILLUSION #...
No comments:
Post a Comment