Code
var bg = new Path.Rectangle({
size: view.bounds,
fillColor: 'black'
})
var radiusOfBrush = 50
function Ball(point) {
this.path = new Path.Circle({
radius: 10,
fillColor: 'blue',
center: point,
applyMatrix: false,
parent: group
})
}
Ball.prototype = {
iterate: function() {
this.path.position.x += 200
},
update: function(event) {
var point = new Point(event.x, event.y)
if (point.isClose(this.path.position, radiusOfBrush)){
this.path.fillColor = 'red'
this.path.tweenTo({
fillColor: 'red'
}, 200)
} else{
this.path.fillColor = 'blue'
}
}
}
var balls = []
var numBalls = 40
var group = new Group()
for (var x = 0; x < numBalls; x++){
for (var y = 0; y < numBalls/2; y++){
var point = new Point(x * 20, y * 20)
var ball = new Ball(view.center + point)
balls.push(ball)
}
}
function onMouseMove(event){
for (var i = 0; i < balls.length; i++){
balls[i].update(event.point)
}
}
group.position = view.center