Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inline image option for PixiJS Movie export #861

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/js/controller/settings/exportimage/PngExportController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
var downloadPixiButton = document.querySelector('.png-pixi-download-button');
var dataUriButton = document.querySelector('.datauri-open-button');

this.pixiInlineImageCheckbox = document.querySelector('.png-pixi-inline-image-checkbox');

this.initLayoutSection_();
this.updateDimensionLabel_();

Expand Down Expand Up @@ -167,7 +169,15 @@
var canvas = this.createPngSpritesheet_();
var name = this.piskelController.getPiskel().getDescriptor().name;

zip.file(name + '.png', pskl.utils.CanvasUtils.getBase64FromCanvas(canvas) + '\n', {base64: true});
var image;

if (this.pixiInlineImageCheckbox.checked) {
image = canvas.toDataURL('image/png');
} else {
image = name + '.png';

zip.file(image, pskl.utils.CanvasUtils.getBase64FromCanvas(canvas) + '\n', {base64: true});
}

var width = canvas.width / this.getColumns_();
var height = canvas.height / this.getRows_();
Expand All @@ -192,7 +202,7 @@
'meta': {
'app': 'https://github.com/piskelapp/piskel/',
'version': '1.0',
'image': name + '.png',
'image': image,
'format': 'RGBA8888',
'size': {'w': canvas.width,'h': canvas.height}
}
Expand Down
4 changes: 4 additions & 0 deletions src/templates/settings/export/png.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<div style="padding-bottom: 5px">
<span class="highlight export-panel-row">Export for PixiJS Movie: </span>
</div>
<div class="checkbox-container" style="margin: 5px 0;">
<input id="png-pixi-inline-image" class="png-pixi-inline-image-checkbox checkbox-fix" type="checkbox" />
<label for="png-pixi-inline-image">Inline spritesheet as data-uri</label>
</div>
<div class="export-panel-row">
<button type="button" class="button button-primary png-pixi-download-button"/>Download</button>
<span class="png-export-dimension-info export-info">Spritesheet with JSON metadata</span>
Expand Down