Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code comments within the FlashlightNode constructor #37

Closed
samreid opened this issue Jun 24, 2014 · 2 comments
Closed

Add code comments within the FlashlightNode constructor #37

samreid opened this issue Jun 24, 2014 · 2 comments
Assignees

Comments

@samreid
Copy link
Member

samreid commented Jun 24, 2014

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 );
  }
@aaronsamuel137
Copy link
Contributor

Comments updated. Assigning to @samreid for review

@samreid
Copy link
Member Author

samreid commented Jun 24, 2014

Looks good, thanks! Closing.

@samreid samreid closed this as completed Jun 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants