eriknau

nested containers

Jun 13th, 2016
84
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(500, 500);
  4.      glc.setDuration(5);
  5. //     glc.setFPS(20);
  6.    //  glc.setMode('single');
  7.      //glc.setEasing(false);
  8.     glc.styles.backgroundColor = "#005";
  9.     var list = glc.renderList,
  10.         width = glc.w,
  11.         height = glc.h,
  12.         color = glc.color;
  13.     var numStars = 150;
  14.    
  15.       var container = list.addContainer({
  16.         x: width / 2,
  17.         y: height / 2,
  18.         rotation: [0, 30]
  19.     });  
  20.     for(var i = 0; i<numStars; i++) {
  21.         x= Math.cos(2 * Math.PI * i / numStars) * 100;
  22.         y= Math.sin(2 * Math.PI * i / numStars) * 100;
  23.         var subContainer = list.addContainer({
  24.             x: x,
  25.             y: y,
  26.             parent: container,
  27.             rotation: [0,360],
  28.             phase: i*0.01
  29.             })
  30.         x= Math.cos(2 * Math.PI * i / numStars) * 30;
  31.         y= Math.sin(2 * Math.PI * i / numStars) * 30;
  32.         list.addStar({
  33.             x: x,
  34.             y: y,
  35.             fill: true,
  36.             fillStyle: glc.color.rgb(255,0,0),
  37.             stroke: true,
  38.             strokeStyle: glc.color.rgb(100,0,100),
  39.             lineWidth: 3,
  40.             outerRadius: 50,
  41.             innerRadius: 25,
  42.             points: 5,
  43.             rotation: [0, 360],
  44.             parent:subContainer,
  45.             phase: i*0.001
  46.     });
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment