/** * gimp_color_bar_set_channel: * @bar: a #GimpColorBar widget * @channel: a #GimpHistogramChannel * * Convenience function that calls gimp_color_bar_set_color() with the * color that matches the @channel. **/ void gimp_color_bar_set_channel (GimpColorBar *bar, GimpHistogramChannel channel) { GimpRGB color = { 1.0, 1.0, 1.0, 1.0 }; g_return_if_fail (GIMP_IS_COLOR_BAR (bar)); switch (channel) { case GIMP_HISTOGRAM_VALUE: case GIMP_HISTOGRAM_ALPHA: case GIMP_HISTOGRAM_RGB: gimp_rgb_set (&color, 1.0, 1.0, 1.0); break; case GIMP_HISTOGRAM_RED: gimp_rgb_set (&color, 1.0, 0.0, 0.0); break; case GIMP_HISTOGRAM_GREEN: gimp_rgb_set (&color, 0.0, 1.0, 0.0); break; case GIMP_HISTOGRAM_BLUE: gimp_rgb_set (&color, 0.0, 0.0, 1.0); break; } gimp_color_bar_set_color (bar, &color); }
/** * gimp_color_hex_entry_set_color: * @entry: a #GimpColorHexEntry widget * @color: pointer to a #GimpRGB * * Sets the color displayed by a #GimpColorHexEntry. If the new color * is different to the previously set color, the "color-changed" * signal is emitted. * * Since: GIMP 2.2 **/ void gimp_color_hex_entry_set_color (GimpColorHexEntry *entry, const GimpRGB *color) { g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry)); g_return_if_fail (color != NULL); if (gimp_rgb_distance (&entry->color, color) > 0.0) { gchar buffer[8]; guchar r, g, b; gimp_rgb_set (&entry->color, color->r, color->g, color->b); gimp_rgb_clamp (&entry->color); gimp_rgb_get_uchar (&entry->color, &r, &g, &b); g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b); gtk_entry_set_text (GTK_ENTRY (entry), buffer); /* move cursor to the end */ gtk_editable_set_position (GTK_EDITABLE (entry), -1); g_signal_emit (entry, entry_signals[COLOR_CHANGED], 0); } }
static VALUE rb_gimp_rgb_set (VALUE self, VALUE r, VALUE g, VALUE b) { Get_TypedStruct(self, GimpRGB, color); gimp_rgb_set(color, (gdouble)NUM2DBL(r), (gdouble)NUM2DBL(g), (gdouble)NUM2DBL(b)); return rb_ary_new3(3, r, g, b); }
static void scale_callback (GtkAdjustment *adj, gpointer data) { GtkObject *object; GimpRGB *color; color = (GimpRGB *) data; object = g_object_get_data (G_OBJECT (adj), "colorbutton"); if (GIMP_IS_COLOR_BUTTON (object)) { if (color == &xargs.threshold && lock_threshold == TRUE) { gdouble value = gtk_adjustment_get_value (adj); gimp_rgb_set (color, value, value, value); } gimp_color_button_set_color (GIMP_COLOR_BUTTON (object), color); } }
static void prepare_coef (params *p) { GimpRGB color1; GimpRGB color2; gdouble scalex = svals.scalex; gdouble scaley = svals.scaley; GRand *gr; gr = g_rand_new (); g_rand_set_seed (gr, svals.seed); switch (svals.colorization) { case BILINEAR: p->blend = bilinear; break; case SINUS: p->blend = cosinus; break; case LINEAR: default: p->blend = linear; } if (svals.perturbation==IDEAL) { /* Presumably the 0 * g_rand_int ()s are to pop random * values off the prng, I don't see why though. */ p->c11= 0 * g_rand_int (gr); p->c12= g_rand_double_range (gr, -1, 1) * scaley; p->c13= g_rand_double_range (gr, 0, 2 * G_PI); p->c21= 0 * g_rand_int (gr); p->c22= g_rand_double_range (gr, -1, 1) * scaley; p->c23= g_rand_double_range (gr, 0, 2 * G_PI); p->c31= g_rand_double_range (gr, -1, 1) * scalex; p->c32= 0 * g_rand_int (gr); p->c33= g_rand_double_range (gr, 0, 2 * G_PI); } else { p->c11= g_rand_double_range (gr, -1, 1) * scalex; p->c12= g_rand_double_range (gr, -1, 1) * scaley; p->c13= g_rand_double_range (gr, 0, 2 * G_PI); p->c21= g_rand_double_range (gr, -1, 1) * scalex; p->c22= g_rand_double_range (gr, -1, 1) * scaley; p->c23= g_rand_double_range (gr, 0, 2 * G_PI); p->c31= g_rand_double_range (gr, -1, 1) * scalex; p->c32= g_rand_double_range (gr, -1, 1) * scaley; p->c33= g_rand_double_range (gr, 0, 2 * G_PI); } if (svals.tiling) { p->c11= ROUND (p->c11/(2*G_PI))*2*G_PI; p->c12= ROUND (p->c12/(2*G_PI))*2*G_PI; p->c21= ROUND (p->c21/(2*G_PI))*2*G_PI; p->c22= ROUND (p->c22/(2*G_PI))*2*G_PI; p->c31= ROUND (p->c31/(2*G_PI))*2*G_PI; p->c32= ROUND (p->c32/(2*G_PI))*2*G_PI; } color1 = svals.col1; color2 = svals.col2; if (drawable_is_grayscale) { gimp_rgb_set (&color1, 1.0, 1.0, 1.0); gimp_rgb_set (&color2, 0.0, 0.0, 0.0); } else { switch (svals.colors) { case USE_COLORS: break; case B_W: gimp_rgb_set (&color1, 1.0, 1.0, 1.0); gimp_rgb_set (&color2, 0.0, 0.0, 0.0); break; case USE_FG_BG: gimp_context_get_background (&color1); gimp_context_get_foreground (&color2); break; } } gimp_rgba_get_uchar (&color1, &p->r, &p->g, &p->b, &p->a); gimp_rgba_subtract (&color2, &color1); p->dr = color2.r * 255.0; p->dg = color2.g * 255.0; p->db = color2.b * 255.0; p->da = color2.a * 255.0; g_rand_free (gr); }
/* ----------------------------------------------- * gap_morph_shape_generate_frame_tween_workpoints * ----------------------------------------------- * generate workpoint files (one per frame) * for the specified frame range. * */ gint32 gap_morph_shape_generate_frame_tween_workpoints(GapAnimInfo *ainfo_ptr , GapMorphGlobalParams *mgpp, GtkWidget *masterProgressBar, GtkWidget *progressBar, gboolean *cancelFlagPtr) { GapMorphGUIParams morph_gui_params; GapMorphGUIParams *mgup; gint32 frameCount; gint32 currFrameNr; gint32 nextFrameNr; gint32 currLayerId; gint32 nextLayerId; gint32 firstFrameNr; gint32 lastFrameNr; gdouble framesToProcess; mgup = &morph_gui_params; mgup->mgpp = mgpp; mgup->src_win.zoom = 1.0; /* no zoom available here (use full drawable size for workpoint generation */ mgup->cancelWorkpointGeneration = FALSE; mgup->progressBar = progressBar; mgpp->master_wp_list = NULL; gimp_rgb_set(&mgup->pointcolor, 0.1, 1.0, 0.1); /* startup with GREEN pointcolor */ gimp_rgb_set_alpha(&mgup->pointcolor, 1.0); gimp_rgb_set(&mgup->curr_pointcolor, 1.0, 1.0, 0.1); /* startup with YELLOW color */ gimp_rgb_set_alpha(&mgup->curr_pointcolor, 1.0); frameCount = 0; nextLayerId = -1; if(gap_lib_chk_framerange(ainfo_ptr) != 0) { return(0); } firstFrameNr = CLAMP(mgpp->range_from, ainfo_ptr->first_frame_nr, ainfo_ptr->last_frame_nr); currFrameNr = firstFrameNr; currLayerId = p_getMergedFrameImageLayer(ainfo_ptr, currFrameNr); nextFrameNr = currFrameNr + 1; while(TRUE) { lastFrameNr = MIN(mgpp->range_to, ainfo_ptr->last_frame_nr); framesToProcess = MAX(1, (lastFrameNr - currFrameNr) -1); if (nextFrameNr > lastFrameNr) { break; } nextLayerId = p_getMergedFrameImageLayer(ainfo_ptr, nextFrameNr); if((nextLayerId >= 0) && (currLayerId >= 0)) { char *workpointFileName; gboolean success; workpointFileName = gap_lib_alloc_fname(ainfo_ptr->basename, currFrameNr, "." GAP_MORPH_WORKPOINT_EXTENSION); p_do_master_progress(masterProgressBar , workpointFileName , framesToProcess , (currFrameNr - firstFrameNr) ); success = p_generateWorkpointFileForFramePair(workpointFileName , mgup , cancelFlagPtr , currLayerId , nextLayerId ); g_free(workpointFileName); gap_image_delete_immediate(gimp_drawable_get_image(currLayerId)); if(!success) { break; } currFrameNr = nextFrameNr; currLayerId = nextLayerId; } nextFrameNr++; } if(nextLayerId >= 0) { gap_image_delete_immediate(gimp_drawable_get_image(nextLayerId)); } return (frameCount); } /* end gap_morph_shape_generate_frame_tween_workpoints */