2D bitmap graphics library with emphasis on speed and correctness
No Matches
gp_line_clip.h File Reference

Line clipping algorithm. More...

Go to the source code of this file.


int gp_line_clip (int *px0, int *py0, int *px1, int *py1, int xmax, int ymax)
 Clips a line.

Detailed Description

Line clipping algorithm.

Definition in file gp_line_clip.h.

Function Documentation

◆ gp_line_clip()

int gp_line_clip ( int *  px0,
int *  py0,
int *  px1,
int *  py1,
int  xmax,
int  ymax 

Clips a line.

Clips a line so that the start and end points are within (0, xmax) and (0, ymax). This is used by the line drawing algorithms to make sure that the we only draw the part of line within pixmap.

px0A starting x coordinate to clip.
py0A starting y cooridinate to clip.
px1An ending x coordinate to clip.
py1An ending y coordinate to clip.
xmaxA x coordinate upper limit.
ymaxA y coordinate upper limit.
Zero if the line is completely outside of the pixmap, non-zero otherwise.