Rebol Programming/within?

From Wikibooks, open books for an open world
Jump to navigation Jump to search

USAGE:[edit | edit source]

WITHIN? point offset size 

DESCRIPTION:[edit | edit source]

Return TRUE if the point is within the rectangle bounds.

WITHIN? is a function value.

ARGUMENTS[edit | edit source]

  • point -- XY position (Type: pair)
  • offset -- Offset of area (Type: pair)
  • size -- Size of area (Type: pair)

SOURCE CODE[edit | edit source]

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)
    ]
]