Displays a Rope by showing a straight line when the Rope is tight, or a jagged line when the Rope has slack. Can have a different color when tight or slack, see setColorTight and setColorSlack.

The position is reported as the midpoint of the Rope by getPosition. The position is determined by the position of the Rope, so setPosition has no effect, and the DisplayRope is never dragable.

Implements

Constructors

Properties

colorSlack_: undefined | string

Color when rope is slack; a CSS3 color value

colorTight_: undefined | string

Color when rope is tight; a CSS3 color value

thickness_: undefined | number

Thickness of lines when drawing the rope, in screen coordinates, so a value of 1 means a 1 pixel thick line.

pathLength: 6 = 6.0

the fixed length of the un-transformed path

pathWidth: 0.5 = 0.5

the fixed width of the un-transformed path

Methods

  • Whether the DisplayObject contains the given world coordinates point.

    Parameters

    • _p_world: Vector

      the point in world coordinates

    Returns boolean

    true if this DisplayObject contains the given point

  • Draws this DisplayObject using the given CoordMap.

    Parameters

    • context: CanvasRenderingContext2D

      the canvas's context to draw this object into

    • map: CoordMap

      the mapping to use for translating between simulation and screen coordinates

    Returns void

  • Thickness to use when drawing the line, in screen coordinates, so a unit is a screen pixel.

    Returns number

  • Sets the z-index which specifies front-to-back ordering of objects; objects with a higher zIndex are drawn over (in front of) objects with a lower zIndex.

    Returns number

    the zIndex of this DisplayObject

  • Sets whether this DisplayObject is currently dragable; has no effect on objects that are not dragable.

    Parameters

    • _dragable: boolean

      whether this DisplayObject should be dragable

    Returns void

  • Sets this DisplayObject's position in simulation coordinates of the containing SimView. Each type of DisplayObject has a different policy regarding whether this will have an effect. Generally the policies are:

    • If the DisplayObject does not represent a SimObject, then the position can be set. Examples are DisplayClock, EnergyBarGraph.

    • If the SimObject's position is dependent on other objects, then the position cannot be set. Examples are DisplayConnector, DisplayRope, DisplaySpring.

    • If the SimObject can be moved independently and isDragable is true, then the position of the SimObject is modified. Example: DisplayShape.

    Parameters

    • _position: GenericVector

      this DisplayObject's position, in simulation coordinates.

    Returns void

  • Thickness to use when drawing the line, in screen coordinates, so a unit is a screen pixel.

    Parameters

    • value: undefined | number

    Returns DisplayRope

    this object for chaining setters

  • Sets the z-index which specifies front-to-back ordering of objects; objects with a higher zIndex are drawn over objects with a lower zIndex. Default is zero.

    Parameters

    • zIndex: number

      the zIndex of this DisplayObject

    Returns void

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

  • Draws the rope using the given AffineTransform, which specifies the combination of translating, stretching, rotating the rope to its current position, and also the sim-to-screen transform. The path is drawn into a size of 6.0 long by 0.5 wide, so that when it is scaled up or down, it doesn't get too distorted. *

    Parameters

    • context: CanvasRenderingContext2D

      the canvas's context to draw into *

    • at: AffineTransform

      the transform to apply to each point

    Returns void

Generated using TypeDoc