static gboolean process (GeglOperation *operation, void *in_buf, void *out_buf, glong n_pixels, const GeglRectangle *roi, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); gfloat *GEGL_ALIGNED in_pixel; gfloat *GEGL_ALIGNED out_pixel; GeglRectangle whole_region; gfloat lightness, chroma, hue, alpha; gint i; gint x, y; in_pixel = in_buf; out_pixel = out_buf; x = roi->x; y = roi->y; whole_region = *(gegl_operation_source_get_bounding_box (operation, "input")); for (i = 0; i < n_pixels; i++) { /* n is independent from the roi, but from the whole image */ gint n = (3 * o->holdness + 4) * (x + whole_region.width * y); lightness = in_pixel[0]; chroma = in_pixel[1]; hue = in_pixel[2]; alpha = in_pixel[3]; if ((o->hue_distance > 0) && (chroma > 0)) hue = randomize_value (hue, 0.0, 359.0, TRUE, o->hue_distance, o->holdness, x, y, n, o->rand); n += o->holdness + 1; if (o->chroma_distance > 0) { if (chroma == 0) hue = gegl_random_float_range (o->rand, x, y, 0, n, 0.0, 360.0); chroma = randomize_value (chroma, 0.0, 100.0, FALSE, o->chroma_distance, o->holdness, x, y, n+1, o->rand); } n += o->holdness + 2; if (o->lightness_distance > 0) lightness = randomize_value (lightness, 0.0, 100.0, FALSE, o->lightness_distance, o->holdness, x, y, n, o->rand); /*n += o->holdness + 1*/ out_pixel[0] = lightness; out_pixel[1] = chroma; out_pixel[2] = hue; out_pixel[3] = alpha; in_pixel += 4; out_pixel += 4; x++; if (x >= roi->x + roi->width) { x = roi->x; y++; } } return TRUE; }
static gboolean process (GeglOperation *operation, void *in_buf, void *out_buf, glong n_pixels, const GeglRectangle *roi, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); GeglRectangle whole_region; gint i; gint x, y; gfloat * GEGL_ALIGNED in_pixel; gfloat * GEGL_ALIGNED out_pixel; gfloat hue, saturation, value, alpha; in_pixel = in_buf; out_pixel = out_buf; x = roi->x; y = roi->y; whole_region = *(gegl_operation_source_get_bounding_box (operation, "input")); for (i = 0; i < n_pixels; i++) { /* n is independent from the roi, but from the whole image */ gint n = (3 * o->holdness + 4) * (x + whole_region.width * y); hue = in_pixel[0]; saturation = in_pixel[1]; value = in_pixel[2]; alpha = in_pixel[3]; /* there is no need for scattering hue of desaturated pixels here */ if ((o->hue_distance > 0) && (saturation > 0)) hue = randomize_value (hue, 0.0, 1.0, TRUE, o->hue_distance / 360.0, o->holdness, x, y, n, o->rand); n += o->holdness + 1; /* desaturated pixels get random hue before increasing saturation */ if (o->saturation_distance > 0) { if (saturation == 0) hue = gegl_random_float_range (o->rand, x, y, 0, n, 0.0, 1.0); saturation = randomize_value (saturation, 0.0, 1.0, FALSE, o->saturation_distance, o->holdness, x, y, n+1, o->rand); } n += o->holdness + 2; if (o->value_distance > 0) value = randomize_value (value, 0.0, 1.0, FALSE, o->value_distance, o->holdness, x, y, n, o->rand); out_pixel[0] = hue; out_pixel[1] = saturation; out_pixel[2] = value; out_pixel[3] = alpha; in_pixel += 4; out_pixel += 4; x++; if (x >= roi->x + roi->width) { x = roi->x; y++; } } return TRUE; }