void PG_Draw::DrawLine(SDL_Surface* surface, Uint32 x0, Uint32 y0, Uint32 x1, Uint32 y1, const PG_Color& color, Uint8 width) { int deltax; int deltay; int temp; int pixelflag; if (!width || !surface) return; pixelflag=0; /* swap y0 with y1 if y0 is greater than y1 */ if (y0 > y1) { temp = y0; y0 = y1; y1 = temp; temp = x0; /* switch the xs */ x0 = x1; x1 = temp; } /* end of the if */ /* handle four separate cases */ deltax = x1 - x0; deltay = y1 - y0; if (deltax > 0) { if (deltax > deltay) { octant0(surface, x0, y0, deltax, deltay, 1, color, width, pixelflag); } /* end of if */ else { octant1(surface, x0, y0, deltax, deltay, 1, color, width, pixelflag); } /* end if else */ } /* end of the if */ else { deltax = -deltax; /* abs value of delta x */ if (deltax > deltay) { octant0(surface, x0, y0, deltax, deltay, -1, color, width, pixelflag); } /* end of the if */ else { /* not correct yet */ octant1(surface, x0, y0, deltax, deltay, -1, color, width, pixelflag); } /* end of if-else */ } /* end of if - else */ } /* end of the function */
void cad1(t_param *param, t_seg *seg) { if (seg->dy != 0) { if (seg->dy > 0) { if (seg->dx >= seg->dy) octant1(param, seg); else octant2(param, seg); } else { if (seg->dx >= -1 * seg->dy) octant8(param, seg); else octant7(param, seg); } } else seg_x1(param, seg); }