pure-canvas
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -48,24 +48,28 @@ "use strict"; | ||
var _a = this.getBounds(), minX = _a.minX, minY = _a.minY, maxX = _a.maxX, maxY = _a.maxY; | ||
if (!this.cache) { | ||
this.cache = document.createElement('canvas'); | ||
this.cache.width = maxX - minX; | ||
this.cache.height = maxY - minY; | ||
var cacheContext_1 = this.cache.getContext('2d'); | ||
var cacheStepAccumulator = []; | ||
var cacheCommitAccumulator = []; | ||
_super.prototype.drawDeferred.call(this, cacheContext_1, cacheStepAccumulator, cacheCommitAccumulator); | ||
stepAccumulator.push(function () { return cacheContext_1.translate(-minX, -minY); }); | ||
for (var _i = 0, cacheStepAccumulator_1 = cacheStepAccumulator; _i < cacheStepAccumulator_1.length; _i++) { | ||
var cacheStep = cacheStepAccumulator_1[_i]; | ||
stepAccumulator.push(cacheStep); | ||
var width = maxX - minX; | ||
var height = maxY - minY; | ||
if (width > 0 && height > 0) { | ||
if (!this.cache) { | ||
this.cache = document.createElement('canvas'); | ||
this.cache.width = width; | ||
this.cache.height = height; | ||
var cacheContext_1 = this.cache.getContext('2d'); | ||
var cacheStepAccumulator = []; | ||
var cacheCommitAccumulator = []; | ||
_super.prototype.drawDeferred.call(this, cacheContext_1, cacheStepAccumulator, cacheCommitAccumulator); | ||
stepAccumulator.push(function () { return cacheContext_1.translate(-minX, -minY); }); | ||
for (var _i = 0, cacheStepAccumulator_1 = cacheStepAccumulator; _i < cacheStepAccumulator_1.length; _i++) { | ||
var cacheStep = cacheStepAccumulator_1[_i]; | ||
stepAccumulator.push(cacheStep); | ||
} | ||
for (var _b = 0, cacheCommitAccumulator_1 = cacheCommitAccumulator; _b < cacheCommitAccumulator_1.length; _b++) { | ||
var cacheCommit = cacheCommitAccumulator_1[_b]; | ||
stepAccumulator.push(cacheCommit); | ||
} | ||
stepAccumulator.push(function () { return cacheContext_1.translate(minX, minY); }); | ||
} | ||
for (var _b = 0, cacheCommitAccumulator_1 = cacheCommitAccumulator; _b < cacheCommitAccumulator_1.length; _b++) { | ||
var cacheCommit = cacheCommitAccumulator_1[_b]; | ||
stepAccumulator.push(cacheCommit); | ||
} | ||
stepAccumulator.push(function () { return cacheContext_1.translate(minX, minY); }); | ||
commitAccumulator.push(function () { | ||
context.drawImage(_this.cache, minX, minY, width, height); | ||
}); | ||
} | ||
commitAccumulator.push(function () { | ||
context.drawImage(_this.cache, minX, minY, maxX - minX, maxY - minY); | ||
}); | ||
}; | ||
@@ -72,0 +76,0 @@ return LayerCached; |
{ | ||
"name": "pure-canvas", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"description": "TODO", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -47,26 +47,30 @@ import {Bounds} from './Node'; | ||
const {minX, minY, maxX, maxY} = this.getBounds(); | ||
const width = maxX - minX; | ||
const height = maxY - minY; | ||
if (!this.cache) { | ||
this.cache = document.createElement('canvas'); | ||
this.cache.width = maxX - minX; | ||
this.cache.height = maxY - minY; | ||
const cacheContext = this.cache.getContext('2d'); | ||
const cacheStepAccumulator: Array<() => void> = []; | ||
const cacheCommitAccumulator: Array<() => void> = []; | ||
super.drawDeferred(cacheContext, cacheStepAccumulator, cacheCommitAccumulator); | ||
if (width > 0 && height > 0) { | ||
if (!this.cache) { | ||
this.cache = document.createElement('canvas'); | ||
this.cache.width = width; | ||
this.cache.height = height; | ||
const cacheContext = this.cache.getContext('2d'); | ||
const cacheStepAccumulator: Array<() => void> = []; | ||
const cacheCommitAccumulator: Array<() => void> = []; | ||
super.drawDeferred(cacheContext, cacheStepAccumulator, cacheCommitAccumulator); | ||
stepAccumulator.push(() => cacheContext.translate(-minX, -minY)); | ||
for (const cacheStep of cacheStepAccumulator) { | ||
stepAccumulator.push(cacheStep); | ||
stepAccumulator.push(() => cacheContext.translate(-minX, -minY)); | ||
for (const cacheStep of cacheStepAccumulator) { | ||
stepAccumulator.push(cacheStep); | ||
} | ||
for (const cacheCommit of cacheCommitAccumulator) { | ||
stepAccumulator.push(cacheCommit); | ||
} | ||
stepAccumulator.push(() => cacheContext.translate(minX, minY)); | ||
} | ||
for (const cacheCommit of cacheCommitAccumulator) { | ||
stepAccumulator.push(cacheCommit); | ||
} | ||
stepAccumulator.push(() => cacheContext.translate(minX, minY)); | ||
commitAccumulator.push(() => { | ||
context.drawImage(this.cache, minX, minY, width, height); | ||
}); | ||
} | ||
commitAccumulator.push(() => { | ||
context.drawImage(this.cache, minX, minY, maxX - minX, maxY - minY); | ||
}); | ||
} | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
199564
2488