mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
Merge pull request #550 from david-szabo97/feature_export-selected-frame
Add misc export: download selected frame as png
This commit is contained in:
commit
8a031d771a
@ -12,6 +12,9 @@
|
|||||||
ns.MiscExportController.prototype.init = function () {
|
ns.MiscExportController.prototype.init = function () {
|
||||||
var cDownloadButton = document.querySelector('.c-download-button');
|
var cDownloadButton = document.querySelector('.c-download-button');
|
||||||
this.addEventListener(cDownloadButton, 'click', this.onDownloadCFileClick_);
|
this.addEventListener(cDownloadButton, 'click', this.onDownloadCFileClick_);
|
||||||
|
|
||||||
|
var selectedFrameDownloadButton = document.querySelector('.selected-frame-download-button');
|
||||||
|
this.addEventListener(selectedFrameDownloadButton, 'click', this.onDownloadSelectedFrameClick_);
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.MiscExportController.prototype.onDownloadCFileClick_ = function (evt) {
|
ns.MiscExportController.prototype.onDownloadCFileClick_ = function (evt) {
|
||||||
@ -73,4 +76,14 @@
|
|||||||
hexStr += ('00' + r.toString(16)).substr(-2);
|
hexStr += ('00' + r.toString(16)).substr(-2);
|
||||||
return hexStr;
|
return hexStr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ns.MiscExportController.prototype.onDownloadSelectedFrameClick_ = function (evt) {
|
||||||
|
var frameIndex = this.piskelController.getCurrentFrameIndex();
|
||||||
|
var fileName = this.getPiskelName_() + '-' + (frameIndex + 1) + '.png';
|
||||||
|
var canvas = this.piskelController.renderFrameAt(frameIndex, true);
|
||||||
|
|
||||||
|
pskl.utils.BlobUtils.canvasToBlob(canvas, function(blob) {
|
||||||
|
pskl.utils.FileUtils.downloadAsFile(blob, fileName);
|
||||||
|
});
|
||||||
|
};
|
||||||
})();
|
})();
|
||||||
|
@ -12,5 +12,14 @@
|
|||||||
</div>
|
</div>
|
||||||
<button type="button" class="button button-primary c-download-button">Download C file</button>
|
<button type="button" class="button button-primary c-download-button">Download C file</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="export-panel-section">
|
||||||
|
<div style="padding-bottom: 5px">
|
||||||
|
<span style="color: gold;">Export selected frame as PNG File: </span>
|
||||||
|
<span class="export-info">
|
||||||
|
PNG export of the currently selected frame.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="button button-primary selected-frame-download-button">Download</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue
Block a user