blob: 93c11f0f0b12cf896d0835ac54d68bdb2981e711 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
include "../curses.h"
# PS_INTERSECT -- Intersection between two rectangles
#
# B.Simon 18-Jan-89 Original
bool procedure ps_intersect (source, maxrow, maxcol, dest)
int source[RSIZE] # i: Source rectangle
int maxrow # i: Max row of clipping rectangle
int maxcol # i: Max column of clipping rectangle
int dest[RSIZE] # o: Destination rectangle
#--
begin
# Clip source rectangle to (1,1) and (maxrow,maxcol)
RTOP(dest) = max (1, RTOP(source))
RLEFT(dest) = max (1, RLEFT(source))
RBOT(dest) = min (maxrow, RBOT(source))
RRIGHT(dest) = min (maxcol, RRIGHT(source))
# Return true if intersection is non-empty
return (RTOP(dest) <= RBOT(dest) && RLEFT(dest) <= RRIGHT(dest))
end
|