Skip to content

Commit

Permalink
Remove completed TODO and move functions below class, see phetsims/ci…
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 8, 2019
1 parent a0dad16 commit 0a3aa13
Showing 1 changed file with 39 additions and 40 deletions.
79 changes: 39 additions & 40 deletions js/capacitor/PlateChargeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,6 @@ define( require => {
const NUMBER_OF_PLATE_CHARGES = new Range( 1, 625 );
const NEGATIVE_CHARGE_SIZE = new Dimension2( 7, 2 );

/**
* Draw a positive charge with canvas. 'Plus' sign is painted with two
* overlapping rectangles around a center location.
* @private
*
* @param {Vector2} location - center location of the charge in view space
* @param {CanvasRenderingContext2D} context - context for the canvas methods
*/
const addPositiveCharge = ( location, context ) => {
const chargeWidth = NEGATIVE_CHARGE_SIZE.width;
const chargeHeight = NEGATIVE_CHARGE_SIZE.height;

context.fillStyle = POSITIVE_CHARGE_COLOR;
context.fillRect( location.x - chargeWidth / 2, location.y - chargeHeight / 2, chargeWidth, chargeHeight );
context.fillRect( location.x - chargeHeight / 2, location.y - chargeWidth / 2, chargeHeight, chargeWidth );
};

/**
* Draw a negative charge with canvas. 'Minus' sign is painted with a single
* rectangle around a center location.
* @private
*
* @param {Vector2} location
* @param {CanvasRenderingContext2D} context
* @param {string} orientation
*/
const addNegativeCharge = ( location, context, orientation ) => {
const chargeWidth = NEGATIVE_CHARGE_SIZE.width;
const chargeHeight = NEGATIVE_CHARGE_SIZE.height;

context.fillStyle = NEGATIVE_CHARGE_COLOR;
if ( orientation === Orientation.VERTICAL ) {
context.fillRect( location.x - chargeWidth / 2, location.y, chargeWidth, chargeHeight );
}
else {
context.fillRect( location.x - chargeHeight / 2, location.y - 2.5, chargeHeight, chargeWidth );
}
};

// TODO: This class seems never used directly
class PlateChargeNode extends CanvasNode {

/**
Expand Down Expand Up @@ -299,5 +259,44 @@ define( require => {
}
}

/**
* Draw a positive charge with canvas. 'Plus' sign is painted with two
* overlapping rectangles around a center location.
* @private
*
* @param {Vector2} location - center location of the charge in view space
* @param {CanvasRenderingContext2D} context - context for the canvas methods
*/
const addPositiveCharge = ( location, context ) => {
const chargeWidth = NEGATIVE_CHARGE_SIZE.width;
const chargeHeight = NEGATIVE_CHARGE_SIZE.height;

context.fillStyle = POSITIVE_CHARGE_COLOR;
context.fillRect( location.x - chargeWidth / 2, location.y - chargeHeight / 2, chargeWidth, chargeHeight );
context.fillRect( location.x - chargeHeight / 2, location.y - chargeWidth / 2, chargeHeight, chargeWidth );
};

/**
* Draw a negative charge with canvas. 'Minus' sign is painted with a single
* rectangle around a center location.
* @private
*
* @param {Vector2} location
* @param {CanvasRenderingContext2D} context
* @param {string} orientation
*/
const addNegativeCharge = ( location, context, orientation ) => {
const chargeWidth = NEGATIVE_CHARGE_SIZE.width;
const chargeHeight = NEGATIVE_CHARGE_SIZE.height;

context.fillStyle = NEGATIVE_CHARGE_COLOR;
if ( orientation === Orientation.VERTICAL ) {
context.fillRect( location.x - chargeWidth / 2, location.y, chargeWidth, chargeHeight );
}
else {
context.fillRect( location.x - chargeHeight / 2, location.y - 2.5, chargeHeight, chargeWidth );
}
};

return sceneryPhet.register( 'PlateChargeNode', PlateChargeNode );
} );

0 comments on commit 0a3aa13

Please sign in to comment.