Created
May 24, 2016 12:21
-
-
Save Scrxtchy/9df9c9ad16b1aace9a16702fc9b427c7 to your computer and use it in GitHub Desktop.
Photoshop region to percentageOfOne as float
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
str = activeDocument.selection.bounds.toString(); | |
str = str.replace(/ px/g,""); //" px"要らないので削除 | |
array = str.split(","); //","で分割 | |
var w = app.activeDocument.width.toString().replace(' px', ''); | |
var h = app.activeDocument.height.toString().replace(' px', ''); | |
str = parseFloat(array[0] /w) + "f," + // x | |
parseFloat(array[1] /h) + "f," + // y | |
parseFloat((Number(array[2]) ).toString() /w)+ "f," + //width | |
parseFloat((Number(array[3]) ).toString() /h)+ "f"; //height | |
//クリップボードに送る処理 | |
var txd=app.charIDToTypeID('TxtD'); | |
var kttc = app.stringIDToTypeID( "textToClipboard" ); | |
var ad = new ActionDescriptor(); | |
ad.putString(txd,str); | |
// http://crosseaglet.blogspot.com/2015/02/photoshoprect.html | |
executeAction( kttc, ad, DialogModes.NO ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment