- Author:
- razorwolf
- Twitter:
- @
- GitHub:
- Facebook:
- Google+:
- +
- Reddit:
- /r/
- Pouet:
- Website:
- Compo:
- classic
- Demo link:
- https://js1k.com/2010-first/demo/524
- Shortlink:
- https://js1k.com/524
- Blog post:
- please update here!
- Bytes:
- 1023
- Chars:
- 1023
- Submission
body=document.body;
body.style.margin="0";
body.style.overflow="hidden";
w=window.innerWidth;
h=window.innerHeight;
c=document.getElementById("c");
c.width=w;
c.height=h;
C=c.getContext("2d");
function r(m){return Math.ceil(m*Math.random());}
function box(n,c){
this.p=new Array(n);
this.V=new Array(n);
this.c=c;
for(i=0;i<n;i++){
this.p[i]=new Array(2);
this.p[i][0]=r(w);
this.p[i][1]=r(h);
this.V[i]=new Array(2);
this.V[i][0]=r(5);
this.V[i][1]=r(5);
}
this.dB=function(m){
C.beginPath();
for(i in this.p){
C.lineTo(this.p[i][0]-(this.V[i][0]*m),this.p[i][1]-(this.V[i][1]*m));
}
C.closePath();
C.stroke();
}
this.D = function(){
C.strokeStyle=this.c;
for(i in this.p){
this.p[i][0]+=this.V[i][0];
this.p[i][1]+=this.V[i][1];
if(this.p[i][0]>w || this.p[i][0]<0)this.V[i][0]*=-1;
if(this.p[i][1]>h || this.p[i][1]<0)this.V[i][1]*=-1;
this.dB(i);
}
}
}
b=new box(4,"#0f0");
r=new box(4,"#F00");
function d(){
C.fillRect(0,0,w,h);
b.D();
r.D();
}
setInterval("d()",50);
- Description
- An updated copy of the windows Mystify screensaver
- Base64 encoded
Ym9keT1kb2N1bWVudC5ib2R5Ow0KYm9keS5zdHlsZS5tYXJnaW49IjAiOw0KYm9keS5zdHlsZS5vdmVyZmxvdz0iaGlkZGVuIjsNCnc9d2luZG93LmlubmVyV2lkdGg7DQpoPXdpbmRvdy5pbm5lckhlaWdodDsNCmM9ZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoImMiKTsNCmMud2lkdGg9dzsNCmMuaGVpZ2h0PWg7DQpDPWMuZ2V0Q29udGV4dCgi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zZXRJbnRlcnZhbCgiZCgpIiw1MCk7
- Original source
<!doctype html>
<html>
<head>
<title>JS1k,1k demo submission [id]</title>
<meta charset="utf-8"/>
</head>
<body>
<canvas id="c"></canvas>
<script>
body=document.body;
body.style.margin="0";
body.style.overflow="hidden";
w=window.innerWidth;
h=window.innerHeight;
c=document.getElementById("c");
c.width=w;
c.height=h;
C=c.getContext("2d");
function r(m){return Math.ceil(m*Math.random());}
function box(n,c){
this.p=new Array(n);
this.V=new Array(n);
this.c=c;
for(i=0;i<n;i++){
this.p[i]=new Array(2);
this.p[i][0]=r(w);
this.p[i][1]=r(h);
this.V[i]=new Array(2);
this.V[i][0]=r(5);
this.V[i][1]=r(5);
}
this.dB=function(m){
C.beginPath();
for(i in this.p){
C.lineTo(this.p[i][0]-(this.V[i][0]*m),this.p[i][1]-(this.V[i][1]*m));
}
C.closePath();
C.stroke();
}
this.D = function(){
C.strokeStyle=this.c;
for(i in this.p){
this.p[i][0]+=this.V[i][0];
this.p[i][1]+=this.V[i][1];
if(this.p[i][0]>w || this.p[i][0]<0)this.V[i][0]*=-1;
if(this.p[i][1]>h || this.p[i][1]<0)this.V[i][1]*=-1;
this.dB(i);
}
}
}
b=new box(4,"#0f0");
r=new box(4,"#F00");
function d(){
C.fillRect(0,0,w,h);
b.D();
r.D();
}
setInterval("d()",50);
</script>
</body>
</html>