mirror of
https://github.com/psychopy/psychojs.git
synced 2025-05-10 10:40:54 +00:00
Fix blurry Pixi canvas
Add resolution: window.devicePixelRatio,
This commit is contained in:
parent
092829f325
commit
d4b52796c9
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Window responsible for displaying the experiment stimuli
|
* Window responsible for displaying the experiment stimuli
|
||||||
*
|
*
|
||||||
* @author Alain Pitiot
|
* @author Alain Pitiot
|
||||||
* @version 2020.1
|
* @version 2020.1
|
||||||
* @copyright (c) 2020 Ilixa Ltd. ({@link http://ilixa.com})
|
* @copyright (c) 2020 Ilixa Ltd. ({@link http://ilixa.com})
|
||||||
@ -15,7 +15,7 @@ import { Logger } from "./Logger";
|
|||||||
/**
|
/**
|
||||||
* <p>Window displays the various stimuli of the experiment.</p>
|
* <p>Window displays the various stimuli of the experiment.</p>
|
||||||
* <p>It sets up a [PIXI]{@link http://www.pixijs.com/} renderer, which we use to render the experiment stimuli.</p>
|
* <p>It sets up a [PIXI]{@link http://www.pixijs.com/} renderer, which we use to render the experiment stimuli.</p>
|
||||||
*
|
*
|
||||||
* @name module:core.Window
|
* @name module:core.Window
|
||||||
* @class
|
* @class
|
||||||
* @extends PsychObject
|
* @extends PsychObject
|
||||||
@ -33,7 +33,7 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for monitorFramePeriod.
|
* Getter for monitorFramePeriod.
|
||||||
*
|
*
|
||||||
* @name module:core.Window#monitorFramePeriod
|
* @name module:core.Window#monitorFramePeriod
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -95,9 +95,9 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the window.
|
* Close the window.
|
||||||
*
|
*
|
||||||
* <p> Note: this actually only removes the canvas used to render the experiment stimuli.</p>
|
* <p> Note: this actually only removes the canvas used to render the experiment stimuli.</p>
|
||||||
*
|
*
|
||||||
* @name module:core.Window#close
|
* @name module:core.Window#close
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -121,7 +121,7 @@ export class Window extends PsychObject {
|
|||||||
{
|
{
|
||||||
this._renderer.destroy();
|
this._renderer.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.removeEventListener('resize', this._resizeCallback);
|
window.removeEventListener('resize', this._resizeCallback);
|
||||||
window.removeEventListener('orientationchange', this._resizeCallback);
|
window.removeEventListener('orientationchange', this._resizeCallback);
|
||||||
|
|
||||||
@ -131,12 +131,12 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimate the frame rate.
|
* Estimate the frame rate.
|
||||||
*
|
*
|
||||||
* @name module:core.Window#getActualFrameRate
|
* @name module:core.Window#getActualFrameRate
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
* @return {number} always returns 60.0 at the moment
|
* @return {number} always returns 60.0 at the moment
|
||||||
*
|
*
|
||||||
* @todo estimate the actual frame rate.
|
* @todo estimate the actual frame rate.
|
||||||
*/
|
*/
|
||||||
getActualFrameRate()
|
getActualFrameRate()
|
||||||
@ -148,7 +148,7 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Take the browser full screen if possible.
|
* Take the browser full screen if possible.
|
||||||
*
|
*
|
||||||
* @name module:core.Window#adjustScreenSize
|
* @name module:core.Window#adjustScreenSize
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -227,9 +227,9 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message.
|
* Log a message.
|
||||||
*
|
*
|
||||||
* <p> Note: the message will be time-stamped at the next call to requestAnimationFrame.</p>
|
* <p> Note: the message will be time-stamped at the next call to requestAnimationFrame.</p>
|
||||||
*
|
*
|
||||||
* @name module:core.Window#logOnFlip
|
* @name module:core.Window#logOnFlip
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -256,9 +256,9 @@ export class Window extends PsychObject {
|
|||||||
/**
|
/**
|
||||||
* Add a callback function that will run after the next screen flip, i.e. immediately after the next rendering of the
|
* Add a callback function that will run after the next screen flip, i.e. immediately after the next rendering of the
|
||||||
* Window.
|
* Window.
|
||||||
*
|
*
|
||||||
* <p>This is typically used to reset a timer or clock.</p>
|
* <p>This is typically used to reset a timer or clock.</p>
|
||||||
*
|
*
|
||||||
* @name module:core.Window#callOnFlip
|
* @name module:core.Window#callOnFlip
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -273,7 +273,7 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the stimuli onto the canvas.
|
* Render the stimuli onto the canvas.
|
||||||
*
|
*
|
||||||
* @name module:core.Window#render
|
* @name module:core.Window#render
|
||||||
* @function
|
* @function
|
||||||
* @public
|
* @public
|
||||||
@ -315,7 +315,7 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update this window, if need be.
|
* Update this window, if need be.
|
||||||
*
|
*
|
||||||
* @name module:core.Window#_updateIfNeeded
|
* @name module:core.Window#_updateIfNeeded
|
||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
@ -337,7 +337,7 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Recompute this window's draw list and _container children for the next animation frame.
|
* Recompute this window's draw list and _container children for the next animation frame.
|
||||||
*
|
*
|
||||||
* @name module:core.Window#_refresh
|
* @name module:core.Window#_refresh
|
||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
@ -376,10 +376,10 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup PIXI.
|
* Setup PIXI.
|
||||||
*
|
*
|
||||||
* <p>A new renderer is created and a container is added to it. The renderer's touch and mouse events
|
* <p>A new renderer is created and a container is added to it. The renderer's touch and mouse events
|
||||||
* are handled by the {@link EventManager}.</p>
|
* are handled by the {@link EventManager}.</p>
|
||||||
*
|
*
|
||||||
* @name module:core.Window#_setupPixi
|
* @name module:core.Window#_setupPixi
|
||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
@ -392,7 +392,8 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
// create a PIXI renderer and add it to the document:
|
// create a PIXI renderer and add it to the document:
|
||||||
this._renderer = PIXI.autoDetectRenderer(this._size[0], this._size[1], {
|
this._renderer = PIXI.autoDetectRenderer(this._size[0], this._size[1], {
|
||||||
backgroundColor: this.color.int
|
backgroundColor: this.color.int,
|
||||||
|
resolution: window.devicePixelRatio,
|
||||||
});
|
});
|
||||||
this._renderer.view.style.transform = 'translatez(0)';
|
this._renderer.view.style.transform = 'translatez(0)';
|
||||||
this._renderer.view.style.position = 'absolute';
|
this._renderer.view.style.position = 'absolute';
|
||||||
@ -456,7 +457,7 @@ export class Window extends PsychObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Send all logged messages to the {@link Logger}.
|
* Send all logged messages to the {@link Logger}.
|
||||||
*
|
*
|
||||||
* @name module:core.Window#_writeLogOnFlip
|
* @name module:core.Window#_writeLogOnFlip
|
||||||
* @function
|
* @function
|
||||||
* @private
|
* @private
|
||||||
|
Loading…
Reference in New Issue
Block a user