# VisualStim

## visual. VisualStim

Base class for all visual stimuli.

## Constructor

#### new VisualStim(options)

Source:
  - visual/VisualStim.js, line 22
Mixes In:
  - WindowMixin

##### 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
`units` | string | <optional> | `"height"` | the units of the stimulus (e.g. for size, position, vertices)
`ori` | number | <optional> | `0.0` | the orientation (in degrees)
`opacity` | number | <optional> | `1.0` | the opacity
`depth` | number | <optional> | `0` | the depth (i.e. the z order)
`pos` | Array.<number> | <optional> | `[0, 0]` | the position of the center of the stimulus
`size` | number | <optional> | `1.0` | the size
`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

- MinimalStim

### Methods

#### (protected) _estimateBoundingBox()

Source:
  - visual/VisualStim.js, line 219

Estimate the bounding box.

#### (protected) _getBoundingBox_px() → {PIXI.Rectangle}

Source:
  - visual/VisualStim.js, line 234

Get the bounding box in pixel coordinates

##### Returns:

the bounding box, in pixel coordinates

Type
  PIXI.Rectangle

#### (protected) _onChange(withPixiopt, withBoundingBoxopt) → {function}

Source:
  - visual/VisualStim.js, line 277

Generate a callback that prepares updates to the stimulus. This is typically called in the constructor of a stimulus, when attributes are added with _addAttribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`withPixi` | boolean | <optional> | `false` | whether or not the PIXI representation must also be updated
`withBoundingBox` | boolean | <optional> | `false` | whether or not to immediately estimate the bounding box

##### Returns:

Type
  function

#### (abstract, protected) _updateIfNeeded()

Source:
  - core/MinimalStim.js, line 181
Overrides:
  - MinimalStim#_updateIfNeeded

Update the stimulus, if necessary.

Note: this is an abstract function, which should not be called.

#### contains(object, units) → {boolean}

Source:
  - visual/VisualStim.js, line 196
Overrides:
  - MinimalStim#contains

Determine whether an object is inside the bounding box of the stimulus.

##### Parameters:

Name | Type | Description
--- | --- | ---
`object` | Object | the object
`units` | string | the units

##### Returns:

whether or not the object is inside the bounding box of the stimulus

Type
  boolean

#### draw()

Source:
  - core/MinimalStim.js, line 81
Overrides:
  - MinimalStim#draw

Draw this stimulus on the next frame draw.

#### hide()

Source:
  - core/MinimalStim.js, line 121
Overrides:
  - MinimalStim#hide

Hide this stimulus on the next frame draw.

#### refresh()

Source:
  - visual/VisualStim.js, line 98

Force a refresh of the stimulus.

refresh() is called, in particular, when the Window is resized.

#### release(logopt)

Source:
  - core/MinimalStim.js, line 161
Overrides:
  - MinimalStim#release

Release the PIXI representation, if there is one.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`log` | boolean | <optional> | `false` | whether to log

#### setAutoDraw(autoDraw, logopt)

Source:
  - core/MinimalStim.js, line 62
Overrides:
  - MinimalStim#setAutoDraw

Setter for the autoDraw attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`autoDraw` | boolean |  |  | the new value
`log` | boolean | <optional> | `false` | whether to log

#### setDepth(depth, logopt)

Source:
  - visual/VisualStim.js, line 182

Setter for the depth attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`depth` | Array.<number> |  | `0` | order in which stimuli is rendered, kind of css's z-index with a negative sign.
`log` | boolean | <optional> | `false` | whether of not to log

#### setOri(ori, logopt)

Source:
  - visual/VisualStim.js, line 135

Setter for the orientation attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`ori` | number |  |  | the orientation in degree with 0 as the vertical position, positive values rotate clockwise.
`log` | boolean | <optional> | `false` | whether of not to log

#### setPos(pos, logopt)

Source:
  - visual/VisualStim.js, line 161

Setter for the position attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`pos` | Array.<number> |  |  | position of the center of the stimulus, in stimulus units
`log` | boolean | <optional> | `false` | whether of not to log

#### setSize(size, logopt)

Source:
  - visual/VisualStim.js, line 109

Setter for the size attribute.

##### Parameters:

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