select bounding box utility functions
parent
7346e87c48
commit
dfeb7e5738
21
selection.js
21
selection.js
|
|
@ -50,6 +50,25 @@ async function selectionToFinalWidthHeight() {
|
|||
}
|
||||
}
|
||||
|
||||
async function selectBoundingBox() {
|
||||
let l = await app.activeDocument.activeLayers[0]
|
||||
let bounds = await l.boundsNoEffects
|
||||
let selectionInfo = convertSelectionObjectToSelectionInfo(bounds)
|
||||
await psapi.reSelectMarqueeExe(selectionInfo)
|
||||
return selectionInfo
|
||||
}
|
||||
function convertSelectionObjectToSelectionInfo(selection_obj) {
|
||||
let selection_info = {
|
||||
left: selection_obj._left,
|
||||
right: selection_obj._right,
|
||||
bottom: selection_obj._bottom,
|
||||
top: selection_obj._top,
|
||||
height: selection_obj._bottom - selection_obj._top,
|
||||
width: selection_obj._right - selection_obj._left,
|
||||
}
|
||||
return selection_info
|
||||
}
|
||||
|
||||
class Selection {
|
||||
static getSelectionInfo() {}
|
||||
static isValidSelection() {
|
||||
|
|
@ -63,5 +82,7 @@ class Selection {
|
|||
module.exports = {
|
||||
finalWidthHeight,
|
||||
selectionToFinalWidthHeight,
|
||||
selectBoundingBox,
|
||||
convertSelectionObjectToSelectionInfo,
|
||||
Selection,
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue