Spirala logarytmiczna Pascala
Listing
function sp_log() { var fi = 0; var q = 0.07; var r = Math.exp(q * fi); var x = r * Math.cos(fi); var y = r * Math.sin(fi); ctx.beginPath(); ctx.moveTo(320 + 20 * x, 240 - 20 * y); while (fi <= 2000) { fi += 1; r = Math.exp(q * fi * Math.PI / 180.0); x = r * Math.cos(fi * Math.PI / 180.0); y = r * Math.sin(fi * Math.PI / 180.0); ctx.lineTo(320 + 20 * x, 240 - 20 * y); } ctx.stroke(); }; var cv = document.getElementById("canvas"); var ctx = cv.getContext("2d"); ctx.strokeStyle="green"; ctx.lineWidth=1; sp_log();