From bfac75a01c0955a5cee310180f27936429348e84 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Wed, 24 Apr 2024 19:01:52 -0600 Subject: [PATCH] draw rectangles associated with each sample point, https://github.com/phetsims/faradays-electromagnetic-lab/issues/156 --- js/common/model/PickupCoil.ts | 2 ++ js/common/view/PickupCoilAreaNode.ts | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/common/model/PickupCoil.ts b/js/common/model/PickupCoil.ts index 94266c64..da347b2d 100644 --- a/js/common/model/PickupCoil.ts +++ b/js/common/model/PickupCoil.ts @@ -78,6 +78,7 @@ export default class PickupCoil extends FELMovable { // B-field sample points along the vertical axis of the coil public readonly samplePointsProperty: TReadOnlyProperty; + public readonly samplePointSpacing: number; // DEBUG: Writeable via developer controls only, when running with &dev query parameter. Dividing the coil's EMF by // this number will give us the coil's normalized current (see Coil.normalizedCurrentProperty), which determines the @@ -196,6 +197,7 @@ export default class PickupCoil extends FELMovable { this.samplePointsProperty = new DerivedProperty( [ this.coil.loopRadiusProperty ], loopRadius => createSamplePoints( loopRadius, options.samplePointsSpacing ) ); + this.samplePointSpacing = options.samplePointsSpacing; this.transitionSmoothingScaleProperty = new NumberProperty( options.transitionSmoothingScale, { range: new Range( 0.1, 1 ) diff --git a/js/common/view/PickupCoilAreaNode.ts b/js/common/view/PickupCoilAreaNode.ts index 49dde743..866b1e32 100644 --- a/js/common/view/PickupCoilAreaNode.ts +++ b/js/common/view/PickupCoilAreaNode.ts @@ -69,8 +69,9 @@ export default class PickupCoilAreaNode extends Node { } } - shape.moveTo( -chordLength / 2, samplePoint.y ); - shape.lineTo( chordLength / 2, samplePoint.y ); + // Draw the rectangle for the portion of the coil's area that is associated with this sample point. + shape.rect( -chordLength / 2, samplePoint.y - pickupCoil.samplePointSpacing / 2, + chordLength, pickupCoil.samplePointSpacing ); } ); path.shape = shape; }