Advertisement
xeromino

grads

Nov 24th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onGLC(glc) {
  2.     glc.loop();
  3.     // glc.playOnce();
  4.     glc.size(540, 540);
  5.     glc.setDuration(2.5);
  6.     glc.setFPS(40);
  7.     glc.setMode("single");
  8.     //glc.styles.backgroundColor = "rgba(255,255,255,.3)";
  9.     // glc.setEasing(false);
  10.    
  11.     var list = glc.renderList,
  12.         width = glc.w,
  13.         height = glc.h,
  14.         color = glc.color;
  15.  
  16.     // your code goes here:
  17.  
  18.    
  19.     var edge = width/5
  20.         num = 4,
  21.         sz = (width-2*edge)/num,
  22.         rad = sz*.4;
  23.  
  24.     var linearGradient = glc.getContext().createLinearGradient(0, -sz/2, 0, sz/2);
  25.     linearGradient.addColorStop(0, "black");
  26.     linearGradient.addColorStop(1, "white");
  27.    
  28.     var radialGradient = glc.getContext().createRadialGradient(0, 0, 0, 0, 0, sz/2);
  29.     radialGradient.addColorStop(0, "white");
  30.     radialGradient.addColorStop(1, "darkred");
  31.    
  32.    
  33.     for (var x=edge; x<=width-edge; x+=sz) {
  34.         for (var y=edge; y<=height-edge; y+=sz){
  35.         var s2=6, s = Math.floor(3+Math.random()*s2),
  36.             r = Math.random()*360;
  37.             if (Math.random()*1>.1){
  38.                 list.addPoly({
  39.                     x: x,
  40.                     y: y,
  41.                     sides: s,
  42.                     rotation: [r,r+360],
  43.                     lineWidth: 1,
  44.                     //fill:false,
  45.                     //fillStyle: "rgba(0,0,0,.2)",
  46.                     //fillStyle: color.hsv(360/s2*s,.8,.8),
  47.                     fillStyle: linearGradient,
  48.                     stroke: false,
  49.                     strokeStyle: "rgba(0,0,0,.8)",
  50.                     radius: rad,
  51.                     //shake: 5
  52.                 });
  53.             } else {
  54.                 list.addCircle({
  55.                     x: x,
  56.                     y: y,
  57.                     radius: rad,
  58.                     fillStyle: radialGradient
  59.                 });
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement