Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- </head>
- <body>
- <canvas id="target" width="640" height="480"></canvas>
- </body>
- <script type="text/javascript">
- R=Math.random;
- canvas = document.getElementById("target");
- rand_color = function(alpha){
- return "rgba("+parseInt(R()*255)+","+parseInt(R()*255)+","+parseInt(R()*255)+","+alpha+ ")";
- }
- radial_gradient = function(t, c1, c2){
- var ctx = t.getContext("2d");
- var grd=ctx.createRadialGradient(t.width/2,t.height/2,0,t.width/2,t.height/2,t.width);
- grd.addColorStop(0,c1);
- grd.addColorStop(1,c2);
- // Fill with gradient
- ctx.fillStyle=grd;
- ctx.fillRect(0,0,t.width,t.height);
- return ctx;
- }
- Z = function(t){B=t.getClientRects()[0];
- t.width=B.width;t.height=B.height;
- t.x=B.left;t.y=B.top;
- t.c = t.style.color;
- if (t.c == "") {t.c=rand_color(R()*0.1)};
- M=t.width;
- //starting iteration
- t.j=(R()*10000);
- //iteration step
- t.l=R()*2//0.01
- //t.l = 0.2
- t.lc=2+(R()*2-1)
- t.ls=3+(R()*3-1.5)
- T=Math;S=T.sin;Q=T.cos;t.C=t.getContext("2d");t.a=t.b=1;
- //t.C.globalCompositeOperation = "additive";
- t.r = function(){
- t.c=rand_color(R()*0.02)
- //t.l += (R()*0.1)-0.05
- t.j += (R()*0.1)-0.05
- t.C.fillStyle=t.c;
- t=this;
- x=y=0;
- i=1e4*1;
- t.j+=t.l;
- t.a=S(t.j)*t.lc//2;
- t.b=Q(t.j)*t.ls//3;
- while(--i){
- t.C.fillRect((x*M/4*Q(t.j*0.1) )+t.width/2,
- (y*M/4*Q(t.j*0.1) )+t.height/2,1,1);
- z=S(t.a*y)-Q(t.b*x);
- y=S(x)-Q(y);
- x=z}}
- if (!t.o){t.o=1;setInterval(t.r.bind(t));}};
- canvas.style.background = "black"//rand_color(1);
- radial_gradient(canvas, rand_color(0.3),rand_color(0.3));
- Z(canvas);
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement