[cairo-commit] cairo-gtk-engine/src Makefile.am, 1.7, 1.8 caligula-draw-shadowed.c, NONE, 1.1 caligula-draw-shadowed.h, NONE, 1.1 caligula-draw.c, 1.3, 1.4 caligula-rand.c, NONE, 1.1 caligula-rand.h, NONE, 1.1

Carl Worth commit at pdx.freedesktop.org
Wed Feb 9 14:18:45 PST 2005


Committed by: cworth

Update of /cvs/cairo/cairo-gtk-engine/src
In directory gabe:/tmp/cvs-serv6542/src

Modified Files:
	Makefile.am caligula-draw.c 
Added Files:
	caligula-draw-shadowed.c caligula-draw-shadowed.h 
	caligula-rand.c caligula-rand.h 
Log Message:

        * src/caligula-draw.c: Switch everything to use caligula_rand
        rather than random.
        (caligula_draw_box): Re-seed with widget adress so per-widget
        drawing is deterministic.

        * src/caligula-rand.c: Add simple PRNG so we can re-seed without
        worrying about affecting other use of the C library PRNG.


Index: Makefile.am
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.am	9 Feb 2005 20:21:04 -0000	1.7
+++ Makefile.am	9 Feb 2005 22:18:43 -0000	1.8
@@ -23,7 +23,9 @@
 	caligula-draw-shadowed.c \
 	caligula-draw-shadowed.h \
 	caligula-draw-sketchy.c  \
-	caligula-draw-sketchy.h
+	caligula-draw-sketchy.h	 \
+	caligula-rand.c		 \
+	caligula-rand.h
 
 libcaligula_la_LDFLAGS = \
 	-avoid-version -no-undefined -module	\

--- NEW FILE: caligula-draw-shadowed.c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: caligula-draw-shadowed.h ---
(This appears to be a binary file; contents omitted.)

Index: caligula-draw.c
===================================================================
RCS file: /cvs/cairo/cairo-gtk-engine/src/caligula-draw.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- caligula-draw.c	9 Feb 2005 20:21:04 -0000	1.3
+++ caligula-draw.c	9 Feb 2005 22:18:43 -0000	1.4
@@ -26,6 +26,7 @@
 #include <gdk/gdkx.h>
 
 #include "caligula-draw.h"
+#include "caligula-rand.h"
 
 static cairo_t *
 caligula_begin_paint (GdkDrawable *window, gint *x_offset, gint *y_offset)
@@ -59,12 +60,6 @@
     cairo_destroy (cr);
 }
 
-static int
-get_random (int low, int high)
-{
-    return low + random () / (RAND_MAX / (high - low));
-}
-
 #if 0 /* Swirly button */
 
 enum { LEFT, RIGHT };
@@ -175,26 +170,26 @@
 {
     int top_x, top_y, left_x, left_y, right_x, right_y, bottom_x, bottom_y;
 
-    top_x = x + get_random (15, 40);
+    top_x = x + caligula_rand_within (15, 40);
     top_y = y - 2;
     left_x = x - 4;
-    left_y = get_random (y + height / 2 - 5, y + height / 2 + 5);
-    right_x = left_x + get_random (50, 60);
-    right_y = get_random (y + height / 2 - 5, y + height / 2 + 5);
-    bottom_x = x + get_random (10, 20);
-    bottom_y = y + height - get_random (0, 4);
+    left_y = caligula_rand_within (y + height / 2 - 5, y + height / 2 + 5);
+    right_x = left_x + caligula_rand_within (50, 60);
+    right_y = caligula_rand_within (y + height / 2 - 5, y + height / 2 + 5);
+    bottom_x = x + caligula_rand_within (10, 20);
+    bottom_y = y + height - caligula_rand_within (0, 4);
 
     draw_swoosh (cr, LEFT, x, y, width, height,
 		 top_x, top_y, left_x, left_y,
 		 right_x, right_y, bottom_x, bottom_y);
 
-    top_x = x + width - get_random (10, 20);
-    top_y = y + get_random (0, 4);
+    top_x = x + width - caligula_rand_within (10, 20);
+    top_y = y + caligula_rand_within (0, 4);
     right_x = x + width + 4;
-    right_y = y + get_random (height / 2 - 5, height / 2 + 5);
-    left_x = right_x - get_random (50, 60);
-    left_y = y + get_random (height / 2 - 5, height / 2 + 5);
-    bottom_x = x + width - get_random (15, 40);
+    right_y = y + caligula_rand_within (height / 2 - 5, height / 2 + 5);
+    left_x = right_x - caligula_rand_within (50, 60);
+    left_y = y + caligula_rand_within (height / 2 - 5, height / 2 + 5);
+    bottom_x = x + width - caligula_rand_within (15, 40);
     bottom_y = y + height + 2;
 
     draw_swoosh (cr, RIGHT, x, y, width, height,
@@ -242,10 +237,10 @@
     const double swoosh_alpha = 0.10;
     double top_x, top_y, right_x, right_y;
 
-    top_x = x + get_random (width / 2, width);
-    top_y = y - get_random (0, height * 2);
-    right_x = x + get_random (0, width);
-    right_y = y + height + get_random (0, height);
+    top_x = x + caligula_rand_within (width / 2, width);
+    top_y = y - caligula_rand_within (0, height * 2);
+    right_x = x + caligula_rand_within (0, width);
+    right_y = y + height + caligula_rand_within (0, height);
 
     cairo_new_path (cr);
     cairo_move_to (cr, top_x, top_y);
@@ -324,6 +319,8 @@
     cairo_t *cr;
     gint x_offset, y_offset;
 
+    caligula_srand ((unsigned)widget);
+
     cr = caligula_begin_paint (window, &x_offset, &y_offset);
 
     draw_button (cr, x, y, width, height);

--- NEW FILE: caligula-rand.c ---
(This appears to be a binary file; contents omitted.)

--- NEW FILE: caligula-rand.h ---
(This appears to be a binary file; contents omitted.)




More information about the cairo-commit mailing list