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

fix: specify units for scale math #11

Merged
merged 1 commit into from
Jan 6, 2020
Merged
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
9 changes: 5 additions & 4 deletions scripts/excessFunctions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,12 @@ function frame(leftPix, topPix, rightPix, bottomPix) {

// Get current size of art in layer
var myLayer = docRef.layers.getByName("Layer 1");
var imageHeight = myLayer.bounds[3] - myLayer.bounds[1];
var imageWidth = myLayer.bounds[2] - myLayer.bounds[0];

var imageHeight = myLayer.bounds[3].as("px") - myLayer.bounds[1].as("px");
var imageWidth = myLayer.bounds[2].as("px") - myLayer.bounds[0].as("px");
// Determine how much to scale the art by, such that it fits into the art window
var percentageToScale = artScaleFactor * (Math.max(windowWidth / imageWidth.as('px'), windowHeight / imageHeight.as('px')));
var percentageToScale = artScaleFactor * Math.max(windowWidth / imageWidth, windowHeight / imageHeight);

myLayer.resize(percentageToScale, percentageToScale, AnchorPosition.TOPLEFT);
myLayer.move(activeDocument, ElementPlacement.PLACEATEND);

Expand Down