Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @see PIXI.SCALE_MODES
*/
this.scaleMode = scaleMode !== undefined ? scaleMode : settings.SCALE_MODE;
/**
* Whether this object is the root element or not
*
* @member {boolean}
*/
this.root = root;
if (!this.root)
{
this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100);
if (this.scaleMode === SCALE_MODES.NEAREST)
{
this.frameBuffer.texture.enableNearestScaling();
}
else
{
this.frameBuffer.texture.enableLinearScaling();
}
/*
A frame buffer needs a target to render to..
create a texture and bind it attach it to the framebuffer..
*/
// this is used by the base texture
this.texture = this.frameBuffer.texture;
}
else
}
else if (texture.wrapMode === WRAP_MODES.REPEAT)
{
glTexture.enableWrapRepeat();
}
else
{
glTexture.enableWrapMirrorRepeat();
}
}
else
{
glTexture.enableWrapClamp();
}
if (texture.scaleMode === SCALE_MODES.NEAREST)
{
glTexture.enableNearestScaling();
}
else
{
glTexture.enableLinearScaling();
}
}
// the texture already exists so we only need to update it..
else if (isRenderTexture)
{
texture._glRenderTargets[this.renderer.CONTEXT_UID].resize(texture.width, texture.height);
}
else
{
glTexture.upload(texture.source);
*
* @member {HTMLCanvasElement} _canvas
* @private
*/
this._canvas = document.createElement('canvas');
this._canvas.width = 4;
this._canvas.height = this.sampleSize;
/**
* The displacement map is used to generate the bands.
* If using your own texture, `slices` will be ignored.
*
* @member {PIXI.Texture}
* @readonly
*/
this.texture = Texture.from(this._canvas, { scaleMode: SCALE_MODES.NEAREST });
/**
* Internal number of slices
* @member {number}
* @private
*/
this._slices = 0;
// Set slices
this.slices = options.slices;
}
set nearest(nearest) {
this._nearest = nearest;
this._scaleMode = nearest ? SCALE_MODES.NEAREST : SCALE_MODES.LINEAR;
const texture = this._colorMap;
if (texture && texture.baseTexture) {
texture.baseTexture._glTextures = {};
texture.baseTexture.scaleMode = this._scaleMode;
texture.baseTexture.mipmap = false;
texture._updateID++;
texture.baseTexture.emit('update', texture.baseTexture);
}
}
import { BaseTextureCache, EventEmitter, isPow2, TextureCache, uid } from '@pixi/utils';
import { FORMATS, SCALE_MODES, TARGETS, TYPES, ALPHA_MODES } from '@pixi/constants';
import { Resource } from './resources/Resource';
import { BufferResource } from './resources/BufferResource';
import { autoDetectResource } from './resources/autoDetectResource';
import { settings } from '@pixi/settings';
const defaultBufferOptions = {
scaleMode: SCALE_MODES.NEAREST,
format: FORMATS.RGBA,
alphaMode: ALPHA_MODES.NPM,
};
/**
* A Texture stores the information that represents an image.
* All textures have a base texture, which contains information about the source.
* Therefore you can have many textures all using a single BaseTexture
*
* @class
* @extends PIXI.utils.EventEmitter
* @memberof PIXI
* @param {PIXI.resources.Resource|string|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} [resource=null]
* The current resource to use, for things that aren't Resource objects, will be converted
* into a Resource.
* @param {Object} [options] - Collection of options