/***************************************************************************** Polyline clipping subroutine for CS480 Programming Assignment 2 ****************************************************************************** Author: ******************************************************************************/ #include #include #include #include #include "draw.h" /* Write a line clipping routine based on the parametric line clipping algorithm described in Section 3.9.4 in the text. */ /* Here's a version of the routine that just draws the line without doing the clipping. Modify it to clip the line segment to the clipping rectangle defined by (xmin,ymin) (xmax,ymax). */ clip2d(winid,x0,y0,x1,y1,xmin,ymin,xmax,ymax,color) int winid; /* window id */ float x0,y0,x1,y1; /* line segment end point coordinates */ float xmin,ymin,xmax,ymax; /* min/max of the clipping rectangle */ Colorindex color; /* color for the line (if drawn) */ { float p0[2],p1[2]; int visible = TRUE; if(visible) /* draw the line */ { p0[0] = x0; p0[1] = y0; p1[0] = x1; p1[1] = y1; draw_line(winid,p0,p1,color); } }