vendredi 6 décembre 2019

Photoshop javascript resize reposition layer with fewer IF statements

I'm continuing to build and refine a script that looks at an active layer in Photoshop.

It takes its size and sees if it's larger or smaller than the document size. It then sees if the layer is off the canvas and moves/scales the layer accordingly.

For example, think of a square (white) that's inside (though it could be larger on all sides, or horizontally, or vertically) the canvas (magenta)

layer inside doc bounds

This white square could be hanging off the canvas to the left, right, top, bottom, top left, top right, bottom left, bottom right.

There are many variables once you start adding in that the square could be a rectangle and is larger than the doc width, or larger than the doc height.

I'm starting to accrue masses of IF statements.

I've read about Switch but am unsure how to begin with something like that. Is it possible to use Switch for something like this?

Any help would be much appreciated.

Aucun commentaire:

Enregistrer un commentaire