// The amount of circles we want to make:
var count = 10;

// Create a symbol, which we will use to place instances of later:
var paths = [];
paths[0] = new Path.Circle(new Point(0, 0), 25);
paths[0].style = {
  //fillColor: 'white',
  //fillColor: '#5EBAAE',
  fillColor: '#FF7300',
  //strokeColor: 'blue'
  //strokeColor: '#5EBAAE'
  strokeColor: '#FF7300'
};
paths[1] = new Path.Circle(new Point(0,0), 10);
paths[1].style = {
  fillColor: '#AEBA5E',
  strokeColor: '#AEBA5E',
}
var symbols = [];
symbols[0] = new Symbol(paths[0]);
symbols[1] = new Symbol(paths[1]);
/* */
// Place the instances of the symbol:
for (var i = 0; i < count; i++) {
  // The center position is a random point in the view:
  var center = Point.random() * view.size;
  var center2 = Point.random() * view.size;
  var placedSymbols = []; 
  placedSymbols[0] = symbols[0].place(center);
  placedSymbols[0].scale(i / count);
  placedSymbols[1] = symbols[1].place(center2);
  placedSymbols[1].scale(i / count);
}
// Create rasters 
var rasters = [];
rasters.push(new Raster('DwarfField'));
rasters.push(new Raster('Gator1'));
rasters.push(new Raster('GD2'));
//rasters.push(new Raster('Harvest2'));
//rasters.push(new Raster('Heron'));
//rasters.push(new Raster('IMG_6389'));
rasters.push(new Raster('IMG_6358'));
//rasters.push(new Raster('People5'));
var j = rasters.length;
while (j) {
  j--;
  rasters[j].position = Point.random() * view.size;
  rasters[j].position.x = j * 300;
  //rasters[j].position.y = 180;
  rasters[j].size = new Size(160, 160);
}
// The onFrame function is called up to 60 times a second:
function onFrame(event) {
  symbols[0].definition.style.strokeColor.hue -= 1;
  symbols[0].definition.style.fillColor.hue -= 1;
  symbols[1].definition.style.strokeColor.hue += 1;
  symbols[1].definition.style.fillColor.hue += 1;
  // Run through the active layer's children list and change
  // the position of the placed symbols:
  var numberOfChildren = project.activeLayer.children.length;
  for (var i = 0; i < (numberOfChildren); i++) {
    var item = project.activeLayer.children[i];
    //if ( i % 10 == 0 ) {console.info(project.activeLayer.children[i]);}

    // Exclude rasters
    if ( item.bounds.width < 100 ) {
      // Move the item 1/20th of its width to the right. This way
      // larger circles move faster than smaller circles:
      item.position.x += item.bounds.width / 80;
    } else { // Now move rasters
      item.position.x += .3;
    }

    // If the item has left the view on the right, move it back
    // to the left:
    if (item.bounds.left > view.size.width) {
      item.position.x = -item.bounds.width;
    }
  }
}
/* */

