AppleScript名:指定矩形内に含まれるデータをリストで返す v3 |
— Created 2017-06-22 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set aList to {{507, 162}, {338, 166}, {389, 166}, {448, 166}, {286, 110}, {504, 109}, {558, 108}, {341, 113}, {394, 115}, {447, 112}, {234, 107}, {611, 110}, {286, 58}, {501, 63}, {556, 58}, {337, 59}, {391, 60}, {448, 63}, {611, 58}} set rangeList to {{500, 100}, {550, 180}} –{{x1,y1}, {x2,y2}} set resList to withinRange(rangeList, aList) of me –> {{507, 162}, {504, 109}} on withinRange(rangeList as list, targetList as list) set aRect to makeNSRect(rangeList) of me set includedList to {} repeat with i in targetList copy i to {x, y} set aPoint to current application’s NSMakePoint(x, y) set aRes to (current application’s NSPointInRect(aPoint, aRect)) as boolean if aRes = true then set the end of includedList to contents of i end if end repeat return includedList end withinRange on makeNSRect(aList as list) try copy aList to {{x1, y1}, {x2, y2}} set xWidth to (x2 – x1) set yHeight to (y2 – y1) set a1Rect to {origin:{x:x1, y:y1}, |size|:{width:xWidth, height:yHeight}} return a1Rect on error return missing value end try end makeNSRect |
More from my site
(Visited 21 times, 1 visits today)