eriknau

arrows1

Dec 18th, 2015
115
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(4);
  5.     // glc.setFPS(20);
  6.     // glc.setMode("single");
  7.     // glc.setEasing(false);
  8.     glc.setMaxColors(256);
  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 numArrows = 50,
  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 < numArrows; i++) {
  23.         xpos = Math.cos(2 * Math.PI * i / numArrows) * rad;
  24.         ypos = Math.sin(2 * Math.PI * i / numArrows) * rad;
  25.         oppXpos = Math.cos(2 * Math.PI * (i+numArrows/2) / numArrows) * rad;
  26.         oppYpos = Math.sin(2 * Math.PI * (i+numArrows/2) / numArrows) * rad;
  27.         pointToX = Math.cos(2 * Math.PI * (i+numArrows/2) / numArrows) * rad;
  28.         pointToY = Math.sin(2 * Math.PI * (i+numArrows/2) / numArrows) * rad;
  29.         list.addArrow({
  30.             translationX: width/2,
  31.             translationY: height/2,
  32.             x: [xpos,oppXpos],
  33.             y: [ypos,oppYpos],
  34.             w: 40,
  35.             h: 20,
  36.             rotation: [pointDirection(xpos,ypos,pointToX,pointToY),pointDirection(pointToX,pointToY,xpos,ypos)],
  37.             fillStyle: color.randomRGB(),
  38.             phase: i*0.04
  39.         })
  40.         // list.addLine({
  41.         //     translationX: width/2,
  42.         //     translationY: height/2,
  43.         //     x0: xpos,
  44.         //     y0: ypos,
  45.         //     x1: oppXpos,
  46.         //     y1: oppYpos,
  47.         //     lineWidth: 1,
  48.         //     strokeStyle: "white"
  49.         // })
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment