Skip to content

ParametricSpringNode

Overview

Spring described by a parametric equation. This implementation is a variation of the cycloid equation. A prolate cycloid (see http://mathworld.wolfram.com/ProlateCycloid.html) comes closest to this implementation, although it doesn't include aspect ratio and delta phase.

The origin (0, 0) of this node is at its left center. The front and back of the spring are drawn as separate paths to provide pseudo-3D visual cues. Performance can be improved dramatically by setting options.pathBoundsMethod to 'none', at the expense of layout accuracy. If you use this option, you can only rely on Node.x and Node.y for doing layout. See Path.boundsMethod for additional details.

The "Spring" screen in the scenery-demo application provides an extensive test harness for ParametricSpringNode.

@author Martin Veillette (Berea College) @author Chris Malley (PixelZoom, Inc.)

Class ParametricSpringNode

import { ParametricSpringNode } from 'scenerystack/scenery-phet';

Constructor

new ParametricSpringNode( providedOptions? : ParametricSpringNodeOptions )

Instance Methods

reset()

Instance Properties

loopsProperty : NumberProperty

(readonly)

radiusProperty : NumberProperty

(readonly)

aspectRatioProperty : NumberProperty

(readonly)

pointsPerLoopProperty : NumberProperty

(readonly)

lineWidthProperty : NumberProperty

(readonly)

phaseProperty : NumberProperty

(readonly)

deltaPhaseProperty : NumberProperty

(readonly)

xScaleProperty : NumberProperty

(readonly)

Type ParametricSpringNodeOptions

import type { ParametricSpringNodeOptions } from 'scenerystack/scenery-phet';
  • frontColor?: TColor
    colors used for the gradient strokes
  • middleColor?: TColor
  • backColor?: TColor
  • leftEndLength?: number
    length of the horizontal line added to the left end of the coil
  • rightEndLength?: number
    {number} length of the horizontal line added to the right end of the coil
  • loops?: number
    number of loops in the coil
  • pointsPerLoop?: number
    number of points used to approximate 1 loop of the coil
  • radius?: number
    radius of a loop with aspect ratio of 1:1
  • aspectRatio?: number
    y:x aspect ratio of the loop radius
  • lineWidth?: number
    lineWidth used to stroke the Paths
  • phase?: number
    phase angle of where the loop starts, period is (0,2*PI) radians, counterclockwise
  • deltaPhase?: number
    responsible for the leaning of the coil, variation on a Lissjoue curve, period is (0,2*PI) radians
  • xScale?: number
    multiplier for radius in the x dimension, makes the coil appear to get longer
  • & PickOptional<PathOptions, "boundsMethod"> & NodeOptions

Source Code

See the source for ParametricSpringNode.ts in the scenery-phet repository.