Draws a clock with two 'second hands': one tracks the simulation time, the other tracks real time. This makes it easy to see whether the simulation time is keeping up with real time.

Implements

Constructors

  • Parameters

    • simTimeFn: (() => number)

      function that returns current simulation time

        • (): number
        • Returns number

    • realTimeFn: (() => number)

      function that returns current real time

        • (): number
        • Returns number

    • Optional period: number

      Period of clock in seconds, the time it takes for the seconds hand to wrap around; default is 2 seconds.

    • Optional radius: number

      Radius of clock in simulation coords, default is 1.0.

    • Optional location: Vector

      Location of center of clock, in simulation coords.

    Returns DisplayClock

Properties

fillStyle_: string = 'rgba(255, 255, 255, 0.75)'

Color to fill circle with; default is transparent white so that it is visible over a black background.

font_: string = '14pt sans-serif'

Font to use for drawing the time, for example '10pt sans-serif'.

handColor_: string = 'blue'

Color to draw the second-hand showing simulation time.

handWidth_: number = 1

Thickness of clock hands, in screen coords (1 means one pixel).

lastSimTime_: number = 0

Last sim time drawn.

outlineColor_: string = 'black'

Color to use for drawing the outline of the clock, a CSS3 color value.

outlineWidth_: number = 1

Thickness of outline, in screen coords (1 means one pixel).

realColor_: string = 'red'

Color to draw the second-hand showing real time.

textColor_: string = 'blue'

Color to use for drawing the time, a CSS3 color value.

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

  • Returns color to fill circle with; default is transparent white so that it is visible over a black background.

    Returns string

    a CSS3 color value

  • Font used when drawing the text, a CSS font specification.

    Returns string

    a CSS font specification

  • Returns color to draw the second-hand showing simulation time.

    Returns string

    a CSS3 color value

  • Returns thickness of clock hands, in screen coords (1 means one pixel).

    Returns number

  • Returns color to draw the second-hand showing real time.

    Returns string

    a CSS3 color value

  • Returns thickness of outline, in screen coords (1 means one pixel).

    Returns number

  • Returns color to draw the second-hand showing real time.

    Returns string

    a CSS3 color value

  • 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 color to fill circle with; default is transparent white so that it is visible over a black background.

    Parameters

    • value: string

      a CSS3 color value

    Returns DisplayClock

    this object for chaining setters

  • 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

  • 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

    • Optional 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.

Generated using TypeDoc