Alexander Deplov

Simple star sky, remove after delay

Simple star sky, remove after delay

Code

var bg = new Path.Rectangle({
    size: view.bounds,
    fillColor: 'black',
    position: view.center
})

var objectsGroup = new Group()

function createCircle(point){
  var path = new Path.Circle({
    radius: 2,
    fillColor: new Color.random(),
    center: point,
    applyMatrix: false,
    parent: objectsGroup
  })

  path.sendToBack()

  path.onFrame = function(event){
    this.scaling += 0.1 * Math.random()
  }
 
  setTimeout(function() {
    path.remove()

  }, 1000 * Math.random()) // 1000 milliseconds = 1 second

}

function onFrame(event){
    if (event.count % 2 == 0){
      for (var i = 0; i < 10; i++){
        createCircle(new Point(Math.random() * view.size.width, Math.random() * view.size.height))
      }
    }

    if (event.count > 30){
        objectsGroup.children[0].remove()
    }
}