eriknau

squares1

Jan 24th, 2016
126
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(400, 400);
  4.      glc.setDuration(4);
  5.     // glc.setFPS(20);
  6.      glc.setMode("single");
  7.      glc.setEasing(false);
  8.      glc.setMaxColors(30);
  9.    
  10.     glc.styles.backgroundColor = "white";
  11.  
  12.     var list = glc.renderList,
  13.         width = glc.w,
  14.         height = glc.h,
  15.         color = glc.color;
  16.  
  17.     var numSquares = 32,
  18.         diameter = 75,
  19.         squareSize = 150;
  20.  
  21.     var container = list.addContainer({
  22.         x: width / 2,
  23.         y: height / 2,
  24.         rotation: [45,-45]
  25.     });
  26.  
  27.  
  28.     for (var i = 0; i < numSquares; i++) {
  29.         newX = Math.cos(2 * Math.PI * i / numSquares) * diameter;
  30.         newY = Math.sin(2 * Math.PI * i / numSquares) * diameter;
  31.         newX2 = Math.cos(2 * Math.PI * (i+numSquares/2) / numSquares) * diameter;
  32.         newY2 = Math.sin(2 * Math.PI * (i+numSquares/2) / numSquares) * diameter;
  33.         list.addRect({
  34.             x: [newX,newX2],
  35.             y: [newY,newY2],
  36.             fill: false,
  37.             stroke: true,
  38.             w: squareSize,
  39.             h: squareSize,
  40.             parent: container,
  41.         })
  42.     };
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment