Advertisement
xeromino

hexa.fun

Nov 21st, 2015
219
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.setEasing(false);
  9.    
  10.     var list = glc.renderList,
  11.         width = glc.w,
  12.         height = glc.h;
  13.  
  14.     // your code goes here:
  15.  
  16.     var num = 100;
  17.     var yPos, sz, p, dir;
  18.     var even = true;
  19.     var col1, col2;
  20.  
  21.     for (var i=0; i<num; i++){
  22.         if (even) {
  23.             dir =((Math.random()*1)>.5) ? 1 : -1;
  24.             if ((Math.random()*1)>.9) {
  25.                 col1 = "rgba(255,0,0,1)";
  26.                 col2 = col1;
  27.             } else {
  28.                 col1 = "rgba(255,255,255,.25)";
  29.                 col2 = "rgba(0,0,0,1)"
  30.             }
  31.             //col2 = ((Math.random()*1)>.9) ? "rgba(255,0,0,1)": "rgba(0,0,0,1)";
  32.             yPos = Math.random()*height;
  33.             sz = 20+Math.random()*20;
  34.             p = Math.floor(Math.random()*Math.PI*2);
  35.         }
  36.         list.addPoly({
  37.             x: [width/num*i,width/num*(i+1)],
  38.             y: even ? [yPos+height+sz,yPos] : [yPos,yPos-height-sz],
  39.             sides: 6,
  40.             radius: even ? [sz, sz*2] : [sz*2,sz],
  41.             rotation: [0,180*dir],
  42.             stroke: true,
  43.             lineWidth: 3,
  44.             strokeStyle: "white",
  45.             fillStyle: even ? [col1,col2 ]:[col2, col1] ,
  46.             phase: p
  47.         });
  48.         even =! even;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement