AppleScript名:矩形座標同士の衝突判定 v3 |
— Created 2017-03-06 by Takaaki Naganoya — 2017 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" set a1Rect to {origin:{x:10, y:10}, |size|:{width:100, height:100}} set b1Rect to {origin:{x:30, y:30}, |size|:{width:100, height:100}} set a1Res to detectRectanglesCollision(a1Rect, b1Rect) of me –> true set a4Rect to {origin:{x:0, y:20}, |size|:{width:100, height:10}} set b4Rect to {origin:{x:1000, y:10000}, |size|:{width:50, height:100}} set a2Res to detectRectanglesCollision(a4Rect, b4Rect) of me –> false set a3Rect to {origin:{x:30, y:30}, |size|:{width:50, height:50}} set b3Rect to {origin:{x:10, y:10}, |size|:{width:100, height:100}} set a3Res to detectRectanglesCollision(a3Rect, b3Rect) of me –> true set a4Rect to {origin:{x:0, y:20}, |size|:{width:100, height:10}} set b4Rect to {origin:{x:10, y:10}, |size|:{width:50, height:100}} set a4Res to detectRectanglesCollision(a4Rect, b4Rect) of me –> true –NSRect同士の衝突判定 on detectRectanglesCollision(aRect, bRect) set a1Res to current application’s NSIntersectionRect(aRect, bRect) return not (a1Res = {origin:{x:0.0, y:0.0}, |size|:{width:0.0, height:0.0}}) end detectRectanglesCollision |
More from my site
(Visited 123 times, 1 visits today)