mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Merge pull request #61 from jonnysmith1981/master
Current canvas size now used when exporting
This commit is contained in:
commit
4044ab18f3
@ -7,8 +7,8 @@
|
|||||||
*/
|
*/
|
||||||
function mergeLayers(belowLayer, topLayer) {
|
function mergeLayers(belowLayer, topLayer) {
|
||||||
// Copying the above content on the layerBelow
|
// Copying the above content on the layerBelow
|
||||||
let belowImageData = belowLayer.getImageData(0, 0, canvas.width, canvas.height);
|
let belowImageData = belowLayer.getImageData(0, 0, belowLayer.canvas.width, belowLayer.canvas.height);
|
||||||
let toMergeImageData = topLayer.getImageData(0, 0, canvas.width, canvas.height);
|
let toMergeImageData = topLayer.getImageData(0, 0, topLayer.canvas.width, topLayer.canvas.height);
|
||||||
|
|
||||||
for (let i=0; i<belowImageData.data.length; i+=4) {
|
for (let i=0; i<belowImageData.data.length; i+=4) {
|
||||||
let currentMovePixel = [
|
let currentMovePixel = [
|
||||||
|
@ -6,9 +6,9 @@ function openPixelExportWindow() {
|
|||||||
|
|
||||||
if (selectedPalette != 'Choose a palette...'){
|
if (selectedPalette != 'Choose a palette...'){
|
||||||
var paletteAbbreviation = palettes[selectedPalette].name;
|
var paletteAbbreviation = palettes[selectedPalette].name;
|
||||||
var fileName = 'pixel-'+paletteAbbreviation+'-'+canvasSize[0]+'x'+canvasSize[1]+'.png';
|
var fileName = 'pixel-'+paletteAbbreviation+'-'+layers[0].canvasSize[0]+'x'+layers[0].canvasSize[1]+'.png';
|
||||||
} else {
|
} else {
|
||||||
var fileName = 'pixel-'+canvasSize[0]+'x'+canvasSize[1]+'.png';
|
var fileName = 'pixel-'+layers[0].canvasSize[0]+'x'+layers[0].canvasSize[1]+'.png';
|
||||||
selectedPalette = 'none';
|
selectedPalette = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,11 +33,11 @@ function exportPixel() {
|
|||||||
var emptyCanvas = document.createElement("canvas");
|
var emptyCanvas = document.createElement("canvas");
|
||||||
var layersCopy = layers.slice();
|
var layersCopy = layers.slice();
|
||||||
|
|
||||||
exportCanvas.width = canvasSize[0];
|
exportCanvas.width = layers[0].canvasSize[0];
|
||||||
exportCanvas.height = canvasSize[1];
|
exportCanvas.height = layers[0].canvasSize[1];
|
||||||
|
|
||||||
emptyCanvas.width = canvasSize[0];
|
emptyCanvas.width = layers[0].canvasSize[0];
|
||||||
emptyCanvas.height = canvasSize[1];
|
emptyCanvas.height = layers[0].canvasSize[1];
|
||||||
|
|
||||||
// Sorting the layers by z index
|
// Sorting the layers by z index
|
||||||
layersCopy.sort((a, b) => (a.canvas.style.zIndex > b.canvas.style.zIndex) ? 1 : -1);
|
layersCopy.sort((a, b) => (a.canvas.style.zIndex > b.canvas.style.zIndex) ? 1 : -1);
|
||||||
|
Loading…
Reference in New Issue
Block a user