Skip to content
Snippets Groups Projects
Commit c4ab7934 authored by Mirar (Pontus Hagland)'s avatar Mirar (Pontus Hagland)
Browse files

no known bugs(\!)

Rev: src/modules/Image/polyfill.c:1.11
parent dc5084ab
No related branches found
No related tags found
No related merge requests found
#include "global.h" #include "global.h"
RCSID("$Id: polyfill.c,v 1.10 1997/10/27 22:41:28 mirar Exp $"); RCSID("$Id: polyfill.c,v 1.11 1997/11/05 03:29:17 mirar Exp $");
/* Prototypes are needed for these */ /* Prototypes are needed for these */
extern double floor(double); extern double floor(double);
...@@ -29,7 +29,7 @@ extern double floor(double); ...@@ -29,7 +29,7 @@ extern double floor(double);
/* /*
**! module Image **! module Image
**! note **! note
**! $Id: polyfill.c,v 1.10 1997/10/27 22:41:28 mirar Exp $ **! $Id: polyfill.c,v 1.11 1997/11/05 03:29:17 mirar Exp $
**! class image **! class image
*/ */
...@@ -302,9 +302,15 @@ static int polygone_row_vertices(float *buf, ...@@ -302,9 +302,15 @@ static int polygone_row_vertices(float *buf,
if (xmin!=xmax && v->xmin<xmax && v->xmax>xmin) if (xmin!=xmax && v->xmin<xmax && v->xmax>xmin)
{ {
#ifdef POLYDEBUG
#define CALC_AREA(FILL,X,Y1,Y2,YP) \
(fprintf(stderr," [area: %d*%g*%g y1=%g y2=%g yp=%g]\n", FILL,X,( 1-0.5*(Y1+Y2)+YP ),Y1,Y2,YP), \
((FILL)*(X)*( 1.0-0.5*((Y1)+(Y2))+(YP) )))
#else
#define CALC_AREA(FILL,X,Y1,Y2,YP) \ #define CALC_AREA(FILL,X,Y1,Y2,YP) \
((FILL)*(X)*( 1.0-0.5*((Y1)+(Y2))+(YP) )) ((FILL)*(X)*( 1.0-0.5*((Y1)+(Y2))+(YP) ))
/* (fprintf(stderr," [area: %d*%g*%g y1=%g y2=%g yp=%g]\n", FILL,X,( 1-0.5*(Y1+Y2)+YP ),Y1,Y2,YP), \*/ #endif
if (xmin_i == xmax_i) if (xmin_i == xmax_i)
...@@ -350,6 +356,41 @@ static int polygone_row_vertices(float *buf, ...@@ -350,6 +356,41 @@ static int polygone_row_vertices(float *buf,
return fill<0; return fill<0;
} }
static int toggle_fill(struct vertex_list *v1,
float xmin,float xmax,
float yp,int fill)
{
struct vertex_list *v;
v=v1;
#ifdef POLYDEBUG
fprintf(stderr,"try toggle %g..%g\n",xmin,xmax);
#endif
while (v)
{
if (v->above->y<yp-1e-10 &&
( (v->xmin==xmin && v->yxmin<=yp+1e-10)
|| (v->xmax==xmin && v->yxmax<=yp+1e-10)
|| (v->xmax==xmax && v->xmin<=xmin && v->yxmax<=yp+1e-10)))
{
fill=!fill;
#ifdef POLYDEBUG
fprintf(stderr," toggle fill %d=>%d on %g,%g-%g,%g\n",
!fill,fill,v->xmin,v->yxmin,v->xmax,v->yxmax);
#endif
}
#ifdef POLYDEBUG
else fprintf(stderr," dont toggle fill %d=>%d on %g,%g-%g,%g (%g<%g) (%d%d%d)\n",
fill,fill,v->xmin,v->yxmin,v->xmax,v->yxmax,
v->above->y,yp-1e-10,
v->xmax==xmax,v->yxmax==yp+1,v->above->y<yp-1e-10);
#endif
v=v->next;
}
return fill;
}
static void polygone_row(struct image *img, static void polygone_row(struct image *img,
float *buf, float *buf,
struct vertex_list *vertices, struct vertex_list *vertices,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment