•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileRC_INTERSECT(x1,y1,w1,h1,x2,y2,w2,h2)

x1, y1, w1, h1: iexp
x2, y2, w2, h2: ivar

The function RC_INTERSECT() (rectangle intersection) can be used to find
whether two rectangles overlap. The rectangles are specified by the coordinates
of the top left corner 'x,y', and the width 'w' and height 'h'.

If the rectangles overlap, then the logical value TRUE (-1) is returned and,
after the function call, x2, y2, w2, and h2 will contain the coordinates and
size of the rectangular area which is common to both rectangles.

If they do not overlap, FALSE (0) is returned and x2, y2, w2, and h2 will
contain the coordinates and size of a rectangle which lies between the two
specified rectangles. In this case, either the width 'w2' or the height 'h2',
or both, will be negative or zero.

This function is normally used for the control of 'Redraws' with GEM windows.

Examples:

    BOX 100,100,400,300
    x=200
    y=200
    w=300
    h=150
    BOX x,y,x+w,y+h
    '
    IF RC_INTERSECT(100,100,300,200,x,y,w,h)
      PBOX x,y,x+w,y+h
    ENDIF

--> Two rectangles are drawn and the common area is represented in black.

    oldmx=0
    oldmy=0
    DO
      MOUSE mx,my,mk
      IF mx<>oldmx OR my<>oldmy
        CLS
        oldmx=mx
        oldmy=my
        x=120
        y=100
        w=75
        h=75
        BOX x,y,x+w,y+h
        BOX mx,my,mx+50,my+50
        PRINT RC_INTERSECT(mx,my,50,50,x,y,w,h)
        PBOX x,y,x+w,y+h
      ENDIF
    LOOP

--> Two boxes are drawn on the screen, one which can be moved about with the
    mouse. The rectangle returned by the function RC_INTERSECT() is shown in
    black. The value -1 (TRUE), or 0 (FALSE) is shown in the top left corner of
    the screen, depending on whether or not the moving rectangle overlaps the
    fixed one.

Memo: For compiler options see section 'RC_INTERSECT() Parameters'.