SHARE
TWEET

Untitled

a guest May 26th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //########################## Splatter screen with colored dots
  2. //    splatter(
  3. //        number of blobs,
  4. //        max size of blobs in pixels,
  5. //        time between each blob in miliseconds
  6. //        );
  7.  
  8. function rdm(fork) {
  9.   return Math.floor(Math.random()*(fork));
  10. }
  11. function randColor(a) {
  12.   var r = rdm(255),
  13.       g = rdm(255),
  14.       b = rdm(255);
  15.   a = a || (Math.random()*1.75);
  16.   return "rgba("+r+","+g+","+b+","+a+")";
  17. }
  18. function splatter(maxBlob, blobSize, delay) {
  19.   var w = window,                               //get screen size
  20.       d = document,
  21.       e = d.documentElement,
  22.       g = d.getElementsByTagName('body')[0],
  23.       x = w.innerWidth || e.clientWidth || g.clientWidth,
  24.       y = w.innerHeight|| e.clientHeight|| g.clientHeight;
  25.      
  26.   maxBlob = maxBlob || (x*y/800);               //defaults values
  27.   blobSize = blobSize || 46;
  28.   delay = delay || 100;
  29.  
  30.   var wrap = document.createElement("div"),     //create wrapping div
  31.       ws = wrap.style;
  32.   ws.position = "absolute";
  33.   ws.top = ws.left = "0";      
  34.   ws.height = ws.width = "100%";
  35.   ws.zIndex = "10";
  36.   ws.overflow = "hidden";
  37.   ws.background = "transparent";
  38.   g.appendChild(wrap);
  39.  
  40.   for (i=1; i<maxBlob; i++){                    //create blobs and splatter loop
  41.     setTimeout(function(){
  42.       var blob = document.createElement("div"),
  43.           bs = blob.style,
  44.           top = rdm(y) - (blobSize/2),
  45.           left = rdm(x) - (blobSize/2),
  46.           size = rdm(blobSize);
  47.       size+=(size & 1);
  48.       bs.position = "absolute";
  49.       bs.top = top+"px";      
  50.       bs.left = left+"px";      
  51.       bs.height = bs.width = size+"px";
  52.       bs.borderRadius = (size/2)+"px";
  53.       bs.background = randColor();
  54.  
  55.       wrap.appendChild(blob);
  56.  
  57.     }, i*delay);
  58.   }
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top