X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?p=xscreensaver;a=blobdiff_plain;f=utils%2Fcolors.c;h=e06359c72db811738959df9bc1f733e359485a4d;hp=2e10b55b428f478b425d3fa749ca82edc926a01e;hb=50be9bb40dc60130c99ffa568e6677779904ff70;hpb=5f1f12f2a37da634000f96d18d59cc73a8814ef7 diff --git a/utils/colors.c b/utils/colors.c index 2e10b55b..e06359c7 100644 --- a/utils/colors.c +++ b/utils/colors.c @@ -336,16 +336,11 @@ make_color_path (Display *dpy, Colormap cmap, k = 0; for (i = 0; i < npoints; i++) { - int distance, direction; - distance = h[(i+1) % npoints] - h[i]; - direction = (distance >= 0 ? -1 : 1); - - if (distance > 180) - distance = 180 - (distance - 180); - else if (distance < -180) - distance = -(180 - ((-distance) - 180)); - else - direction = -direction; + int distance = h[(i+1) % npoints] - h[i]; + int direction = (distance >= 0 ? -1 : 1); + + if (distance <= 180 && distance >= -180) + direction = -direction; #ifdef DEBUG fprintf (stderr, "point %d: %3d %.2f %.2f\n", @@ -541,7 +536,7 @@ make_smooth_colormap (Display *dpy, Visual *visual, Colormap cmap, allocate_p, (writable_pP && *writable_pP)); /* If we tried for writable cells and got none, try for non-writable. */ - if (allocate_p && *ncolorsP == 0 && *writable_pP) + if (allocate_p && *ncolorsP == 0 && writable_pP && *writable_pP) { *writable_pP = False; goto RETRY_NON_WRITABLE;