home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kyūkyoku!! X68000 Emulator
/
X68000Book.dat
/
mac
/
OLS
/
X68000
/
Ko-Window
/
kow142s.lzh
/
wsrv
/
clip.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-22
|
1KB
|
70 lines
#include <stdio.h>
#define CLIP
#include "clip.h"
#define min( a, b ) (a) < (b) ? (a) : (b)
#define max( a, b ) (a) > (b) ? (a) : (b)
void ClipSet( cp, x, y, h, v )
ClipClass *cp ;
int x, y, h, v ;
{
cp->clip.x1 = x ;
cp->clip.y1 = y ;
cp->clip.x2 = x + h - 1 ;
cp->clip.y2 = y + v - 1 ;
}
void ClipMove( cp, x, y )
ClipClass *cp ;
int x, y ;
{
x -= cp->clip.x1 ;
y -= cp->clip.y1 ;
cp->clip.x1 += x ;
cp->clip.y1 += y ;
cp->clip.x2 += x ;
cp->clip.y2 += y ;
}
int ClipInner( cp, x, y )
ClipClass *cp ;
int x, y ;
{
return( cp->clip.x1 <= x && x <= cp->clip.x2 && cp->clip.y1 <= y && y <= cp->clip.y2 );
}
void ClipGetSize( cp, xp, yp )
ClipClass *cp ;
int *xp, *yp ;
{
*xp = cp->clip.x2 - cp->clip.x1 + 1 ;
*yp = cp->clip.y2 - cp->clip.y1 + 1 ;
}
int ClipOverlap( ret, v1, v2 )
ClipClass *ret, *v1, *v2 ;
{
ret->clip.x1 = max( v1->clip.x1, v2->clip.x1 );
ret->clip.y1 = max( v1->clip.y1, v2->clip.y1 );
ret->clip.x2 = min( v1->clip.x2, v2->clip.x2 );
ret->clip.y2 = min( v1->clip.y2, v2->clip.y2 );
/* ârâàü[â|ü[âgé¬Ådé╚éτé╚éóé╞é½ */
if ( ret->clip.x1 > ret->clip.x2 || ret->clip.y1 > ret->clip.y2 )
return( FALSE );
return( TRUE );
}
int ClipSetDraw( buf, clip, code, option )
DrawBuf *buf ;
ClipClass *clip ;
int code, option ;
{
DrawSetLine( buf, clip->clip.x1, clip->clip.y1, clip->clip.x2, clip->clip.y2, code, option );
return( 1 );
}