MeasuringTapeNode¶
Overview¶
A scenery node that is used to represent a draggable Measuring Tape. It contains a tip and a base that can be dragged separately, with a text indicating the measurement. The motion of the measuring tape can be confined by drag bounds. The position of the measuring tape should be set via the basePosition and tipPosition rather than the scenery coordinates
@author Vasily Shakhov (Mlearner) @author Siddhartha Chinthapally (ActualConcepts) @author Aaron Davis (PhET Interactive Simulations) @author Martin Veillette (Berea College)
Class MeasuringTapeNode¶
Constructor¶
new MeasuringTapeNode( unitsProperty : TReadOnlyProperty<MeasuringTapeUnits>, providedOptions? : MeasuringTapeNodeOptions )¶
Instance Methods¶
reset()¶
dispose()¶
setDragBounds( newDragBounds : Bounds2 )¶
Sets the dragBounds of the measuring tape. In addition, it forces the tip and base of the measuring tape to be within the new bounds.
getDragBounds() : Bounds2¶
Gets the dragBounds of the measuring tape.
getLocalBaseCenter() : Vector2¶
Returns the center of the base in the measuring tape's local coordinate frame.
getLocalBaseBounds() : Bounds2¶
Returns the bounding box of the measuring tape's base within its local coordinate frame
startBaseDrag( event : PressListenerEvent )¶
Initiates a drag of the base (whole measuring tape) from a Scenery event.
Instance Properties¶
measuredDistanceProperty : TReadOnlyProperty<number>¶
(readonly)
the distance measured by the tape
isTipUserControlledProperty : TReadOnlyProperty<boolean>¶
(readonly)
isBaseUserControlledProperty : TReadOnlyProperty<boolean>¶
(readonly)
basePositionProperty : Property<Vector2>¶
(readonly)
tipPositionProperty : Property<Vector2>¶
(readonly)
modelViewTransformProperty : Property<ModelViewTransform2>¶
(readonly)
Static Methods¶
createIcon( providedOptions? : MeasuringTapeIconOptions ) : Node¶
Creates an icon of the measuring tape.
Type MeasuringTapeIconOptions¶
- tapeLength?: number
- & StrictOmit<NodeOptions, "children">
Type MeasuringTapeNodeOptions¶
NOTE: NodeTranslationOptions are omitted because you must use basePositionProperty and tipPositionProperty to position this Node.
- basePositionProperty?: Property<Vector2>
base Position in model coordinate reference frame (rightBottom position of the measuring tape image) - tipPositionProperty?: Property<Vector2>
tip Position in model coordinate reference frame (center position of the tip) - hasValue?: boolean
use this to omit the value and units displayed below the tape measure, useful with createIcon - dragBounds?: Bounds2
bounds for the measuring tape (in model coordinate reference frame), default value is everything, effectively no bounds - textPosition?: Vector2
- modelViewTransform?: ModelViewTransform2
- significantFigures?: number
- textColor?: TColor
- textBackgroundColor?: TColor
- textBackgroundXMargin?: number
- textBackgroundYMargin?: number
- textBackgroundCornerRadius?: number
- textMaxWidth?: number
- textFont?: Font
- baseScale?: number
- lineColor?: TColor
- tapeLineWidth?: number
- tipCircleColor?: TColor
- tipCircleRadius?: number
- crosshairColor?: TColor
- crosshairSize?: number
- crosshairLineWidth?: number
- isBaseCrosshairRotating?: boolean
- isTipCrosshairRotating?: boolean
- isTipDragBounded?: boolean
- interactive?: boolean
- baseDragStarted?: () => void
- baseDragEnded?: () => void
- phetioReadoutStringPropertyInstrumented?: boolean
- phetioFeaturedMeasuredDistanceProperty?: boolean
- baseDragListenerOptions?: SoundDragListenerOptions
Options passed to the drag listeners for the base and tip. - tipDragListenerOptions?: SoundDragListenerOptions
- baseKeyboardDragListenerOptions?: SoundKeyboardDragListenerOptions
- tipKeyboardDragListenerOptions?: SoundKeyboardDragListenerOptions
- & StrictOmit<NodeOptions, keyof NodeTranslationOptions>
Type MeasuringTapeUnits¶
- name: string
- multiplier: number
Source Code¶
See the source for MeasuringTapeNode.ts in the scenery-phet repository.