2017-03-15 01:07:58 +00:00
|
|
|
var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camera)
|
|
|
|
{
|
|
|
|
if (this.renderMask !== this.renderFlags)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var ctx = renderer.currentContext;
|
|
|
|
|
|
|
|
// Blend Mode
|
|
|
|
if (renderer.currentBlendMode !== src.blendMode)
|
|
|
|
{
|
|
|
|
renderer.currentBlendMode = src.blendMode;
|
|
|
|
ctx.globalCompositeOperation = renderer.blendModes[src.blendMode];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Alpha
|
|
|
|
if (renderer.currentAlpha !== src.alpha)
|
|
|
|
{
|
|
|
|
renderer.currentAlpha = src.alpha;
|
|
|
|
ctx.globalAlpha = src.alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Smoothing
|
|
|
|
if (renderer.currentScaleMode !== src.scaleMode)
|
|
|
|
{
|
|
|
|
renderer.currentScaleMode = src.scaleMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
var canvas = src.canvas;
|
|
|
|
|
|
|
|
ctx.save();
|
2017-03-15 23:44:39 +00:00
|
|
|
ctx.translate(src.x - camera.scrollX, src.y - camera.scrollY);
|
2017-03-15 01:07:58 +00:00
|
|
|
ctx.rotate(src.rotation);
|
|
|
|
ctx.scale(src.scaleX, src.scaleY);
|
2017-03-20 23:37:17 +00:00
|
|
|
ctx.translate(canvas.width * (src.flipX ? 1 : 0), canvas.height * (src.flipY ? 1 : 0));
|
|
|
|
ctx.scale(src.flipX ? -1 : 1, src.flipY ? -1 : 1);
|
2017-03-15 23:44:39 +00:00
|
|
|
ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, -src.displayOriginX, -src.displayOriginY, canvas.width, canvas.height);
|
2017-03-15 01:07:58 +00:00
|
|
|
ctx.restore();
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = TextCanvasRenderer;
|