]> git.hungrycats.org Git - xscreensaver/blobdiff - hacks/rorschach.c
From https://www.jwz.org/xscreensaver/xscreensaver-6.09.tar.gz
[xscreensaver] / hacks / rorschach.c
index 0d352696b71c1e51b5b5c0aa0370021c83e2c455..58b1c8f8ad5c2056b56c76b340ea2600fb404866 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1992-2008 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1992-2014 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -22,6 +22,7 @@ struct state {
   Bool xsym, ysym;
   int sleep_time;
   int xlim, ylim;
+  int scale;
   XColor color;
   int current_x, current_y, remaining_iterations;
   eraser_state *eraser;
@@ -36,6 +37,12 @@ rorschach_init (Display *dpy, Window window)
   Colormap cmap;
   XWindowAttributes xgwa;
   XGetWindowAttributes (dpy, window, &xgwa);
+
+  st->scale = 1;
+  if (xgwa.width > 2560 || xgwa.height > 2560)
+    st->scale *= 3;  /* Retina displays */
+
+
   cmap = xgwa.colormap;
   gcv.foreground = st->default_fg_pixel =
     get_pixel_resource (dpy, cmap, "foreground", "Foreground");
@@ -93,7 +100,7 @@ static void
 rorschach_draw_step (Display *dpy, Window window, struct state *st)
 {
 # define ITER_CHUNK 300
-  XPoint points [4 * ITER_CHUNK];
+  XRectangle points [4 * ITER_CHUNK];
   int x = st->current_x;
   int y = st->current_y;
   int i, j = 0;
@@ -108,27 +115,31 @@ rorschach_draw_step (Display *dpy, Window window, struct state *st)
       y += ((random () % (1 + (st->offset << 1))) - st->offset);
       points [j].x = x;
       points [j].y = y;
+      points[j].width = points[j].height = st->scale;
       j++;
       if (st->xsym)
        {
          points [j].x = st->xlim - x;
          points [j].y = y;
+          points[j].width = points[j].height = st->scale;
          j++;
        }
       if (st->ysym)
        {
          points [j].x = x;
          points [j].y = st->ylim - y;
+          points[j].width = points[j].height = st->scale;
          j++;
        }
       if (st->xsym && st->ysym)
        {
          points [j].x = st->xlim - x;
          points [j].y = st->ylim - y;
+          points[j].width = points[j].height = st->scale;
          j++;
        }
     }
-  XDrawPoints (dpy, window, st->draw_gc, points, j, CoordModeOrigin);
+  XFillRectangles (dpy, window, st->draw_gc, points, j);
   st->remaining_iterations -= this_iterations;
   if (st->remaining_iterations < 0) st->remaining_iterations = 0;
   st->current_x = x;
@@ -168,6 +179,12 @@ rorschach_draw (Display *dpy, Window window, void *closure)
 static Bool
 rorschach_event (Display *dpy, Window window, void *closure, XEvent *event)
 {
+  struct state *st = (struct state *) closure;
+  if (screenhack_event_helper (dpy, window, event))
+    {
+      st->remaining_iterations = 0;
+      return True;
+    }
   return False;
 }
 
@@ -175,6 +192,7 @@ static void
 rorschach_free (Display *dpy, Window window, void *closure)
 {
   struct state *st = (struct state *) closure;
+  XFreeGC (dpy, st->draw_gc);
   free (st);
 }
 
@@ -188,7 +206,7 @@ static const char *rorschach_defaults [] = {
   "*iterations:        4000",
   "*offset:    7",
   "*delay:     5",
-#ifdef USE_IPHONE
+#ifdef HAVE_MOBILE
   "*ignoreRotation: True",
 #endif
   0