Skip to content

Instantly share code, notes, and snippets.

@Plankiton
Last active November 27, 2021 13:47
Show Gist options
  • Select an option

  • Save Plankiton/05b896ccdde677702e31ed5d8365e7b0 to your computer and use it in GitHub Desktop.

Select an option

Save Plankiton/05b896ccdde677702e31ed5d8365e7b0 to your computer and use it in GitHub Desktop.
Donut math js implementation
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Donut</title> <style>::selection{background: #505050}::-moz-selection{background: #505050}.container, body, html{overflow: hidden; background-color: #000; height: 100%}.container{color: #fff; display: -webkit-flexbox; display: -ms-flexbox; display: flex; -webkit-flex-align: center; -ms-flex-align: center; align-items: center; justify-content: center}</style> </head> <body> <div class="container"> <pre class="center" id="d"></pre> </div><script>parcelRequire=function(e,r,n,t){var i="function"==typeof parcelRequire&&parcelRequire,o="function"==typeof require&&require;function u(n,t){if(!r[n]){if(!e[n]){var f="function"==typeof parcelRequire&&parcelRequire;if(!t&&f)return f(n,!0);if(i)return i(n,!0);if(o&&"string"==typeof n)return o(n);var c=new Error("Cannot find module '"+n+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[n][1][r]||r};var l=r[n]=new u.Module(n);e[n][0].call(l.exports,p,l,l.exports,this)}return r[n].exports;function p(e){return u(p.resolve(e))}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=r,u.parent=i,u.register=function(r,n){e[r]=[function(e,r){r.exports=n},{}]};for(var f=0;f<n.length;f++)u(n[f]);if(n.length){var c=u(n[n.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=c:"function"==typeof define&&define.amd?define(function(){return c}):t&&(this[t]=c)}return u}({"0gr9":[function(require,module,exports){var a=document.getElementById("d"),t=void 0,n=void 0,o=1,r=1,s=function(){var t=[],n=[];o+=.07,r+=.03;for(var s=Math.cos(o),v=Math.sin(o),M=Math.cos(r),h=Math.sin(r),e=0;e<1760;e++)t[e]=e%80==79?"\n":" ",n[e]=0;for(var c=0;c<6.28;c+=.07){var d=Math.cos(c),f=Math.sin(c);for(i=0;i<6.28;i+=.02){var l=Math.sin(i),m=Math.cos(i),u=d+2,I=1/(l*u*v+f*s+5),g=l*u*s-f*v,j=0|40+30*I*(m*u*M-g*h),y=0|12+15*I*(m*u*h+g*M),B=j+80*y,E=0|8*((f*v-l*d*s)*M-l*d*v-f*s-m*d*h);y<22&&y>=0&&j>=0&&j<79&&I>n[B]&&(n[B]=I,t[B]=".,-~:;=!*#$@"[E>0?E:0])}}a.innerHTML=t.join("")};setInterval(s,50);},{}]},{},["0gr9"], null)</script></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment