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

Supported to export for transparent background. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 21 additions & 2 deletions Better Android Export/library/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,30 @@ com.animal = {
var path = [[[openDlg URLs] objectAtIndex:0] fileSystemRepresentation];

new AppSandbox().authorize(path, function() {
var copyLayer = [layer duplicate];

var exportSizes = [[copyLayer exportOptions] sizes];
while([exportSizes count] > 0)
[[exportSizes firstObject] remove];

var fileNames = [];
for (var f=0; f < factors.length; f++) {
var factor = factors[f];
slice = [MSExportRequest requestWithRect:rect scale:factor["scale"]];
[doc saveArtboardOrSlice:slice toFile:path + "/" + factor["name"] + "/" + [layer name] + ".png"];

var exportOption = [[copyLayer exportOptions] addExportSize];
[exportOption setFormat:"png"];
[exportOption setScale:factor["scale"]];
[exportOption setName:factor["name"]];

var fileName = path + "/" + factor["name"] + "/" + [layer name] + ".png";
fileNames.push(fileName);
}

var slices = [MSSliceMaker slicesFromExportableLayer:copyLayer inRect:[copyLayer absoluteDirtyRect]];
for (var i=0;i < [slices count]; i++)
[doc saveArtboardOrSlice:slices[i] toFile:fileNames[i]];

[copyLayer removeFromParent];
});

// Restore layers visibility
Expand Down