eriknau

25Days-18

Dec 18th, 2015
90
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(300, 300);
  4.     glc.setDuration(3);
  5.      glc.setFPS(17);
  6.     //glc.setMode("single");
  7.     // glc.setEasing(false);
  8.     glc.setMaxColors(50);
  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 numParts = 80,
  17.         rad = 100;
  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 < numParts; i++) {
  23.         xpos = Math.cos(2 * Math.PI * i / numParts) * rad;
  24.         ypos = Math.sin(2 * Math.PI * i / numParts) * rad;
  25.         oppXpos = Math.cos(2 * Math.PI * (i+numParts/2) / numParts) * rad;
  26.         oppYpos = Math.sin(2 * Math.PI * (i+numParts/2) / numParts) * rad;
  27.         pointToX = Math.cos(2 * Math.PI * (i-1) / numParts) * rad;
  28.         pointToY = Math.sin(2 * Math.PI * (i-1) / numParts) * rad;
  29.         list.addOval({
  30.             translationX: width/2,
  31.             translationY: height/2,
  32.             x: [xpos,oppXpos],
  33.             y: [ypos,oppYpos],
  34.             rx: 100,
  35.             ry: 25,
  36.             lineWidth:.6,
  37.             rotation: [pointDirection(xpos,ypos,pointToX,pointToY),pointDirection(pointToX,pointToY,xpos,ypos)],
  38.             // fillStyle: color.randomRGB(),
  39.             stroke: true,
  40.             fill: false,
  41.             strokeStyle: "yellow",
  42.             phase: i*0.001
  43.         })
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment