/* * libpipi Proper image processing implementation library * Copyright (c) 2004-2008 Sam Hocevar * 2008 Jean-Yves Lamoureux x1, y1 = s->y1, x2 = s->x2, y2 = s->y2; float g, xd, yd, xgap, xend, yend, xf, yf, val1, val2; int x, y, ix1, ix2, iy1, iy2; xd = x2 - x1; yd = y2 - y1; /* "Horizontal" line (X greater than Y)*/ if (fabsf(xd) > fabsf(yd)) { if (x1 > x2) { float tmp; tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; xd = (x2-x1); yd = (y2-y1); } g = yd/xd; xend = truncf(x1+0.5); yend = y1 + g*(xend-x1); xgap = fractinvf(x1+0.5); ix1 = (int)xend; iy1 = (int)yend; val1 = fractinvf(yend)*xgap; val2 = fractf(yend)*xgap; PLOT(ix1, iy1, val1); PLOT(ix1, (iy1+1) x2) { float tmp; tmp = x1; x1 = x2; x2 = tmp; tmp = y1; y1 = y2; y2 = tmp; xd = (x2-x1); yd = (y2-y1); } g = xd/yd; xend = truncf(x1+0.5); yend = y1 + g*(xend-x1); xgap = fractf(x1+0.5); ix1 = (int)xend; iy1 = (int)yend; val1 = fractinvf(yend)*xgap; val2 = fractf(yend)*xgap; PLOT(ix1, iy1, val1); PLOT(ix1, (iy1+1)