eriknau

ants

Dec 26th, 2015
123
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(1);
  5. //     glc.setFPS(20);
  6.      glc.setMode('single');
  7.      glc.setEasing(false);
  8.     glc.styles.backgroundColor = "white";
  9.    
  10.     var list = glc.renderList,
  11.         width = glc.w,
  12.         height = glc.h,
  13.         color = glc.color;
  14.    
  15.     function ant(xpos, ypos) {  
  16.         //upper/lower legs
  17.         for(var i = 0; i<2; i++) {
  18.             var rotator = list.addContainer({
  19.                 x: xpos,
  20.                 y: [ypos,ypos-80],
  21.                 rotation: [i ? 10 : -30,i ? -30 : 10]
  22.             })
  23.             for(var j = 0; j<2; j++) {
  24.                 list.addLine({
  25.                     parent: rotator,
  26.                     x0: -25,
  27.                     y0: j ? -25 : 25,
  28.                     x1: 25,
  29.                     y1: j ? 25 : -25,
  30.                     stroke: [i ? true : false, i ? false : true],
  31.                     lineWidth: 2
  32.                 })
  33.             }
  34.         }
  35.         //center legs
  36.         for(var i = 0; i<2; i++) {
  37.             var centerRotator = list.addContainer({
  38.                 x: xpos,
  39.                 y: [ypos,ypos-80],
  40.                 rotation: [i ? -20 : 40, i ? 40 : -20]
  41.             })
  42.             list.addLine({
  43.                 parent: centerRotator,
  44.                 x0: -30,
  45.                 y0: 0,
  46.                 x1: 30,
  47.                 y1: 0,
  48.                 stroke: [i ? true : false, i ? false : true],
  49.                 lineWidth: 2
  50.             })
  51.         }
  52.         //body
  53.         for(var i = 0; i<3; i++){
  54.             list.addCircle({
  55.                 x: xpos,
  56.                 y: [ypos+i*20-20,ypos+i*20-100],
  57.                 radius: 10
  58.             })        
  59.         }
  60.         //antennae
  61.         for(var l = 0; l<2; l++) {
  62.             list.addLine({
  63.                 x0: xpos,
  64.                 y0: [ypos-20, ypos - 100],
  65.                 x1: l ? xpos-10 : xpos+10,
  66.                 y1: [ypos - 45, ypos - 125],
  67.                 lineWidth: 1
  68.             })
  69.         }
  70.     }
  71.     for(var rows = -1; rows<8; rows++){
  72.         for(var num = 1; num<5; num++){
  73.             ant(num*80,rows*80);
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment