mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Add smoothPixelArt config option.
This commit is contained in:
parent
66bbf8ea4a
commit
78b4efbf11
4 changed files with 50 additions and 0 deletions
|
@ -417,6 +417,18 @@ var Config = new Class({
|
|||
this.roundPixels = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @const {boolean} Phaser.Core.Config#smoothPixelArt - WebGL only. Sets `antialias` to true and `pixelArt` to false. Texture-based Game Objects use special shader setting that preserve blocky pixels, but smooth the edges between the pixels. This is only visible when objects are scaled up; otherwise, `antialias` is simpler.
|
||||
*/
|
||||
this.smoothPixelArt = GetValue(renderConfig, 'smoothPixelArt', false, config);
|
||||
|
||||
if (this.smoothPixelArt)
|
||||
{
|
||||
this.antialias = true;
|
||||
this.antialiasGL = true;
|
||||
this.pixelArt = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @const {boolean} Phaser.Core.Config#transparent - Whether the game canvas will have a transparent background.
|
||||
*/
|
||||
|
|
|
@ -37,7 +37,10 @@
|
|||
* @property {boolean} [antialiasGL=true] - Sets the `antialias` property when the WebGL context is created. Setting this value does not impact any subsequent textures that are created, or the canvas style attributes.
|
||||
* @property {boolean} [desynchronized=false] - When set to `true` it will create a desynchronized context for both 2D and WebGL. See https://developers.google.com/web/updates/2019/05/desynchronized for details.
|
||||
* @property {boolean} [pixelArt=false] - Sets `antialias` to false and `roundPixels` to true. This is the best setting for pixel-art games.
|
||||
* @property {boolean} [smoothPixelArt=false] - WebGL only. Sets `antialias` to true and `pixelArt` to false. Texture-based Game Objects use special shader setting that preserve blocky pixels, but smooth the edges between the pixels. This is only visible when objects are scaled up; otherwise, `antialias` is simpler.
|
||||
* @property {boolean} [roundPixels=false] - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.
|
||||
* @property {boolean} [selfShadow=false] - On textured objects with lighting, this enables self-shadowing based on the diffuse map.
|
||||
* @property {number} [pathDetailThreshold=1] - Threshold for combining points into a single path in the WebGL renderer for Graphics objects. This can be overridden at the Graphics object level.
|
||||
* @property {boolean} [transparent=false] - Whether the game canvas will be transparent. Boolean that indicates if the canvas contains an alpha channel. If set to false, the browser now knows that the backdrop is always opaque, which can speed up drawing of transparent content and images.
|
||||
* @property {boolean} [clearBeforeRender=true] - Whether the game canvas will be cleared between each rendering frame.
|
||||
* @property {boolean} [preserveDrawingBuffer=false] - If the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
* @property {boolean} [antialiasGL=true] - Sets the `antialias` property when the WebGL context is created. Setting this value does not impact any subsequent textures that are created, or the canvas style attributes.
|
||||
* @property {boolean} [desynchronized=false] - When set to `true` it will create a desynchronized context for both 2D and WebGL. See https://developers.google.com/web/updates/2019/05/desynchronized for details.
|
||||
* @property {boolean} [pixelArt=false] - Sets `antialias` to false and `roundPixels` to true. This is the best setting for pixel-art games.
|
||||
* @property {boolean} [smoothPixelArt=false] - WebGL only. Sets `antialias` to true and `pixelArt` to false. Texture-based Game Objects use special shader setting that preserve blocky pixels, but smooth the edges between the pixels. This is only visible when objects are scaled up; otherwise, `antialias` is simpler.
|
||||
* @property {boolean} [roundPixels=true] - Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.
|
||||
* @property {boolean} [selfShadow=false] - On textured objects with lighting, this enables self-shadowing based on the diffuse map.
|
||||
* @property {number} [pathDetailThreshold=1] - Threshold for combining points into a single path in the WebGL renderer for Graphics objects. This can be overridden at the Graphics object level.
|
||||
|
|
|
@ -126,6 +126,19 @@ var Texture = new Class({
|
|||
*/
|
||||
this.frameTotal = 0;
|
||||
|
||||
/**
|
||||
* Whether shaders using this texture should use special filtering code.
|
||||
* This relies on shader support.
|
||||
*
|
||||
* If `null`, the game default will be used.
|
||||
*
|
||||
* @name Phaser.Textures.Texture#smoothPixelArt
|
||||
* @type {?boolean}
|
||||
* @default null
|
||||
* @since 3.90.0
|
||||
*/
|
||||
this.smoothPixelArt = null;
|
||||
|
||||
// Load the Sources
|
||||
for (var i = 0; i < source.length; i++)
|
||||
{
|
||||
|
@ -526,6 +539,27 @@ var Texture = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the `smoothPixelArt` property for this Texture.
|
||||
* If `true`, it will also run `setFilter(Phaser.Textures.FilterMode.LINEAR)`
|
||||
* to enable the necessary linear filtering.
|
||||
* If `false`, it will not change the filter mode, as it doesn't know
|
||||
* the previous state, nor is it necessary to change it.
|
||||
*
|
||||
* @method Phaser.Textures.Texture#setSmoothPixelArt
|
||||
* @since 3.90.0
|
||||
* @param {boolean|null} value - The value of the smoothPixelArt property.
|
||||
*/
|
||||
setSmoothPixelArt: function (value)
|
||||
{
|
||||
this.smoothPixelArt = value;
|
||||
|
||||
if (value)
|
||||
{
|
||||
this.setFilter(Phaser.Textures.FilterMode.LINEAR);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys this Texture and releases references to its sources and frames.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue