@@ -24,6 +24,11 @@
#include <stdlib.h>
#include <string.h>
#undef __USE_MISC /* THAT sucks */
#undef __USE_XOPEN /* THAT sucks, too (avoid declaring y1 in math.h) */
#include <math.h>
#include "pipi.h"
#include "pipi_internals.h"
@@ -268,10 +273,11 @@ static void draw_aliased_line_gray(pipi_image_t *img, struct line* s)
/* Xiaolin Wu's line algorithm, as seen at http://portal.acm.org/citation.cfm?id=122734 */
/* math.h doesn't like y0 (sucker) */
/* math.h doesn't like y1 (sucker) */
float floorf(float x);
float truncf(float x);
float fabsf(float x);
static float fractf(float d) { return (d - floorf(d)); }
static float fractinvf(float d) { return (1 - (d - floorf(d))); }
@@ -286,13 +292,13 @@ static void draw_antialiased_line_float(pipi_image_t *img, struct line* s)
s->buf_f[qwer] = (c*s->colorf[0]) + (1-c) * s->buf_f[qwer]; \
s->buf_f[qweg] = (c*s->colorf[1]) + (1-c) * s->buf_f[qweg]; \
s->buf_f[qweb] = (c*s->colorf[2]) + (1-c) * s->buf_f[qweb]; \
if(s->buf_f[qwer] > 0.8f) s->buf_f[qwer] = 0.8f; /* DEBUG LOL !*/ \
if(s->buf_f[qwer] < 0.2f) s->buf_f[qwer] = 0.2 f; \
if(s->buf_f[qweg] > 0.8f) s->buf_f[qweg] = 0.8 f; \
if(s->buf_f[qweg] < 0.2f) s->buf_f[qweg] = 0.2 f; \
if(s->buf_f[qweb] > 0.8f) s->buf_f[qweb] = 0.8 f; \
if(s->buf_f[qweb] < 0.2f) s->buf_f[qweb] = 0.2f; \
}
if(s->buf_f[qwer] > 1.0f) s->buf_f[qwer] = 1.0f; \
if(s->buf_f[qwer] < 0.0f || isnan(s->buf_f[qwer])) s->buf_f[qwer] = 0.0 f; \
if(s->buf_f[qweg] > 1.0f) s->buf_f[qweg] = 1.0 f; \
if(s->buf_f[qweg] < 0.0f || isnan(s->buf_f[qweg])) s->buf_f[qweg] = 0.0 f; \
if(s->buf_f[qweb] > 1.0f) s->buf_f[qweb] = 1.0 f; \
if(s->buf_f[qweb] < 0.0f || isnan(s->buf_f[qweb])) s->buf_f[qweb] = 0.0f; }
#include "aline_template.h"
}
@@ -301,6 +307,10 @@ static void draw_antialiased_line_gray(pipi_image_t *img, struct line* s)
{
#undef PLOT
#define PLOT(x, y, c) s->buf_f[((int)(x))+((int)(y))*img->w] = \
(c*s->colorf[0]) + (1-c) * s->buf_f[((int)(x))+((int)(y))*img->w];
(c*s->colorf[0]) + (1-c) * s->buf_f[((int)(x))+((int)(y))*img->w]; \
if(s->buf_f[((int)(x))+((int)(y))*img->w] > 1.0f) s->buf_f[((int)(x))+((int)(y))*img->w] = 1.0f; \
if(s->buf_f[((int)(x))+((int)(y))*img->w] < 0.0f) s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f; \
if(isnan(s->buf_f[((int)(x))+((int)(y))*img->w])) s->buf_f[((int)(x))+((int)(y))*img->w] = 0.0f;
#include "aline_template.h"
}