H=()=>{return"#"+"F00FF090F".substr(A(0,6),3)};A=(b,d)=>{return(d-b)*Math.random()+b};L=(b)=>{for(p in b)b[p[0]+(p[6]||"")]=b[p]};F=(b,d)=>{b[T="strokeStyle"]=H();b.ba();b.a(P+A(100,C),d,A(9,C),0,7);b.s()};Y=()=>{[x,y].map((b)=>{b.fc(P,0,2*W,C);X=P/W;if(0<X){F(b,0);F(b,C);if(3<X&&8>X)for(q=0;9>q;q++)for(z=A(1,9)*q*9,Z=A(3,9)*q*5,b.se([n=A(3,9),3]),i=0;i<n;i++)for(Z+=9,b[T]=H(),b.ba(),j=0;j<n;j++)b.m(V=P+z+j*A(25,50),Z),b.l(V+A(50,150),Z),b.s();if(1<X)for(v=0;21>v;v++)b[T]=H(),b.lineWidth=A(1,9),b.ba(),b.m(z=P+45*v,A(9,C)),b.l(z,A(9,C)),b.s()}});P+=W;P%=9*W};L(c);c.fc(0,0,a[U="width"]=W=900,a.height=C=400);x=(s=a[o="cloneNode"]())[B="getContext"]("2d");y=(t=a[o]())[B]("2d");s[U]=t[U]=9*W;P=I=0;L(x);L(y);Y();setInterval(()=>{c[h="globalCompositeOperation"]="source-over";c[k="globalAlpha"]=1-X/12;c.fc(0,0,W,C);c[h]="lighter";c[k]=.5;for(i=0;i<W/2;++i)E=2*i/W,Q=(1+E)*C/2,O=9*C*E,c.da(s,J=I+250-250*E,K=(C-Q)/2,R=30*E+1,Q,W/2-i,(C-O)/2,N=60*E,O),c.da(t,J,K,R,Q,W/2+i,(C-O)/2,N,O);I+=5;I%=9*W;(I+C)%W^0?1:Y()},16)
// Get a random nice color
E=()=>{
return'#' 'F00FF090F'.substr(R(0,6),3)
}
// Get a random number between two numbers
R=(a,b)=>{
return(b - a)*Math.random() a
}
// Abbreviate object methods (by Marijn Haverbeke)
// Taken from the first js1k winner - Legend Of The Bouncing Beholder
// http://js1k.com/2010-first/details/635
M=(x)=>{
for (p in x)
x[p[0] (p[6]||'')]=x[p]
}
// Circle
F=(c,y)=>{
c.strokeStyle = E();
c.ba(); // c.beginPath
c.a(P R(100,H), y, R(9,H), 0, 7); // c.arc
c.s() // c.stroke
}
// Pattern generating function
Y=()=>{
// x, y - canvases on which we generate patterns to display
[x,y].map((c)=>{
c.fc(P, 0, 2*W, H);
// X - number of the canvas where we are, between 1 and 9
X=P/W;
if (X>0) {
F(c, 0);
F(c, H);
// Horizontal blocks of lines
if (X>3&&X<8)
for (q=0;q<9;q ) {
z=R(1,9)*q * 9;
Z=R(3,9)*q * 5;
c.se([n = R(3, 9), 3]); // c.setLineDash
for (i=0; i<n; i ) {
Z = 9;
c.strokeStyle = E();
c.ba();
for (j=0; j<n; j ) {
c.m(V = P z j*R(25, 50), Z); // c.moveTo
c.l(V R(50, 150), Z); // c.lineTo
c.s()
}
}
}
// Vertical lines
if (X>1)
for (v=0; v<21; v ) {
c.strokeStyle = E();
c.lineWidth = R(1, 9);
c.ba();
c.m(z = P v*45, R(9, H));
c.l(z, R(9, H));
c.s()
}
}
})
P =W;
P=P%(9*W)
}
M(c);
// Displayed canvas
a.width = W = 900;
a.height = H = 400;
c.fc(0, 0, W, H); // c.fillRect
// Two 9x width offscreen canvases to render left and right
// channel patterns in the loop
s = a.cloneNode();
t = a.cloneNode();
x = s.getContext('2d');
y = t.getContext('2d');
s.width = t.width = 9*W;
// P - position within the pattern canvases
// I - position at the main canvas
P = I = 0;
M(x);
M(y);
Y();
// Slit-scan function
// Emulates technique used in 2001: A Space Odyssey to create
// star gate effect. See more at:
// http://nofilmschool.com/2013/08/learn-how-to-create-slit-screen-sequences
// http://seriss.com/people/erco/2001/
// Take parts two stereo canvases and redraw them on a displayed canvas
setInterval(()=>{
c.globalCompositeOperation = 'source-over';
c.globalAlpha = 1-X/12;
c.fc(0, 0, W, H);
c.globalCompositeOperation = 'lighter';
c.globalAlpha = .5;
for (i=0; i<W/2; i) {
A=2*i/W;
Q=(1 A)*H/2;
O=9*H*A;
J=I 250-A*250;
K=(H-Q)/2;
L=30*A 1;
N=60*A;
c.da(s, // c.drawImage
J, K, L, Q,
W/2-i, (H-O)/2, N, O);
c.da(t,
J, K, L, Q,
W/2 i ,(H-O)/2, N, O)
}
I =5;
I=I%(9*W);
if ((I H)%W===0) Y()
},16)