State

State class. Saves: data url/path, display info.

History:

  • v0.5 (dwv 0.30.0, 12/2021):
    • store position as array,
    • new draw position group key.
  • v0.4 (dwv 0.29.0, 06/2021):
    • move drawing details into meta property,
    • remove scale center and translation, add offset.
  • v0.3 (dwv v0.23.0, 03/2018):
    • new drawing structure, drawings are now the full layer object and using toObject to avoid saving a string representation,
    • new details structure: simple array of objects referenced by draw ids.
  • v0.2 (dwv v0.17.0, 12/2016):
    • adds draw details: array [nslices][nframes] of detail objects.
  • v0.1 (dwv v0.15.0, 07/2016):
    • adds version,
    • drawings: array [nslices][nframes] with all groups.
  • initial release (dwv v0.10.0, 05/2015), no version number:
    • content: window-center, window-width, position, scale, scaleCenter, translation, drawings,
    • drawings: array [nslices] with all groups.

Constructor

new State()

Methods

apply(app, data)

Load an application state from JSON.

Parameters:
NameTypeDescription
appApp

The app to apply the state to.

dataobject

The state data.

fromJSON(json) → {object}

Load an application state from JSON.

Parameters:
NameTypeDescription
jsonstring

The state as a JSON string.

Returns:

The state object.

Type: 
object

toJSON(app) → {string}

Save the application state as JSON.

Parameters:
NameTypeDescription
appApp

The associated application.

Returns:

The state as a JSON string.

Type: 
string