Skip to content

Commit

Permalink
Shift Operation: Make sure the pixels on each line are shifted consis…
Browse files Browse the repository at this point in the history
…tently.
  • Loading branch information
JDShu authored and MichaelMure committed Aug 29, 2012
1 parent 84f8f27 commit 9d3515f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions operations/common/shift.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ process (GeglOperation *operation,

gint n_pixels = result->width * result->height;
gint i;
gint j;

GRand *gr;
gint shift; /* random shift amount */
Expand All @@ -111,6 +112,17 @@ process (GeglOperation *operation,
gr = g_rand_new ();
g_rand_set_seed (gr, o->seed);
shift = g_rand_int_range(gr, -s, s);

if (o->direction == GEGL_HORIZONTAL)
j = result->y;
else
j = result->x;

/* run through the random numbers until we reach the one for the first line */
for(i = 0; i < j; i++)
{
g_rand_int_range(gr, -s, s);
}

while (n_pixels--)
{
Expand Down

0 comments on commit 9d3515f

Please sign in to comment.