Class: CameraState

model/CameraState.CameraState(obj)

Camera state.

This class models the state of a camera in the context of a Sozi document. It is attached to a given SVG document and contains the properties that need to be stored in the Sozi presentation file.

Constructor

new CameraState(obj)

Initialize a new camera state object.

If the argument is a camera state, this constructor will create a copy of of that state. If the argument is an SVG root element, a camera state with default properties will be created.

Parameters:
Name Type Description
obj CameraState | SVGSVGElement

A camera state to copy, or an SVG root element.

Source:
See:
  • Camera for a camera implementation in the context of the Sozi player.

Members

angle :number

The rotation angle applied to the camera, in degrees.

The angle is automatically normalized in the interval [-180 ; 180].

Type:
  • number
Default Value:
  • 0
Source:

clipHeightFactor :number

The height of the clipping rectangle with respect to the height of the image seen by the camera.

Type:
  • number
Default Value:
  • 1
Source:

clipped :boolean

Indicates that the content outside a specified rectangle must be clipped.

Type:
  • boolean
Source:

clipWidthFactor :number

The width of the clipping rectangle with respect to the width of the image seen by the camera.

Type:
  • number
Default Value:
  • 1
Source:

clipXOffset :number

The horizontal offset of the clipping rectangle with respect to the current camera location.

Type:
  • number
Source:

clipYOffset :number

The vertical offset of the clipping rectangle with respect to the current camera location.

Type:
  • number
Source:

cx :number

The horizontal coordinate of the camera.

This is also the horizontal coordinate of the center of the image seen by the camera.

Type:
  • number
Default Value:
  • The center of the bounding box of the SVG content.
Source:

cy :number

The vertical coordinate of the camera.

This is also the vertical coordinate of the center of the image seen by the camera.

Type:
  • number
Default Value:
  • The center of the bounding box of the SVG content.
Source:

height :number

The height of the image seen by the camera.

Cannot be lower than 1.

Type:
  • number
Default Value:
  • The height of the bounding box of the SVG content.
Source:

opacity :number

The opacity level of the layer attached to this camera.

A floating-point number between 0 and 1.

Type:
  • number
Default Value:
  • 1
Source:

svgRoot :SVGSVGElement

The root SVG element attached to this camera.

Type:
  • SVGSVGElement
Source:

width :number

The width of the image seen by the camera.

Cannot be lower than 1.

Type:
  • number
Default Value:
  • The width of the bounding box of the SVG content.
Source:

Methods

applyOffset(arg)

Apply a transformation to the current camera state.

This method accepts an object with the same type as the result of offsetFromElement.

Parameters:
Name Type Description
arg object

A transformation object to apply.

Properties
Name Type Description
deltaX number

An horizontal offset from the center of the SVG element.

deltaY number

A vertical offset from the center of the SVG element.

widthFactor number

A scaling factor applied to the width of the SVG element.

heightFactor number

A scaling factor applied to the height of the SVG element.

deltaAngle number

A relative angle from the orientation of the SVG element.

Source:
See:

copy(state)

Copy another camera state into the current instance.

Parameters:
Name Type Description
state module:model/CameraState.CameraState

The camera state to copy.

Source:

fromStorable(storable)

Copy the properties of the given object into this instance.

Parameters:
Name Type Description
storable object

A plain object with the properties to copy.

Source:

offsetFromElement(svgElement) → {object}

Compute a transformation from the bounding box of an SVG element to the current camera state.

The result has the same type as the argument of applyOffset.

Parameters:
Name Type Description
svgElement SVGElement

A source SVG element.

Source:
See:
Returns:
  • The translation coordinates, scaling factors, and rotation angle.
Type
object

resetClipping()

Set the clipping properties to their default values.

This method will fit the clipping rectangle to the image seen by the camera.

Source:

setAtElement(svgElement, deltaXopt, deltaYopt, widthFactoropt, heightFactoropt, deltaAngleopt)

Fit the current camera state to the given SVG element.

The default behavior is to fit the image seen by the camera to the bounding box of the SVG element. Translation, scaling and rotation may be applied.

Parameters:
Name Type Attributes Default Description
svgElement SVGElement

The target SVG element.

deltaX number <optional>
0

An horizontal offset from the center of the SVG element.

deltaY number <optional>
0

A vertical offset from the center of the SVG element.

widthFactor number <optional>
1

A scaling factor applied to the width of the SVG element.

heightFactor number <optional>
1

A scaling factor applied to the height of the SVG element.

deltaAngle number <optional>
0

A relative angle from the orientation of the SVG element.

Source:
See:

toMinimalStorable() → {object}

Convert this instance to a plain object that can be stored as JSON.

The result contains only the properties needed by the Sozi player to show and animate the presentation.

Source:
Returns:
  • A plain object with the properties needed by the player.
Type
object

toStorable() → {object}

Convert this instance to a plain object that can be stored as JSON.

The result contains all the properties needed by the editor to restore the state of this instance.

Source:
Returns:
  • A plain object with the properties needed by the editor.
Type
object