<head> <script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script> <script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML"> </script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); </script> <link rel="stylesheet" href="http://mirkwood.cs.edinboro.edu/~bennett/style/hw.css"> </head> <body> <canvas id="canvas" width="400" height="400" style="border:1px solid #000000;"></canvas> <p> <script type="text/javascript"> "use strict" let canvas = document.getElementById("canvas"); let ctx = canvas.getContext('2d'); canvas.tabIndex = 0; function LERP(a,b,alpha) { return a*(1-alpha) + b * alpha; } function SetPixel(x, y, color = "black") { x = Math.round(x); y = Math.round(y); ctx.beginPath(); ctx.fillStyle = color; ctx.fillRect(x,y,2,2); ctx.fill() return; } let theta, r, hue, color; let cx = canvas.width/2; let cy = canvas.height/2; let dalpha = 1/1200; for(let alpha=0;alpha<=1; alpha += dalpha) { r = LERP(0, Math.min(cx,cy), alpha); theta = LERP(0, 4*Math.PI, alpha); hue = LERP(240, 360, alpha); let color = "hsl("+hue + ", 100%, 50%)"; SetPixel(cx + r*Math.cos(theta), cy - r*Math.sin(theta), color); } </script>