forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextureSource.js
More file actions
62 lines (42 loc) · 1.41 KB
/
Copy pathTextureSource.js
File metadata and controls
62 lines (42 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
var Class = require('../utils/Class');
var CONST = require('../const');
var IsSizePowerOfTwo = require('../math/pow2/IsSizePowerOfTwo');
var ScaleModes = require('../renderer/ScaleModes');
var TextureSource = new Class({
initialize:
function TextureSource (texture, source, width, height)
{
var game = texture.manager.game;
this.texture = texture;
this.image = source;
this.compressionAlgorithm = null;
this.resolution = 1;
this.width = width || source.naturalWidth || source.width || 0;
this.height = height || source.naturalHeight || source.height || 0;
this.scaleMode = ScaleModes.DEFAULT;
this.isCanvas = (source instanceof HTMLCanvasElement);
this.isPowerOf2 = IsSizePowerOfTwo(this.width, this.height);
this.init(game);
},
init: function (game)
{
this.glTexture = null;
if (game.config.renderType === CONST.WEBGL)
{
game.renderer.createTexture(this, this.width, this.height);
}
if (game.config.pixelArt)
{
this.setFilter(1);
}
},
setFilter: function (filterMode)
{
var game = this.texture.manager.game;
if (game.config.renderType === CONST.WEBGL)
{
game.renderer.setTextureFilterMode(this.glTexture, filterMode);
}
}
});
module.exports = TextureSource;