PointInBox
Result = PointInBox(PointX, PointY, X1, Y1, X2, Y2)
 
Parameters:

    PointX = X coordinate of the point
    PointY = Y coordinate of the point
    X1 = The top left hand X coordinate of the box
    Y1 = The top left hand Y coordinate of the box
    X2 = The bottom right hand X coordinate of the box
    Y2 = The bottom right hand Y coordinate of the box
Returns:

    Result
 

      PointInBox checks if a specified point is within the boundaries of a given box. The function returns 1 when the point is inside the box, otherwise it'll return 0.



FACTS:


      * PointInBox can be useful for any kind of user interfaces

      * You can perform more complex polygon collisions with the Shape command set, see Create Shape.



Mini Tutorial:


      Showing the use of MouseInBox

  
  
; Calculate Box position and dimension
  X1 = GetScreenWidth() / 2 - 20
  Y1 = GetScreenHeight() / 2 - 20
  X2 = X1 + 40
  Y2 = Y1 + 40
  
; White Color
  White = RGB(255,255,255)
  
; Red Colour
  Red = RGB(255,0,0)
  
  Repeat
     Cls RGB(0,0,0)
     
     
   ; Get the mouse pointers coordinates
     Mx=MouseX()
     My=MouseY()
     
   ; Check if mouse is in box
     If PointInBox(Mx,My,X1, Y1, X2, Y2)
      ; Draw a Box in red
        BoxC X1, Y1, X2, Y2, 1, Red
     Else
      ; Draw a Box in white
        BoxC X1, Y1, X2, Y2, 1, White
     EndIf
     Sync
  Until EscKey()
  
  


 
Related Info: CirclesIntersect | LineIntersectCircle | LineIntersectRect | LinesIntersect | MouseInBox | PointIntersectCircle :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com