eriknau

25Days-6

Dec 6th, 2015
189
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(.5);
  5.     // glc.setFPS(20);
  6.     glc.setMode("single");
  7.     glc.setEasing(false);
  8.     // glc.setMaxColors(256);
  9.     glc.styles.shadowColor = "rgba(0,0,0,0.4)";
  10.     glc.styles.shadowOffsetX = 5;
  11.     glc.styles.shadowOffsetY = 5;
  12.     glc.styles.shadowBlur = 10;
  13.  
  14.     var list = glc.renderList,
  15.         width = glc.w,
  16.         height = glc.h,
  17.         color = glc.color;
  18.  
  19.     var ratio = 0.18, toothDepth = 9,
  20.         radius1 = 50, x1 = 50, y1 = 100,
  21.         radius2 = 70, x2 = x1+radius1+radius2-toothDepth,
  22.         radius3 = 40, x3 = x2+radius2+radius3-toothDepth,
  23.         radius4 = 35, y4 = y1+radius3+radius4-toothDepth,
  24.         radius5 = 90, x5 = x3+50, y5 = y4 + 105,
  25.         radius6 = 45, x6 = x5-radius6-radius5+toothDepth,
  26.         radius7 = 75, x7 = x6-radius7-radius6+toothDepth,
  27.         radius8 = 35, x8 = x7,y8 = y5-radius8-radius7+toothDepth+1;
  28.  
  29.     var addNewGear = function(rad, posx, posy, rot1, clockwise) {
  30.         var numTeeth = Math.floor(rad*ratio),
  31.             rot2 = 360 / numTeeth;
  32.             if(!clockwise) {
  33.                 rot2 *= -1;
  34.             }
  35.             rot2 += rot1;
  36.         list.addGear({
  37.             x: posx,
  38.             y: posy,
  39.             radius: rad,
  40.             teeth: numTeeth,
  41.             rotation: [rot1,rot2],
  42.             fill:true,
  43.             fillStyle: color.randomRGB()
  44.         })  
  45.         list.addCircle({
  46.             x: posx,
  47.             y: posy,
  48.             fill: "black",
  49.             stroke: false,
  50.             radius: 10
  51.         })    
  52.     }
  53.  
  54.     addNewGear(radius1,x1,y1,0,true);
  55.     addNewGear(radius2,x2,y1,3,false);
  56.     addNewGear(radius3,x3,y1,27,true);
  57.     addNewGear(radius4,x3,y4,-6,false);
  58.     addNewGear(radius5,x5,y5,5,true);
  59.     addNewGear(radius6,x6,y5,-4,false);
  60.     addNewGear(radius7,x7,y5,6,true);
  61.     addNewGear(radius8,x8,y8,6,false);
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment