Class Simulation

A Simulation object that contains Universes and a Visualizer.

Constructors

  • Create a new Simulation object with the provided Universes and visualization config.

    Parameters

    • universes: Universe | Universe[]

      array of Universes.

    • __namedParameters: {
          controller?: ControllerType;
          looped?: boolean;
          maxFrameRate?: number;
          maxTrailLength?: number;
          record?: boolean;
          showDebugInfo?: boolean;
          showTrails?: boolean;
          visType?: VisType;
      }
      • Optional controller?: ControllerType
      • Optional looped?: boolean
      • Optional maxFrameRate?: number
      • Optional maxTrailLength?: number
      • Optional record?: boolean
      • Optional showDebugInfo?: boolean
      • Optional showTrails?: boolean
      • Optional visType?: VisType

    Returns Simulation

Methods

  • Get the maximum trail length used in the visualization.

    Returns number

    maximum trail length.

  • Get whether trails are shown in the visualization.

    Returns boolean

    true if trails are shown.

  • True if the universe with the given label is shown.

    Parameters

    • label: string

      universe label.

    Returns boolean

    whether the universe is shown.

  • Get the speed of the simulation.

    Returns number

    speed of the simulation as a scale of normal time.

  • Get whether the simulation is playing.

    Returns boolean

    true if the simulation is playing.

  • Pause the simulation. Only works if the controller is 'code'.

    Returns void

  • Resume the simulation. Only works if the controller is 'code'.

    Returns void

  • Set the maximum trail length used in the visualization. Changes only apply on the next Simulation.play() call.

    Parameters

    • maxTrailLength: number

      maximum trail length.

    Returns void

  • Set whether to show trails in the visualization. Only works if the controller is 'code'.

    Parameters

    • showTrails: boolean

      true to show trails.

    Returns void

  • Set whether to show the universe with the given label. Only works if the controller is 'code'.

    Parameters

    • label: string

      universe label.

    • show: boolean

      true to show the universe.

    Returns void

  • Set the speed of the simulation. Only works if the controller is 'code'.

    Parameters

    • speed: number

      speed of the simulation as a scale of normal time.

    Returns void

  • Insert the simulation visualization in the div with the given id.

    Parameters

    • divId: string

      div id.

    • width: number

      width of the visualization.

    • height: number

      height of the visualization.

    • playSpeed: number = 1

      initial time scale.

    • startPaused: boolean = false

      whether to start the simulation paused.

    • recordFor: number = 1

      number of seconds to record for, only used if in record mode.

    • recordSpeed: number = 1

      speed of the recording, only used if in record mode.

    Returns void

Generated using TypeDoc