/* Draw a one-pixel-wide line. */ int gz_draw_line_fixed(fixed ixf, fixed iyf, fixed itoxf, fixed itoyf, const gx_device_color *pdevc, gs_state *pgs) { int ix = fixed2int_var(ixf); int iy = fixed2int_var(iyf); int itox = fixed2int_var(itoxf); int itoy = fixed2int_var(itoyf); gx_device *dev; gp_check_interrupts(); if ( itoy == iy ) /* horizontal line */ { return (ix <= itox ? gz_fill_rectangle(ix, iy, itox - ix + 1, 1, pdevc, pgs) : gz_fill_rectangle(itox, iy, ix - itox + 1, 1, pdevc, pgs) ); } if ( itox == ix ) /* vertical line */ { return (iy <= itoy ? gz_fill_rectangle(ix, iy, 1, itoy - iy + 1, pdevc, pgs) : gz_fill_rectangle(ix, itoy, 1, iy - itoy + 1, pdevc, pgs) ); } if ( color_is_pure(pdevc) && (dev = pgs->device->info, (*dev->procs->draw_line)(dev, ix, iy, itox, itoy, pdevc->color1)) >= 0 ) return 0; { fixed h = itoyf - iyf; fixed w = itoxf - ixf; fixed tf; #define fswap(a, b) tf = a, a = b, b = tf if ( (w < 0 ? -w : w) <= (h < 0 ? -h : h) ) { if ( h < 0 ) fswap(ixf, itoxf), fswap(iyf, itoyf), h = -h; return gz_fill_trapezoid_fixed(ixf - fixed_half, fixed_1, iyf, itoxf - fixed_half, fixed_1, h, 0, pdevc, pgs); } else { if ( w < 0 ) fswap(ixf, itoxf), fswap(iyf, itoyf), w = -w; return gz_fill_trapezoid_fixed(iyf - fixed_half, fixed_1, ixf, itoyf - fixed_half, fixed_1, w, 1, pdevc, pgs); } #undef fswap } }
/* Draw a one-pixel-wide line. */ int gz_draw_line_fixed(fixed ixf, fixed iyf, fixed itoxf, fixed itoyf, gx_device_color *pdevc, gs_state *pgs) { int ix = fixed2int(ixf); int iy = fixed2int(iyf); int itox = fixed2int(itoxf); int itoy = fixed2int(itoyf); if ( itoy == iy ) /* horizontal line */ { if ( ix <= itox ) gz_fill_rectangle(ix, iy, fixed2int_ceiling(itoxf) - ix, 1, pdevc, pgs); else gz_fill_rectangle(itox, iy, fixed2int_ceiling(ixf) - itox, 1, pdevc, pgs); } else { gx_device *dev = pgs->device->info; fixed h, w, tf; #define fswap(a, b) tf = a, a = b, b = tf if ( color_is_pure(pdevc) && (*dev->procs->draw_line)(dev, ix, iy, itox, itoy, pdevc->color1) >= 0 ) return 0; h = itoyf - iyf; w = itoxf - ixf; #define fixed_eps (fixed)1 if ( (w < 0 ? -w : w) <= (h < 0 ? -h : h) ) { if ( h < 0 ) fswap(ixf, itoxf), fswap(iyf, itoyf), h = -h; gz_fill_trapezoid_fixed(ixf, fixed_eps, iyf, itoxf, fixed_eps, h, 0, pdevc, pgs); } else { if ( w < 0 ) fswap(ixf, itoxf), fswap(iyf, itoyf), w = -w; gz_fill_trapezoid_fixed(iyf, fixed_eps, ixf, itoyf, fixed_eps, w, 1, pdevc, pgs); } #undef fixed_eps #undef fswap } return 0; }