# TextStim

## visual TextStim

TextStim handles text stimuli.

## Constructor

#### new TextStim(options)

Source:
  - visual/TextStim.js, line 24
Mixes In:
  - ColorMixin
To Do:
  - vertical alignment, and orientation are currently NOT implemented

##### Parameters:

Name | Type | Description
--- | --- | ---

`options`

Object

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`name` | String |  |  | the name used when logging messages from this stimulus
`win` | module:core.Window |  |  | the associated Window
`text` | string | <optional> | `"Hello World"` | the text to be rendered
`font` | string | <optional> | `"Arial"` | the font family
`pos` | Array.<number> | <optional> | `[0, 0]` | the position of the center of the text
`color` | Color | <optional> | `'white'` | the background color
`opacity` | number | <optional> | `1.0` | the opacity
`depth` | number | <optional> | `0` | the depth (i.e. the z order)
`contrast` | number | <optional> | `1.0` | the contrast
`units` | string | <optional> | `"norm"` | the units of the text size and position
`ori` | number |  |  | the orientation (in degrees)
`height` | number | <optional> | `0.1` | the height of the text
`bold` | boolean | <optional> | `false` | whether or not the text is bold
`italic` | boolean | <optional> | `false` | whether or not the text is italic
`alignHoriz` | string | <optional> | `'center'` | horizontal alignment
`alignVert` | string | <optional> | `'center'` | vertical alignment
`wrapWidth` | boolean |  |  | whether or not to wrap the text horizontally
`flipHoriz` | boolean | <optional> | `false` | whether or not to flip the text horizontally
`flipVert` | boolean | <optional> | `false` | whether or not to flip the text vertically
`clipMask` | PIXI.Graphics | <optional> | `null` | the clip mask
`autoDraw` | boolean | <optional> | `false` | whether or not the stimulus should be automatically drawn on every frame flip
`autoLog` | boolean | <optional> | `false` | whether or not to log

### Extends

- VisualStim

### Members

#### (protected, static, readonly) _defaultLetterHeightMap

Source:
  - visual/TextStim.js, line 485

This map associates units to default letter height.

#### (protected, static, readonly) _defaultWrapWidthMap

Source:
  - visual/TextStim.js, line 503

This map associates units to default wrap width.

### Methods

#### (protected) _estimateBoundingBox()

Source:
  - visual/TextStim.js, line 319

Estimate the bounding box.

#### (protected) _getAnchor() → {Array.<number>}

Source:
  - visual/TextStim.js, line 446

Convert the alignment attributes into an anchor.

##### Returns:

- the anchor

Type
  Array.<number>

#### (protected) _getDefaultLetterHeight()

Source:
  - visual/TextStim.js, line 212

Get the default letter height given the stimulus' units.

#### (protected) _getDefaultWrapWidth()

Source:
  - visual/TextStim.js, line 233

Get the default wrap width given the stimulus' units.

#### (protected) _getTextStyle()

Source:
  - visual/TextStim.js, line 347

Get the PIXI Text Style applied to the PIXI.Text

#### (protected) _updateIfNeeded()

Source:
  - visual/TextStim.js, line 386

Update the stimulus, if necessary.

#### (protected) getBoundingBox(tightopt) → {Array.<number>}

Source:
  - visual/TextStim.js, line 256

Get the bounding gox.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`tight` | boolean | <optional> | `false` | whether or not to fit as closely as possible to the text

##### Returns:

- the bounding box, in the units of this TextStim

Type
  Array.<number>

#### getTextMetrics()

Source:
  - visual/TextStim.js, line 184

Get the metrics estimated for the text and style.

Note: getTextMetrics does not require the PIXI representation of the stimulus to be instantiated, unlike getSize().

#### setColor(color, logopt)

Source:
  - visual/TextStim.js, line 367

Setter for the color attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`color` | undefined | null | number |  |  | the color
`log` | boolean | <optional> | `false` | whether of not to log