src/video/SDL_rect.c
 changeset 2997 e4f025078c1c parent 2994 7563b99e9a49 child 3004 f3d7226a8dfd
```     1.1 --- a/src/video/SDL_rect.c	Sun Jan 04 23:36:53 2009 +0000
1.2 +++ b/src/video/SDL_rect.c	Sun Jan 04 23:41:09 2009 +0000
1.3 @@ -184,23 +184,22 @@
1.4          return SDL_TRUE;
1.5      }
1.6
1.7 -    else
1.8 -    {
1.9 -    /* The task of clipping a line with finite slope ratios in a fixed-
1.10 -     * precision coordinate space is not as immediately simple as it is
1.11 -     * with coordinates of arbitrary precision. If the ratio of slopes
1.12 -     * between the input line segment and the result line segment is not
1.13 -     * a whole number, you have in fact *moved* the line segment a bit,
1.14 -     * and there can be no avoiding it without more precision
1.15 -     */
1.16 -        int *x_result_[] = {X1, X2, NULL}, **x_result = x_result_;
1.17 -        int *y_result_[] = {Y1, Y2, NULL}, **y_result = y_result_;
1.18 +    else {
1.19 +        /* The task of clipping a line with finite slope ratios in a fixed-
1.20 +         * precision coordinate space is not as immediately simple as it is
1.21 +         * with coordinates of arbitrary precision. If the ratio of slopes
1.22 +         * between the input line segment and the result line segment is not
1.23 +         * a whole number, you have in fact *moved* the line segment a bit,
1.24 +         * and there can be no avoiding it without more precision
1.25 +         */
1.26 +        int *x_result_[] = { X1, X2, NULL }, **x_result = x_result_;
1.27 +        int *y_result_[] = { Y1, Y2, NULL }, **y_result = y_result_;
1.28          SDL_bool intersection = SDL_FALSE;
1.29          double b, m, left, right, bottom, top;
1.30          int xl, xh, yl, yh;
1.31
1.32          /* solve mx+b line formula */
1.33 -        m = (double)(y1-y2) / (double)(x1-x2);
1.34 +        m = (double) (y1 - y2) / (double) (x1 - x2);
1.35          b = y2 - m * (double) x2;
1.36
1.37          /* find some linear intersections */
1.38 @@ -232,8 +231,8 @@
1.39              x_result++;
1.40              y_result++;
1.41              intersection = SDL_TRUE;
1.42 -        } else /* it was determined earlier that *both* end-points are not contained */
1.43 -
1.44 +        } else
1.45 +            /* it was determined earlier that *both* end-points are not contained */
1.46          if (RISING(rectx1, x2, rectx2) && RISING(recty1, y2, recty2)) {
1.47              **(x_result++) = x2;
1.48              **(y_result++) = y2;
1.49 @@ -246,21 +245,24 @@
1.50              intersection = SDL_TRUE;
1.51          }
1.52
1.53 -        if (*x_result == NULL) return intersection;
1.54 +        if (*x_result == NULL)
1.55 +            return intersection;
1.56          if (RISING(recty1, right, recty2) && RISING(xl, rectx2, xh)) {
1.57              **(x_result++) = rectx2;
1.58              **(y_result++) = (int) right;
1.59              intersection = SDL_TRUE;
1.60          }
1.61
1.62 -        if (*x_result == NULL) return intersection;
1.63 +        if (*x_result == NULL)
1.64 +            return intersection;
1.65          if (RISING(rectx1, top, rectx2) && RISING(yl, recty1, yh)) {
1.66              **(x_result++) = (int) top;
1.67              **(y_result++) = recty1;
1.68              intersection = SDL_TRUE;
1.69          }
1.70
1.71 -        if (*x_result == NULL) return intersection;
1.72 +        if (*x_result == NULL)
1.73 +            return intersection;
1.74          if (RISING(rectx1, bottom, rectx2) && RISING(yl, recty2, yh)) {
1.75              **(x_result++) = (int) bottom;
1.76              **(y_result++) = recty2;
```