<button onclick="drawSpiral()">Draw Spiral</button>
<canvas height="400" id="canvas" width="400">
</canvas>
<script>
// Get the canvas element and its context
function drawSpiral() {
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
a=0;r=0;i=0, n=4*2*Math.PI,dr=0.05,x0=200,y0=200;
ctx.beginPath();
ctx.moveTo(x0, y0);
for(a=0;a<n;a+=0.01){
ctx.lineTo(200+r*Math.cos(a), 200+r*Math.sin(a));
r+=dr;
}
ctx.stroke();
}
</script>
Computer Methods in Science Course
Friday, October 13, 2023
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