select bounding box utility functions

heal-brush
Abdullah Alfaraj 2023-02-19 08:51:34 +03:00
parent 7346e87c48
commit dfeb7e5738
1 changed files with 21 additions and 0 deletions

View File

@ -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,
}