[gegl] Bug 779902 - tile-paper is non deterministic
- From: Thomas Manni <tmanni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Bug 779902 - tile-paper is non deterministic
- Date: Tue, 14 Mar 2017 19:27:22 +0000 (UTC)
commit 2eea64ec826db73bdf5f22beafab9e275f91f71a
Author: Thomas Manni <thomas manni free fr>
Date: Tue Mar 14 12:05:49 2017 +0100
Bug 779902 - tile-paper is non deterministic
Add a seed property to the operation and use gegl_random_* functions
operations/common/tile-paper.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/operations/common/tile-paper.c b/operations/common/tile-paper.c
index 66672fb..b7fe192 100644
--- a/operations/common/tile-paper.c
+++ b/operations/common/tile-paper.c
@@ -79,6 +79,8 @@ property_color (bg_color, _("Background color"), "rgba(0.0, 0.0, 0.0, 1.0)")
description (("The tiles' background color"))
ui_meta ("role", "color-primary")
+property_seed (seed, _("Random seed"), rand)
+
#else
#define GEGL_OP_AREA_FILTER
@@ -110,13 +112,17 @@ tile_compare (const void *x,
}
static inline void
-random_move (gint *x,
- gint *y,
- gint max,
- GRand *gr)
+random_move (gint tile_x,
+ gint tile_y,
+ gint *x,
+ gint *y,
+ gint max,
+ GeglProperties *o)
{
- gdouble angle = g_rand_double_range (gr, 0.0, 1.0) * G_PI;
- gdouble radius = g_rand_double_range (gr, 0.0, 1.0) * (gdouble) max;
+ gdouble angle = gegl_random_float_range (o->rand, tile_x, tile_y, 0, 1,
+ 0.0, 1.0) * G_PI;
+ gdouble radius = gegl_random_float_range (o->rand, tile_x, tile_y, 0, 2,
+ 0.0, 1.0) * (gdouble) max;
*x = (gint) (radius * cos (angle));
*y = (gint) (radius * sin (angle));
@@ -151,9 +157,6 @@ randomize_tiles (GeglProperties *o,
gint move_max_pixels = o->move_rate * o->tile_width / 100;
gint x;
gint y;
- GRand *gr;
-
- gr = g_rand_new ();
for (y = 0; y < division_y; y++)
{
@@ -195,8 +198,8 @@ randomize_tiles (GeglProperties *o,
t->height = rect->height - srcy;
}
- t->z = g_rand_int (gr);
- random_move (&t->move_x, &t->move_y, move_max_pixels, gr);
+ t->z = gegl_random_int (o->rand, x, y, 0, 0);
+ random_move (x, y, &t->move_x, &t->move_y, move_max_pixels, o);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]