Here is the FlashlightNode constructor. Would be good to add some inner line comments describing what the shape looks like, why the flashlight image is positioned where it is, which direction it is pointing, etc.
function FlashlightNode( rotation, color, options ) {
Node.call( this, { rotation: rotation } );
var scale = 0.8;
var flashlightImage = new Image( flashlight,
{
scale: scale,
left: this.centerX,
centerY: this.centerY
} );
var startX = flashlightImage.left + 15;
var centerY = flashlightImage.centerY + 0.5;
var dx = 20 / 0.12 * scale;
var dy = 3 / 0.12 * scale;
var beamShape = new Shape().
moveTo( startX, centerY + dy ).
lineTo( startX - dx, centerY + dy * 2 ).
lineTo( startX - dx, centerY - dy * 2 ).
lineTo( startX, centerY - dy ).
close();
this.addChild( new Path( beamShape, { fill: color } ) );
this.addChild( flashlightImage );
this.mutate( options );
}
Here is the FlashlightNode constructor. Would be good to add some inner line comments describing what the shape looks like, why the flashlight image is positioned where it is, which direction it is pointing, etc.