Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
- </meta>
- <style>
- /*
- img {
- max-width: 100%;
- height: auto;
- }
- */
- </style>
- </head>
- <head>
- <body>
- <canvas width="500" height="500" id="canvas">
- </canvas>
- <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
- <script>
- onerror = errWindow;
- //-- EPICYCLES2 - Copyright S.Poole, 27dec2020 --
- // ____________________________
- // WINDOW setup : get a reference to the canvas
- var canvas = document.getElementById("canvas");
- var ctx = canvas.getContext('2d');
- //draw, filling the whole canvas (equ ql-screen area?)
- ctx.fillStyle = "gray"; ctx.fillRect(0,0,500,500);
- ctx.scale(1,1);
- //________________________
- // GLOBALs :
- var xmlhttp=0;
- document.write("<br>"); // Do NOT REMOVE (Forces print position to BELOW Canvas
- document.write(' EPICYCLES PROGRAM ');
- document.write("<br>");
- document.write(' SmartPhone, Tablet or PC ...browsers ');
- document.write("<br>");
- document.write(' copyright 27dec20 : Steve Poole ');
- // var dud=setInterval(draw,100);
- // GLOBALS
- qS='.'; ps=100; m1=-1; o=0; wn=1;
- tw=2; fr=4; sx=6; p=2*Math.PI; st=20;
- h=30; mh=-h; r1=p/360; r3=r1*3; r6=r3*2;
- s=0; c=0; ik=0; r=0; j=0; f=0; so=0;
- m=0; x=0; n=0; y=0; es=0; rs=0; r=0; sg=0; e=0;
- sd=0; ec=0; rc=0; cg=0; cd=0; g=0; d=0; pc=0;
- rj=0; q2=0; q4=0; i=0; q=0; s6=0; s4=0;
- u=0; v=0; t=1;
- window.requestAnimationFrame(main);
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- async function main(){
- u=t; v=u*2; ctx.fillStyle = "blue"; ctx.fillRect(0,0,500,500);
- s=u; // for s=u....
- i=r3; s4=0; if (s<4) {s4=1;}
- s6=0; if (s>6) {s6=1;}
- if (s4>0) {i=r6;}
- if (s6>0) {i=r1;}
- q=p/s; q2=q/2; q4=q/4; //ik=tw;
- for (var c1=1; c1<4; c1++) {
- if (c1==1) {c=q2;}
- if (c1==2) {c=q4;}
- if (c1==3) {c=i; }
- pc=p+c;
- for (var rr=1; rr<5; rr++) {
- if (rr==1) {r=(-30);}
- if (rr==2) {r=(-10);}
- if (rr==3) {r=10; }
- if (rr==4) {r=30; }
- for (var jj=1; jj<3; jj++) {
- if (jj==1) {j=(-1);}
- if (jj==2) {j=1;}
- rj=r*j; e=rj+h; f=0; //var pp=Math.PI; var mp=pp*-1;
- core();
- // waits()50); alert(" ENTER... "); cls();
- }//END FOR jj
- //waits(50); var ans = prompt(" HIT a key... "); cls();
- }//END FOR rr
- await sleep(1000);
- //waits(50);
- //document.getElementById("canvas").innerHTML = "Hello Dolly."; waits(100);
- //var ans = prompt(" HIT a key... ");
- //cls();
- }//END FOR c1
- //var ans = prompt(" HIT a key... ");
- // end for s...
- //var ans = prompt(" HIT ENTER... ");
- if (t++<7) window.requestAnimationFrame(main);
- }
- //______________________________
- function core() {
- for (var ff=0; ff<999999999; ff++) {
- //FOR f=o TO pc STEP c
- d=f*j;
- g=f*s+d;
- cd=Math.cos(d); cg=Math.cos(g);
- sd=Math.sin(d); sg=Math.sin(g);
- ec=e*cd ; rc=r*cg;
- x=ec+rc; es=e*sd; rs=r*sg;
- y=es+rs; so=f; off=250;
- if (so>0) {
- ctx.strokeStyle='white'; ctx.beginPath();
- ctx.moveTo(off+m*1.9,off+n*1.9); ctx.lineTo(off+x*1.9,off+y*1.9);
- ctx.closePath(); ctx.stroke();
- //var ans = prompt(" HIT a key... ");
- }// end if so
- m=x; n=y; f=f+c;// c
- if (f>pc) {break;}
- }//END FOR ff
- }//end def
- //______________________________
- function cls(){
- ctx.fillStyle = "green"; ctx.fillRect(0,0,500,500);
- }
- //________________________________
- function waits(wt) {
- var nbr=0; for (var ctr=1; ctr<(wt*10000000); ctr++) {nbr=ctr+1;}
- }// end def .... 7 zeros
- //____________________________
- function errWindow(errMsg,location,lineNum){
- var debugWin = window.open("","debugWin","height=200,width=300,resize=yes") ;
- debugWin.document.write("<h2>There was an error at line " + lineNum) ;
- debugWin.document.write("<br>The error was: " + errMsg) ;
- debugWin.document.close() ;
- return true ;
- } // end def
- // ____________________________
- function askQty() {
- //alert("We've begun asking for Qty ");
- var ans = prompt(" Loops ? 1 to 10000 ");
- try {
- if( !ans || isNaN(ans) || ans < 1 || ans>10000) {ans=9; throw new Error("Not a valid number");}
- return ans;
- } //Eo try
- catch(errMsg){
- alert(errMsg.message);
- } //Eo catch
- } //Eofunc askQty
- //____________________________
- function show_message(){
- window.alert('!');
- } // end def
- //////////////////////////////////////
- // NO MORE FUNCTION DEFINITIONS...
- //////////////////////////////////////
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement