Class: TextSprite

PhotoEditorSDK.Operations~SpriteOperation~ TextSprite

A text that can be drawn by SpriteOperation. Should only be created via PhotoEditorSDK.Operations.SpriteOperation#createText

new TextSprite(operation, options)

sdk/operations/sprite-operation/sprites/text-sprite.js, line 44

Creates a new Text

Name Type Description
operation PhotoEditorSDK.Operations.SpriteOperation
options Object optional
Name Type Default Description
text String optional

The text that should be rendered

position PhotoEditorSDK.Math.Vector2 new Vector2(0.5, 0.5) optional

The position of the text. Both x and y components are relative to the respective image dimensions.

fontSize Number 0.1 optional

The font size, relative to the shorter side of the image.

lineHeight Number 1.1 optional

The line height, relative to the font size.

fontIdentifier String optional

Specifies the font that should be used.

alignment String 'center' optional

Specifies the horizontal text alignment of the text. Possible values are 'left', 'center' and 'right'.

color PhotoEditorSDK.Color Color.BLACK optional

The color of the text.

backgroundColor Color Color.TRANSPARENT optional

The background color of the text sprite.

rotation Number 0 optional

The rotation of the text in radians.

maxWidth Number 0.5 optional

The maximum width of the text, relative to the image width.



sdk/operations/sprite-operation/sprites/text-sprite.js, line 124

Applies a flip in the given direction

Name Type Description
direction String


sdk/operations/sprite-operation/sprites/text-sprite.js, line 156

Applies a rotation with the given degrees

Name Type Description
degrees Number


sdk/operations/sprite-operation/sprites/text-sprite.js, line 144

Applies a transform with the given options

Name Type Description
transformChange PhotoEditorSDK.Operations.TransformOperation.TransformChange


sdk/operations/sprite-operation/sprites/text-sprite.js, line 236

Cleans up this Sprite


sdk/operations/sprite-operation/sprites/text-sprite.js, line 94

Returns the absolute text height in pixels. The value is calculated using the current fonts metrics, the font size and the given input dimensions. If no font metrics are available, a fallback algorithm is used to determine the absolute text height.

Name Type Description
inputDimensions PhotoEditorSDK.Math.Vector2
Type Description
Float Absolute text height in pixels

getDimensions(sdk, inputDimensions){PhotoEditorSDK.Math.Vector2}

sdk/operations/sprite-operation/sprites/text-sprite.js, line 116

Returns the dimensions for this text

Name Type Description
sdk PhotoEditorSDK
inputDimensions PhotoEditorSDK.Math.Vector2
Type Description

getDOMStyle(SDK, inputDimensions){Object}

sdk/operations/sprite-operation/sprites/text-sprite.js, line 71

Returns a style object for this text

Name Type Description
SDK PhotoEditorSDK
inputDimensions PhotoEditorSDK.Math.Vector2
Type Description

serializeOptions(keys, toObject){Object}

sdk/operations/sprite-operation/sprites/text-sprite.js, line 59

Returns a serialized version of this configurable

Name Type Default Description
keys Array.<String>
toObject Boolean false

= false

Type Description

update(sdk, inputDimensions)

sdk/operations/sprite-operation/sprites/text-sprite.js, line 197

Updates this sprite

Name Type Description
sdk PhotoEditorSDK
inputDimensions PhotoEditorSDK.Math.Vector2