API Docs for: 6.0.1
Show:

window.scrawl_Physics Class

window.scrawl

scrawlPhysics extension adaptions to the scrawl-canvas library object

New library sections

  • scrawl.force - for Force objects
  • scrawl.spring - for Spring objects
  • scrawl.physics - an area for storing physics constants and variables that affect multiple particles

Particle objects are treated like entitys, and stored in the scrawl.entity section of the library

Methods

makeForce

(
  • items
)

A factory function to generate new Force objects

Parameters:

  • items Object

    Key:value Object argument for setting attributes

Returns:

Force object

makeParticle

(
  • items
)

A factory function to generate new Particle objects

Parameters:

  • items Object

    Key:value Object argument for setting attributes

Returns:

Particle object

makeSpring

(
  • items
)

A factory function to generate new Spring objects

Parameters:

  • items Object

    Key:value Object argument for setting attributes

Returns:

Spring object

newForce

() deprecated

Alias for makeForce()

newParticle

() deprecated

Alias for makeParticle()

newSpring

() deprecated

Alias for makeSpring()

physicsInit

()

scrawl.init hook function - modified by physics module

Initiates two forces:

  • force.gravity() - gravity force at sea level
  • force.drag() - air drag force at sea level

updateDeltaTime

(
  • [item]
)

A general function to update Physics elapsed deltaTime

Parameters:

  • [item] Number optional

    new time

Returns:

True on success; false otherwise

updateSprings

(
  • [items]
)

A general function to undertake a round of calculations for Spring objects

Parameters:

  • [items] Array optional

    Array of SPRINGNAMES; defaults to all Spring objects

Returns:

True on success; false otherwise

Properties

physics

Object

An Object containing parameter:value pairs representing the physical parameters within which a physics model operates

physics.airDensity

Number

Air density, measured in kilograms per cubic meter; default is air density at seal level

Default: 1.23

physics.deltaTime

Number

Change in time since last update, measured in seconds

Default: 0

physics.gravity

Number

Gravity - positive values are assumed to act downwards from the top of the <canvas> element. Measured in meters per second squared

Default: 9.8

scrawl.work.workphys

Object private

Object containing a set of vectors, for physics calculations