update tng

This commit is contained in:
Christopher Jeffrey 2015-06-29 02:58:06 -07:00
parent 64e1a730dc
commit 60c54590a1
1 changed files with 19 additions and 12 deletions

31
vendor/tng.js vendored
View File

@ -328,7 +328,7 @@ PNG.prototype.parseLines = function(data) {
PNG.prototype.unfilterLine = function(filter, line, prior) { PNG.prototype.unfilterLine = function(filter, line, prior) {
for (var x = 0; x < line.length; x++) { for (var x = 0; x < line.length; x++) {
if (filter === 0) { if (filter === 0) {
// line[x] = line[x]; break;
} else if (filter === 1) { } else if (filter === 1) {
line[x] = this.filters.sub(x, line, prior, this.bytesPerPixel); line[x] = this.filters.sub(x, line, prior, this.bytesPerPixel);
} else if (filter === 2) { } else if (filter === 2) {
@ -551,7 +551,8 @@ PNG.prototype.sampleInterlacedLines = function(raw) {
}; };
PNG.prototype.createBitmap = function(pixels) { PNG.prototype.createBitmap = function(pixels) {
var bmp = []; var bmp = []
, i;
if (this.colorType === 0) { if (this.colorType === 0) {
pixels = pixels.map(function(sample) { pixels = pixels.map(function(sample) {
@ -576,7 +577,7 @@ PNG.prototype.createBitmap = function(pixels) {
}); });
} }
for (var i = 0; i < pixels.length; i += this.width) { for (i = 0; i < pixels.length; i += this.width) {
bmp.push(pixels.slice(i, i + this.width)); bmp.push(pixels.slice(i, i + this.width));
} }
@ -672,8 +673,8 @@ PNG.prototype.renderScreen = function(bmp, screen, xi, xl, yi, yl) {
cellLines = bmp.reduce(function(cellLines, line, y) { cellLines = bmp.reduce(function(cellLines, line, y) {
var cellLine = []; var cellLine = [];
line.forEach(function(pixel, x) { line.forEach(function(pixel, x) {
var outch = self.getOutch(x, y, line, pixel); var outch = self.getOutch(x, y, line, pixel)
var cell = self.pixelToCell(pixel, outch); , cell = self.pixelToCell(pixel, outch);
cellLine.push(cell); cellLine.push(cell);
}); });
cellLines.push(cellLine); cellLines.push(cellLine);
@ -708,8 +709,10 @@ PNG.prototype.renderScreen = function(bmp, screen, xi, xl, yi, yl) {
}; };
PNG.prototype.renderElement = function(bmp, el) { PNG.prototype.renderElement = function(bmp, el) {
var xi = el.aleft + el.ileft, xl = el.aleft + el.width - el.iright var xi = el.aleft + el.ileft
, yi = el.atop + el.itop, yl = el.atop + el.height - el.ibottom; , xl = el.aleft + el.width - el.iright
, yi = el.atop + el.itop
, yl = el.atop + el.height - el.ibottom;
return this.renderScreen(bmp, el.screen, xi, xl, yi, yl); return this.renderScreen(bmp, el.screen, xi, xl, yi, yl);
}; };
@ -882,6 +885,7 @@ PNG.prototype.renderFrame = function(bmp, frame, i) {
, ops , ops
, x , x
, y , y
, line
, p; , p;
ops = (xo + yo + fc.blendOp) ops = (xo + yo + fc.blendOp)
@ -892,7 +896,7 @@ PNG.prototype.renderFrame = function(bmp, frame, i) {
if (!this._curBmp) { if (!this._curBmp) {
this._curBmp = []; this._curBmp = [];
for (y = 0; y < first.fctl.height; y++) { for (y = 0; y < first.fctl.height; y++) {
var line = []; line = [];
for (x = 0; x < first.fctl.width; x++) { for (x = 0; x < first.fctl.width; x++) {
p = bmp[y][x]; p = bmp[y][x];
line.push({ r: p.r, g: p.g, b: p.b, a: p.a }); line.push({ r: p.r, g: p.g, b: p.b, a: p.a });
@ -951,6 +955,7 @@ PNG.prototype._animate = function(callback) {
var next_lomem = function() { var next_lomem = function() {
if (!running) return; if (!running) return;
var frame = self.frames[++i]; var frame = self.frames[++i];
if (!frame) { if (!frame) {
if (!--numPlays) return callback(); if (!--numPlays) return callback();
@ -1027,7 +1032,9 @@ PNG.prototype.toPNG = function() {
, format = this.format , format = this.format
, buf , buf
, img , img
, gif; , gif
, i
, disposeOp;
if (format !== 'gif') { if (format !== 'gif') {
buf = exec('convert', buf = exec('convert',
@ -1044,11 +1051,11 @@ PNG.prototype.toPNG = function() {
this.height = gif.height; this.height = gif.height;
this.frames = []; this.frames = [];
for (var i = 0; i < gif.images.length; i++) { for (i = 0; i < gif.images.length; i++) {
var img = gif.images[i]; img = gif.images[i];
// Convert from gif disposal to png disposal. See: // Convert from gif disposal to png disposal. See:
// http://www.w3.org/Graphics/GIF/spec-gif89a.txt // http://www.w3.org/Graphics/GIF/spec-gif89a.txt
var disposeOp = Math.max(0, (gif.disposeMethod || 0) - 1); disposeOp = Math.max(0, (gif.disposeMethod || 0) - 1);
if (disposeOp > 2) disposeOp = 0; if (disposeOp > 2) disposeOp = 0;
this.frames.push({ this.frames.push({
fctl: { fctl: {