<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)
N-point Star in Microsoft Visual Studio Console App
#include <windows.h> #include <cmath> #include <iostream> LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,...
-
In mathematics, Pascal's triangle is a triangular array of the binomial coefficients Coasters (Set of 4) $13.91 #MOVING #EYE #ILLUSION #...
-
Get my art printed on awesome products. Support me at Redbubble Unit #circle #angles. #Trigonometry, #Math Formulas, Geometry Formu...
-
<button onclick="drawX()">Draw X</button> <!-- Button to call the 'drawX' function when clicked --> <...
No comments:
Post a Comment