跳轉到內容

Rebol 程式設計/within?

來自華夏公益教科書,開放的書籍,開放的世界
WITHIN? point offset size 

如果點在矩形邊界內,則返回 TRUE。

WITHIN? 是一個函式值。

  • -- XY 位置(型別:對)
  • 偏移 -- 區域偏移(型別:對)
  • 大小 -- 區域大小(型別:對)

原始碼

[編輯 | 編輯原始碼]
within?: func [
    {Return TRUE if the point is within the rectangle bounds.} 
    point [pair!] "XY position" 
    offset [pair!] "Offset of area" 
    size [pair!] "Size of area"
][
    found? all [
        point/x >= offset/x 
        point/y >= offset/y 
        point/x < (offset/x + size/x) 
        point/y < (offset/y + size/y)
    ]
]
華夏公益教科書