X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fdeluxe.c;h=694a982a6007f6d08aaef1dd598b8040e2ec003d;hb=78add6e627ee5f10e1fa6f3852602ea5066eee5a;hp=7b0ac3b4f6ec427786df17f5a0cc670cf672d50a;hpb=49f5b54f312fe4ac2e9bc47581a72451bd0e8439;p=xscreensaver diff --git a/hacks/deluxe.c b/hacks/deluxe.c index 7b0ac3b4..694a982a 100644 --- a/hacks/deluxe.c +++ b/hacks/deluxe.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1999-2006 Jamie Zawinski +/* xscreensaver, Copyright (c) 1999-2018 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -62,7 +62,14 @@ draw_star (struct state *st, Drawable w, struct throbber *t) XPoint points[11]; int x = t->x; int y = t->y; - int s = t->size / 0.383; /* trial and error, I forget how to derive this */ + + /* + The following constant is really: + sqrt(5 - sqrt(5)) / sqrt(25 - 11 * sqrt(5)) + + Reference: http://mathworld.wolfram.com/Pentagram.html + */ + int s = t->size * 2.6180339887498985; int s2 = t->size; double c = M_PI * 2; double o = -M_PI / 2; @@ -120,25 +127,31 @@ draw_corners (struct state *st, Drawable w, struct throbber *t) int s = (t->size + t->thickness) / 2; XPoint points[3]; - points[0].x = 0; points[0].y = t->y - s; - points[1].x = t->x - s; points[1].y = t->y - s; - points[2].x = t->x - s; points[2].y = 0; - XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); - - points[0].x = 0; points[0].y = t->y + s; - points[1].x = t->x - s; points[1].y = t->y + s; - points[2].x = t->x - s; points[2].y = t->max_size; - XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); - - points[0].x = t->x + s; points[0].y = 0; - points[1].x = t->x + s; points[1].y = t->y - s; - points[2].x = t->max_size; points[2].y = t->y - s; - XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); + if (t->y > s) + { + points[0].x = 0; points[0].y = t->y - s; + points[1].x = t->x - s; points[1].y = t->y - s; + points[2].x = t->x - s; points[2].y = 0; + XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); + + points[0].x = t->x + s; points[0].y = 0; + points[1].x = t->x + s; points[1].y = t->y - s; + points[2].x = t->max_size; points[2].y = t->y - s; + XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); + } - points[0].x = t->x + s; points[0].y = t->max_size; - points[1].x = t->x + s; points[1].y = t->y + s; - points[2].x = t->max_size; points[2].y = t->y + s; - XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); + if (t->x > s) + { + points[0].x = 0; points[0].y = t->y + s; + points[1].x = t->x - s; points[1].y = t->y + s; + points[2].x = t->x - s; points[2].y = t->max_size; + XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); + + points[0].x = t->x + s; points[0].y = t->max_size; + points[1].x = t->x + s; points[1].y = t->y + s; + points[2].x = t->max_size; points[2].y = t->y + s; + XDrawLines (st->dpy, w, t->gc, points, countof(points), CoordModeOrigin); + } } @@ -150,22 +163,19 @@ make_throbber (struct state *st, Drawable d, int w, int h, unsigned long pixel) struct throbber *t = (struct throbber *) malloc (sizeof (*t)); t->x = w / 2; t->y = h / 2; - t->max_size = w; + t->max_size = (w > h ? w : h); t->speed = get_integer_resource (st->dpy, "speed", "Speed"); t->fuse = 1 + (random() % 4); t->thickness = get_integer_resource (st->dpy, "thickness", "Thickness"); + if (st->xgwa.width > 2560) t->thickness *= 3; /* Retina displays */ + if (t->speed < 0) t->speed = -t->speed; t->speed += (((random() % t->speed) / 2) - (t->speed / 2)); if (t->speed > 0) t->speed = -t->speed; - if (random() % 4) - t->size = t->max_size; - else - t->size = t->thickness, t->speed = -t->speed; - flags = GCForeground; -# ifndef HAVE_COCOA +# ifndef HAVE_JWXYZ if (st->transparent_p) { gcv.foreground = ~0L; @@ -173,7 +183,7 @@ make_throbber (struct state *st, Drawable d, int w, int h, unsigned long pixel) flags |= GCPlaneMask; } else -# endif /* !HAVE_COCOA */ +# endif /* !HAVE_JWXYZ */ { gcv.foreground = pixel; } @@ -185,7 +195,7 @@ make_throbber (struct state *st, Drawable d, int w, int h, unsigned long pixel) flags |= (GCLineWidth | GCCapStyle | GCJoinStyle); t->gc = XCreateGC (st->dpy, d, flags, &gcv); -# ifdef HAVE_COCOA +# ifdef HAVE_JWXYZ if (st->transparent_p) { /* give a non-opaque alpha to the color */ @@ -197,7 +207,7 @@ make_throbber (struct state *st, Drawable d, int w, int h, unsigned long pixel) jwxyz_XSetAlphaAllowed (st->dpy, t->gc, True); XSetForeground (st->dpy, t->gc, pixel); } -# endif /* HAVE_COCOA */ +# endif /* HAVE_JWXYZ */ switch (random() % 11) { case 0: case 1: case 2: case 3: t->draw = draw_star; break; @@ -208,6 +218,14 @@ make_throbber (struct state *st, Drawable d, int w, int h, unsigned long pixel) default: abort(); break; } + if (t->draw == draw_circle) + t->max_size *= 1.5; + + if (random() % 4) + t->size = t->max_size; + else + t->size = t->thickness, t->speed = -t->speed; + return t; } @@ -259,7 +277,7 @@ deluxe_init (Display *dpy, Window window) st->dbeclear_p = get_boolean_resource (st->dpy, "useDBEClear", "Boolean"); #endif -# ifdef HAVE_COCOA /* Don't second-guess Quartz's double-buffering */ +# ifdef HAVE_JWXYZ /* Don't second-guess Quartz's double-buffering */ st->dbuf = False; # endif @@ -276,7 +294,7 @@ deluxe_init (Display *dpy, Window window) st->colors[0].pixel = get_pixel_resource(st->dpy, st->xgwa.colormap, "foreground", "Foreground"); } -#ifndef HAVE_COCOA +#ifndef HAVE_JWXYZ else if (st->transparent_p) { st->nplanes = get_integer_resource (st->dpy, "planes", "Planes"); @@ -297,13 +315,13 @@ deluxe_init (Display *dpy, Window window) goto COLOR; } } -#endif /* !HAVE_COCOA */ +#endif /* !HAVE_JWXYZ */ else { -#ifndef HAVE_COCOA +#ifndef HAVE_JWXYZ COLOR: #endif - make_random_colormap (st->dpy, st->xgwa.visual, st->xgwa.colormap, + make_random_colormap (st->xgwa.screen, st->xgwa.visual, st->xgwa.colormap, st->colors, &st->ncolors, True, True, 0, True); if (st->ncolors < 2) goto MONO; @@ -411,7 +429,7 @@ deluxe_free (Display *dpy, Window window, void *closure) static const char *deluxe_defaults [] = { ".background: black", ".foreground: white", - "*delay: 5000", + "*delay: 10000", "*count: 5", "*thickness: 50", "*speed: 15", @@ -422,6 +440,9 @@ static const char *deluxe_defaults [] = { "*useDBE: True", "*useDBEClear: True", #endif /* HAVE_DOUBLE_BUFFER_EXTENSION */ +#ifdef HAVE_MOBILE + "*ignoreRotation: True", +#endif 0 };