# Window

## core Window

Window displays the various stimuli of the experiment.

It sets up a `PIXI` renderer, which we use to render the experiment stimuli.

## Constructor

#### new Window(options)

Source:
  - core/Window.js, line 23

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`psychoJS` | module:core.PsychoJS |  |  | the PsychoJS instance
`name` | string | <optional> |  | the name of the window
`fullscr` | boolean | <optional> | `false` | whether or not to go fullscreen
`color` | Color | <optional> | `Color('black')` | the background color of the window
`gamma` | number | <optional> | `1` | sets the divisor for gamma correction. In other words gamma correction is calculated as pow(rgb, 1/gamma)
`contrast` | number | <optional> | `1` | sets the contrast value
`units` | string | <optional> | `'pix'` | the units of the window
`waitBlanking` | boolean | <optional> | `false` | whether or not to wait for all rendering operations to be done before flipping
`autoLog` | boolean | <optional> | `true` | whether or not to log

### Extends

- PsychObject

### Methods

#### (protected, static) _resizePixiRenderer(pjsWindow, event)

Source:
  - core/Window.js, line 490

Adjust the size of the renderer and the position of the root container in response to a change in the browser's size.

##### Parameters:

Name | Type | Description
--- | --- | ---
`pjsWindow` | module:core.Window | the PsychoJS Window
`event` |  |

#### (protected) _fullRefresh()

Source:
  - core/Window.js, line 396

Force an update of all stimuli in this window's drawlist.

#### (protected) _refresh()

Source:
  - core/Window.js, line 374

Recompute this window's draw list and _container children for the next animation frame.

#### (protected) _setupPixi()

Source:
  - core/Window.js, line 416

Setup PIXI.

A new renderer is created and a container is added to it. The renderer's touch and mouse events are handled by the `EventManager`.

#### (protected) _updateIfNeeded()

Source:
  - core/Window.js, line 351

Update this window, if need be.

#### (protected) _writeLogOnFlip()

Source:
  - core/Window.js, line 517

Send all logged messages to the `Logger`.

#### addPixiObject()

Source:
  - core/Window.js, line 291

Add PIXI.DisplayObject to the container displayed on the scene (window)

#### adjustScreenSize()

Source:
  - core/Window.js, line 175

Take the browser full screen if possible.

#### callOnFlip(flipCallback, …flipCallbackArgs)

Source:
  - core/Window.js, line 283

Add a callback function that will run after the next screen flip, i.e. immediately after the next rendering of the Window.

This is typically used to reset a timer or clock.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`flipCallback` | module:core.Window~OnFlipCallback |  | callback function.
`flipCallbackArgs` | * | <repeatable> | arguments for the callback function.

#### close()

Source:
  - core/Window.js, line 129

Close the window.

Note: this actually only removes the canvas used to render the experiment stimuli.

#### closeFullScreen()

Source:
  - core/Window.js, line 216

Take the browser back from full screen if needed.

#### getActualFrameRate() → {number}

Source:
  - core/Window.js, line 163

Estimate the frame rate.

##### Returns:

rAF based delta time based approximation, 60.0 by default

Type
  number

#### logOnFlip(options, levelopt, objopt)

Source:
  - core/Window.js, line 259

Log a message.

Note: the message will be time-stamped at the next call to requestAnimationFrame.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`options` | Object |  |  | ###### Properties
Name | Type | Description
--- | --- | ---
`msg` | String | the message to be logged
`level` | module:util.Logger.ServerLevel | <optional> | `module:util.Logger.ServerLevel.EXP` | the log level
`obj` | Object | <optional> |  | the object associated with the message

#### removePixiObject()

Source:
  - core/Window.js, line 299

Remove PIXI.DisplayObject from the container displayed on the scene (window)

#### render()

Source:
  - core/Window.js, line 307

Render the stimuli onto the canvas.