Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2021
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5.08 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  5. </meta>
  6. <style>
  7. /*
  8. img {
  9.     max-width: 100%;
  10.     height: auto;
  11. }
  12. */
  13. </style>
  14. </head>
  15.  
  16. <head>
  17. <body>
  18.  
  19.  <canvas width="500" height="500" id="canvas">
  20.  </canvas>
  21. <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
  22.  
  23. <script>
  24. onerror = errWindow;
  25. //-- EPICYCLES2  - Copyright S.Poole, 27dec2020 --
  26.  
  27. // ____________________________
  28. // WINDOW setup :  get a reference to the canvas
  29.  var canvas = document.getElementById("canvas");
  30.  var ctx = canvas.getContext('2d');
  31.   //draw, filling the whole canvas (equ ql-screen area?)
  32.   ctx.fillStyle = "gray"; ctx.fillRect(0,0,500,500);
  33.   ctx.scale(1,1);
  34.  
  35.  
  36. //________________________
  37. // GLOBALs :
  38.  
  39. var xmlhttp=0;
  40.  
  41.  document.write("<br>"); // Do NOT REMOVE (Forces print position to BELOW Canvas
  42.  document.write(' EPICYCLES PROGRAM ');
  43.  
  44.  document.write("<br>");
  45.  document.write(' SmartPhone, Tablet or PC ...browsers ');
  46.  
  47.  document.write("<br>");
  48.  document.write(' copyright 27dec20 : Steve Poole ');
  49.  
  50.  
  51.  // var dud=setInterval(draw,100);
  52.  
  53. // GLOBALS
  54.    qS='.'; ps=100; m1=-1; o=0; wn=1;
  55.    tw=2; fr=4; sx=6; p=2*Math.PI; st=20;
  56.    h=30; mh=-h; r1=p/360; r3=r1*3; r6=r3*2;
  57.  
  58.    s=0; c=0; ik=0; r=0; j=0; f=0; so=0;
  59.    m=0; x=0; n=0; y=0; es=0; rs=0; r=0; sg=0; e=0;
  60.    sd=0; ec=0; rc=0; cg=0; cd=0; g=0; d=0; pc=0;
  61.    rj=0; q2=0; q4=0; i=0; q=0; s6=0; s4=0;
  62.    u=0; v=0; t=1;
  63.  
  64.    window.requestAnimationFrame(main);
  65.  
  66. function sleep(ms) {
  67.       return new Promise(resolve => setTimeout(resolve, ms));
  68. }
  69.  
  70. async function main(){
  71.         u=t; v=u*2; ctx.fillStyle = "blue"; ctx.fillRect(0,0,500,500);
  72.  
  73.             s=u; // for s=u....
  74.             i=r3; s4=0; if (s<4) {s4=1;}
  75.                   s6=0; if (s>6) {s6=1;}
  76.  
  77.             if (s4>0) {i=r6;}
  78.             if (s6>0) {i=r1;}
  79.             q=p/s; q2=q/2; q4=q/4; //ik=tw;
  80.  
  81.             for (var c1=1; c1<4; c1++) {
  82.                 if (c1==1) {c=q2;}
  83.                 if (c1==2) {c=q4;}
  84.                 if (c1==3) {c=i; }
  85.                   pc=p+c;
  86.  
  87.                for (var rr=1; rr<5; rr++) {
  88.                     if (rr==1) {r=(-30);}
  89.                     if (rr==2) {r=(-10);}
  90.                     if (rr==3) {r=10; }
  91.                     if (rr==4) {r=30; }
  92.  
  93.                    for (var jj=1; jj<3; jj++) {
  94.                         if (jj==1) {j=(-1);}
  95.                         if (jj==2) {j=1;}
  96.                         rj=r*j; e=rj+h; f=0; //var pp=Math.PI; var mp=pp*-1;
  97.                        core();
  98.                      // waits()50); alert(" ENTER... "); cls();
  99.                 }//END FOR jj
  100.                //waits(50); var ans = prompt(" HIT a key... "); cls();
  101.             }//END FOR rr
  102.            await sleep(1000);
  103.          //waits(50);
  104.             //document.getElementById("canvas").innerHTML = "Hello Dolly."; waits(100);
  105.             //var ans = prompt(" HIT a key... ");
  106.             //cls();
  107.             }//END FOR c1
  108.             //var ans = prompt(" HIT a key... ");
  109.         // end for s...
  110.         //var ans = prompt(" HIT ENTER... ");
  111.        if (t++<7) window.requestAnimationFrame(main);
  112. }
  113. //______________________________
  114.  
  115. function core() {
  116.                       for (var ff=0; ff<999999999; ff++) {
  117.                        //FOR f=o TO pc STEP c
  118.                            d=f*j;
  119.                             g=f*s+d;
  120.                            cd=Math.cos(d); cg=Math.cos(g);
  121.                            sd=Math.sin(d); sg=Math.sin(g);
  122.                            ec=e*cd  ; rc=r*cg;
  123.                            x=ec+rc; es=e*sd; rs=r*sg;
  124.                            y=es+rs; so=f; off=250;
  125.                            if (so>0) {
  126.                              ctx.strokeStyle='white'; ctx.beginPath();
  127.                              ctx.moveTo(off+m*1.9,off+n*1.9); ctx.lineTo(off+x*1.9,off+y*1.9);
  128.                              ctx.closePath(); ctx.stroke();
  129.                              //var ans = prompt(" HIT a key... ");
  130.                             }// end if so
  131.                             m=x; n=y; f=f+c;// c
  132.                             if (f>pc) {break;}
  133.                     }//END FOR ff
  134. }//end def
  135. //______________________________
  136.  
  137. function cls(){
  138. ctx.fillStyle = "green"; ctx.fillRect(0,0,500,500);
  139. }
  140.  
  141. //________________________________
  142. function waits(wt) {
  143. var nbr=0; for (var ctr=1; ctr<(wt*10000000); ctr++) {nbr=ctr+1;}
  144.  
  145. }// end def .... 7 zeros
  146. //____________________________
  147.  
  148.   function errWindow(errMsg,location,lineNum){
  149.     var debugWin = window.open("","debugWin","height=200,width=300,resize=yes") ;
  150.     debugWin.document.write("<h2>There was an error at line " + lineNum) ;
  151.      debugWin.document.write("<br>The error was: " + errMsg) ;
  152.      debugWin.document.close() ;
  153.      return true ;
  154.   } // end def
  155.  
  156.   // ____________________________
  157.  
  158.   function askQty() {
  159.        //alert("We've begun asking for Qty ");
  160.        var ans = prompt(" Loops ? 1 to 10000 ");
  161.        try {
  162.          if( !ans || isNaN(ans) || ans < 1 || ans>10000) {ans=9; throw new Error("Not a valid number");}
  163.          return ans;
  164.         } //Eo try
  165.        catch(errMsg){
  166.            alert(errMsg.message);
  167.         } //Eo catch
  168.     } //Eofunc askQty
  169.  
  170.  //____________________________
  171.  
  172.  function show_message(){
  173.      window.alert('!');
  174.      } // end def
  175.  
  176.  
  177.  //////////////////////////////////////
  178.  
  179.  // NO MORE FUNCTION DEFINITIONS...
  180.  
  181.  //////////////////////////////////////
  182.  
  183. </script>
  184. </body>
  185. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement