Skip to content

Commit

Permalink
use actual (scaled) width of Image to compute clipArea, #283
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jan 11, 2022
1 parent a0411eb commit 7eaa7d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 8 additions & 7 deletions js/common/view/GOScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ class GOScreenView extends ScreenView {
visibleProperty: visibleProperties.secondPointVisibleProperty
} );

// create the target image
const targetNode = new TargetNode( model.representationProperty, model.firstTarget, model.optic,
visibleProperties.virtualImageVisibleProperty, visibleProperties.rayTracingVisibleProperty, modelViewTransform, {
tandem: options.tandem.createTandem( 'targetNode' )
} );

// The complete optical axis, to be put in the background
const opticalAxisNode = new OpticalAxisNode( model.optic.positionProperty, modelBoundsProperty, modelViewTransform, {
visibleProperty: model.optic.opticalAxisVisibleProperty
Expand All @@ -271,7 +277,8 @@ class GOScreenView extends ScreenView {
// the axis is going through the source object, real/virtual image, etc.
const opticalAxisForegroundNode = new OpticalAxisForegroundNode( model.optic.positionProperty,
model.representationProperty, model.sourceObject.positionProperty, model.firstTarget.positionProperty,
model.firstTarget.isVirtualProperty, model.barrier, modelBoundsProperty, modelViewTransform, {
model.firstTarget.isVirtualProperty, model.barrier, modelBoundsProperty, modelViewTransform,
targetNode.boundsProperty, {
visibleProperty: model.optic.opticalAxisVisibleProperty
} );

Expand Down Expand Up @@ -304,12 +311,6 @@ class GOScreenView extends ScreenView {
visibleProperties.virtualImageVisibleProperty, modelViewTransform, this.visibleBoundsProperty,
model.optic.positionProperty, model.firstTarget.positionProperty, model.firstTarget.isVirtualProperty, lightRays2Options );

// create the target image
const targetNode = new TargetNode( model.representationProperty, model.firstTarget, model.optic,
visibleProperties.virtualImageVisibleProperty, visibleProperties.rayTracingVisibleProperty, modelViewTransform, {
tandem: options.tandem.createTandem( 'targetNode' )
} );

// focal points (F)
const focalPointsNode = new Node( {
children: [
Expand Down
4 changes: 3 additions & 1 deletion js/common/view/OpticalAxisForegroundNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class OpticalAxisForegroundNode extends OpticalAxisNode {
* @param barrier
* @param modelBoundsProperty
* @param modelViewTransform
* @param targetNodeBoundsProperty
* @param providedOptions
*/
constructor( opticPositionProperty: IReadOnlyProperty<Vector2>,
Expand All @@ -43,6 +44,7 @@ class OpticalAxisForegroundNode extends OpticalAxisNode {
barrier: Barrier | null,
modelBoundsProperty: IReadOnlyProperty<Bounds2>,
modelViewTransform: ModelViewTransform2,
targetNodeBoundsProperty: IReadOnlyProperty<Bounds2>,
providedOptions: OpticalAxisNodeOptions ) {

const options = merge( {}, providedOptions ) as OpticalAxisNodeOptions;
Expand Down Expand Up @@ -98,7 +100,7 @@ class OpticalAxisForegroundNode extends OpticalAxisNode {

// The second rectangle is between the thing on the left and the left edge of the picture frame on the right.
const x2 = modelViewTransform.modelToViewX( leftPosition.x );
const halfFrameWidth = 34; //TODO get this from sourceObject.boundsProperty, or from sourceObjectNode
const halfFrameWidth = targetNodeBoundsProperty.value.width / 2;
const clipWidth2 = modelViewTransform.modelToViewX( rightPosition.x ) - halfFrameWidth - x2;

clipArea = new Shape()
Expand Down

0 comments on commit 7eaa7d7

Please sign in to comment.