eriknau

25Days-19

Dec 19th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onGLC(glc) {
  2.     glc.loop();
  3.     // glc.size(200, 300);
  4.     glc.setDuration(3);
  5.      glc.setFPS(20);
  6.     glc.setMode("single");
  7.     // glc.setEasing(false);
  8.     glc.setMaxColors(20);
  9.     // glc.setQuality(1);
  10.         glc.styles.backgroundColor = "black";
  11.     var list = glc.renderList,
  12.         width = glc.w,
  13.         height = glc.h,
  14.         color = glc.color;
  15.  
  16.     var numLines = 150,
  17.         rad = 160;
  18.         //credit to stackexchange
  19.     function pointDirection(x1, y1, x2, y2) {
  20.         return Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI;
  21.     }
  22.     for (var i = 0; i < numLines; i++) {
  23.         xpos = Math.cos(2 * Math.PI * i / numLines) * rad;
  24.         ypos = Math.sin(2 * Math.PI * i / numLines) * rad;
  25.         oppXpos = Math.cos(2 * Math.PI * (i+numLines/2) / numLines) * rad;
  26.         oppYpos = Math.sin(2 * Math.PI * (i+numLines/2) / numLines) * rad;
  27.         pointToX = Math.cos(2 * Math.PI * (i+1) / numLines) * rad;
  28.         pointToY = Math.sin(2 * Math.PI * (i+1) / numLines) * rad;
  29.         var container = list.addContainer({
  30.             translationX: width/2,
  31.             translationY: height/2,
  32.             x:[xpos,oppXpos],
  33.             y: [ypos,oppYpos],
  34.             rotation: [pointDirection(xpos,ypos,pointToX,pointToY),pointDirection(pointToX,pointToY,xpos,ypos)],
  35.             phase: i*0.03
  36.         })
  37.         list.addLine({
  38.             parent: container,
  39.             x0: 0,
  40.             y0: -100,
  41.             x1: 0,
  42.             y1: 100,
  43.             lineWidth: 1,
  44.             stroke: true,
  45.             fill: false,
  46.             strokeStyle: "white",
  47.         })
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment