Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Space

Space is an abstract class that represents a general context for expressing Pts. See Space guide for details.

Hierarchy

Index

Properties

Private _animID

_animID: number = -1

Protected _ctx

_ctx: any

Protected _isReady

_isReady: boolean = false

Private _pause

_pause: boolean = false

Protected _playing

_playing: boolean = false

Protected _pointer

_pointer: Pt = new Pt()

Private _refresh

_refresh: boolean = undefined

Private _renderFunc

_renderFunc: function

Type declaration

    • (context: any, self: Space): null
    • Parameters

      • context: any
      • self: Space

      Returns null

Protected bound

bound: Bound = new Bound()

id

id: string = "space"

Protected playerCount

playerCount: number = 0

Protected players

players: ISpacePlayers

Accessors

center

  • get center(): Pt
  • Get the size of this bounding box as a Pt

    Returns Pt

customRendering

  • get customRendering(): function
  • set customRendering(f: function): void
  • Set a custom rendering function(graphics_context, canvas_space) if needed

    Returns function

      • (context: any, self: Space): null
      • Parameters

        • context: any
        • self: Space

        Returns null

  • Set a custom rendering function(graphics_context, canvas_space) if needed

    Parameters

    • f: function
        • (context: any, self: Space): null
        • Parameters

          • context: any
          • self: Space

          Returns null

    Returns void

height

  • get height(): number
  • Get height of canvas

    Returns number

innerBound

  • get innerBound(): Bound

isPlaying

  • get isPlaying(): boolean
  • Get a boolean to indicate whether the animation is playing

    Returns boolean

outerBound

  • get outerBound(): Bound

size

  • get size(): Pt
  • Get the size of this bounding box as a Pt

    Returns Pt

width

  • get width(): number
  • Get width of canvas

    Returns number

Methods

add

  • Add an IPlayer to this space. An IPlayer can define the following callback functions:

    • animate( time, ftime, space )
    • start(bound, space)
    • resize( size, event )
    • action( type, x, y, event ) Subclasses of Space may define other callback functions.

    Parameters

    Returns this

clear

  • clear(): this
  • clear all contents in the space

    Returns this

getForm

  • Get a default form for drawing in this space

    Returns Form

pause

  • pause(toggle?: boolean): this
  • Pause the animation

    Parameters

    • Default value toggle: boolean = false

      a boolean value to set if this function call should be a toggle (between pause and resume)

    Returns this

play

  • play(time?: number): this
  • Main play loop. This implements window.requestAnimationFrame and calls it recursively. Override this play() function to implemenet your own animation loop.

    Parameters

    • Default value time: number = 0

      current time

    Returns this

Protected playItems

  • playItems(time: number): void
  • Main animate function. This calls all the items to perform

    Parameters

    • time: number

      current time

    Returns void

playOnce

  • playOnce(duration?: number): this
  • Play animation loop, and then stop after duration time has passed.

    Parameters

    • Default value duration: number = 5000

      a value in millisecond to specify a time period to play before stopping, or -1 to play forever

    Returns this

refresh

  • refresh(b: boolean): this
  • Set whether the rendering should be repainted on each frame

    Parameters

    • b: boolean

      a boolean value to set whether to repaint each frame

    Returns this

remove

  • Remove a player from this Space

    Parameters

    • player: IPlayer

      an IPlayer that has an animateID property

    Returns this

removeAll

  • removeAll(): this
  • Remove all players from this Space

    Returns this

Protected render

  • render(context: any): this
  • Custom rendering

    Parameters

    • context: any

      rendering context

    Returns this

replay

  • replay(): void
  • Replay the animation after stop(). This resets the end-time counter. You may also use pause() and resume() for temporary pause.

    Returns void

resize

  • resize(b: IPt, evt?: Event): this
  • Resize the space

    Parameters

    • b: IPt
    • Optional evt: Event

    Returns this

resume

  • resume(): this
  • Resume the pause animation

    Returns this

stop

  • stop(t?: number): this
  • Specify when the animation should stop: immediately, after a time period, or never stops.

    Parameters

    • Default value t: number = 0

      a value in millisecond to specify a time period to play before stopping, or -1 to play forever, or 0 to end immediately. Default is 0 which will stop the animation immediately.

    Returns this

Object literals

Protected _time

_time: object

diff

diff: number = 0

end

end: number = -1

prev

prev: number = 0

Generated using TypeDoc