|
- int x1, y1, x2, y2;
- int dx, dy;
- int xinc, yinc;
-
- x1 = s->x1; y1 = s->y1; x2 = s->x2; y2 = s->y2;
-
- dx = abs(x2 - x1);
- dy = abs(y2 - y1);
-
- xinc = (x1 > x2) ? -1 : 1;
- yinc = (y1 > y2) ? -1 : 1;
-
- if(dx >= dy)
- {
- int dpr = dy << 1;
- int dpru = dpr - (dx << 1);
- int delta = dpr - dx;
-
- for(; dx>=0; dx--)
- {
- ASSIGN(x1, y1, img->w);
-
- if(delta > 0)
- {
- x1 += xinc;
- y1 += yinc;
- delta += dpru;
- }
- else
- {
- x1 += xinc;
- delta += dpr;
- }
- }
- }
- else
- {
- int dpr = dx << 1;
- int dpru = dpr - (dy << 1);
- int delta = dpr - dy;
-
- for(; dy >= 0; dy--)
- {
- ASSIGN(x1, y1, img->w);
- if(delta > 0)
- {
- x1 += xinc;
- y1 += yinc;
- delta += dpru;
- }
- else
- {
- y1 += yinc;
- delta += dpr;
- }
- }
- }
|