static void add_text(CrItem *group) { double x, y; gboolean scaleable; const char *text; CrItem *item; x = g_random_double_range(0, 380); y = g_random_double_range(0, 380); scaleable = g_random_boolean(); if (scaleable) text = "This text will <b>scale</b>."; else text = "This text will <b>not</b>."; item = cr_text_new(group, x, y, text, "scaleable", scaleable, "font", "Sans 12", "anchor", GTK_ANCHOR_NW, "use-markup", TRUE, "fill_color_rgba", 0x000000ffL, NULL); g_signal_connect(item, "event", (GCallback) item_event, NULL); }
static void add_ellipse(CrItem *group) { double x, y, width, height, orientation, tmp1, tmp2; GArray *array; CrItem *item; guint color; x = g_random_double_range(0, 360); y = g_random_double_range(0, 360); tmp1 = g_random_double_range(10, 200); tmp2 = g_random_double_range(10, 200); width = MAX(tmp1, tmp2); height = MIN(tmp1, tmp2); orientation = g_random_double_range(0, G_PI); color = g_random_int_range(0,255) << 24 | g_random_int_range(0,255) << 16 | g_random_int_range(0,255) << 8 | 0xff; item = cr_ellipse_new(group, x, y, width, height, orientation, "outline_color_rgba", 0x000000ff, "line_scaleable", FALSE, "line_width", 2.0, "fill_color_rgba", color, NULL); g_signal_connect(item, "event", (GCallback) item_event, NULL); }
static void add_vector(CrItem *group) { double x, y, x2, y2; GArray *array; CrItem *item; guint color; x = g_random_double_range(0, 360); y = g_random_double_range(0, 360); x2 = g_random_double_range(10, 100); y2 = g_random_double_range(10, 100); item = cr_vector_new(group, x, y, x2, y2, "outline_color_rgba", 0x000000ff, "end_scaleable", FALSE, "line_scaleable", FALSE, "line_width", 2.0, NULL); cr_arrow_new(item, -1, NULL); cr_arrow_new(item, 0, NULL); g_signal_connect(item, "event", (GCallback) item_event, NULL); }
static void add_arrow(CrItem *group) { double x, y, depth; gboolean scaleable; const char *color; int i; CrItem *item; GArray *array; array = g_array_new(FALSE, FALSE, sizeof(double)); x = g_random_double_range(0, 380); y = g_random_double_range(0, 380); for (i = 0; i < 4; i++) { g_array_append_val(array, x); g_array_append_val(array, y); x += g_random_double_range(5, 50); y += g_random_double_range(5, 50); } item = cr_line_new(group, "array", array, "outline_color", "darkgreen", "close", FALSE, NULL); cr_arrow_new(item, 0, NULL); cr_arrow_new(item, 1, NULL); cr_arrow_new(item, -2, NULL); cr_arrow_new(item, -1, NULL); g_signal_connect(item, "event", (GCallback) item_event, NULL); }
static void add_pixbuf(CrItem *group) { double x, y; CrItem *item; GdkPixbuf *pixbuf; GError *error; x = g_random_double_range(0, 380); y = g_random_double_range(0, 380); error = NULL; pixbuf = gdk_pixbuf_new_from_file("bug.png", &error); g_return_if_fail(pixbuf); item = cr_pixbuf_new(group, x, y, "pixbuf", pixbuf, "scaleable", FALSE, "anchor", GTK_ANCHOR_CENTER, NULL); g_object_unref(pixbuf); g_signal_connect(item, "event", (GCallback) item_event, NULL); }
static void add_rectangle(CrItem *group) { double x, y, w, h; CrItem *item; guint color; x = g_random_double_range(0, 360); y = g_random_double_range(0, 360); w = g_random_double_range(10, 100); h = g_random_double_range(10, 100); color = g_random_int_range(0,255) << 24 | g_random_int_range(0,255) << 16 | g_random_int_range(0,255) << 8 | 0xff; item = cr_rectangle_new(group, x, y, w, h, "outline_color_rgba", 0x000000ff, "line_scaleable", TRUE, "line_width", 2.0, "fill_color_rgba", color, NULL); g_signal_connect(item, "event", (GCallback) item_event, NULL); }
static void setup (void) { GstTagSetter *setter; gchar *desc_str; GstCaps *filter_caps; GstBus *bus; gint i; GST_INFO ("init"); main_loop = g_main_loop_new (NULL, TRUE); camera = gst_check_setup_element ("camerabin"); setup_camerabin_elements (camera); g_signal_connect (camera, "image-done", G_CALLBACK (capture_done), main_loop); bus = gst_pipeline_get_bus (GST_PIPELINE (camera)); gst_bus_add_watch (bus, (GstBusFunc) capture_bus_cb, main_loop); gst_bus_set_sync_handler (bus, bus_sync_callback, main_loop); gst_object_unref (bus); filter_caps = gst_caps_from_string ("video/x-raw-yuv,format=(fourcc)I420"); g_object_set (G_OBJECT (camera), "filter-caps", filter_caps, NULL); gst_caps_unref (filter_caps); /* force a low framerate here to not timeout the tests because of the * encoders */ g_signal_emit_by_name (camera, "set-video-resolution-fps", 320, 240, 5, 1, NULL); /* Set some default tags */ setter = GST_TAG_SETTER (camera); desc_str = g_strdup_printf ("Created by %s", g_get_real_name ()); gst_tag_setter_add_tags (setter, GST_TAG_MERGE_REPLACE, GST_TAG_DESCRIPTION, desc_str, NULL); g_free (desc_str); if (gst_element_set_state (GST_ELEMENT (camera), GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { GST_WARNING ("setting camerabin to PLAYING failed"); gst_element_set_state (GST_ELEMENT (camera), GST_STATE_NULL); gst_object_unref (camera); camera = NULL; } /* create the taglists */ for (i = 0; i < TAGLISTS_COUNT; i++) { taglists[i] = gst_tag_list_new_full (GST_TAG_ARTIST, "test-artist", GST_TAG_GEO_LOCATION_LONGITUDE, g_random_double_range (-180, 180), GST_TAG_GEO_LOCATION_LATITUDE, g_random_double_range (-90, 90), GST_TAG_GEO_LOCATION_ELEVATION, g_random_double_range (0, 3000), NULL); } GST_INFO ("init finished"); }
static void add_line(CrItem *group) { int i, total; double angle, dist, cx, cy, x, y; GArray *array; CrItem *line; guint color; cairo_pattern_t *pattern; array = g_array_new(FALSE, FALSE, sizeof(double)); total = g_random_int_range(3, 30); cx = g_random_double_range(40, 360); cy = g_random_double_range(40, 360); for (i = 0, angle = 0; i < total; angle += 2. * M_PI/total, i++) { dist = g_random_double_range(10, 40); x = cx + dist * sin(angle); y = cy + dist * cos(angle); g_array_append_val(array, x); g_array_append_val(array, y); } line = cr_line_new(group, "array", array, "outline_color_rgba", 0x000000ff, "line_scaleable", TRUE, "line_width", 3.0, NULL); if (g_random_boolean()) { color = g_random_int_range(0,255) << 24 | g_random_int_range(0,255) << 16 | g_random_int_range(0,255) << 8 | 0xff; g_object_set(line, "fill_color_rgba", color, NULL); } else { pattern = cairo_pattern_create_linear(0, 0, g_random_double_range(5, 20), g_random_double_range(5, 20)); cairo_pattern_add_color_stop_rgb(pattern, 0, g_random_double(), g_random_double(), g_random_double()); cairo_pattern_add_color_stop_rgb(pattern, 10, g_random_double(), g_random_double(), g_random_double()); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); g_object_set(line, "pattern", pattern, NULL); cairo_pattern_destroy(pattern); } g_signal_connect(line, "event", (GCallback) item_event, NULL); }
gdouble gimp_paint_options_get_dynamic_size (GimpPaintOptions *paint_options, const GimpCoords *coords, gboolean use_dynamics) { gdouble scale = 1.0; if (use_dynamics) { gdouble pressure = -1.0; gdouble velocity = -1.0; gdouble random = -1.0; if (paint_options->pressure_options->size) { pressure = coords->pressure; } else if (paint_options->pressure_options->inverse_size) { pressure = 1.0 - 0.9 * coords->pressure; } if (paint_options->velocity_options->size) { velocity = 1.0 - sqrt (coords->velocity); } else if (paint_options->velocity_options->inverse_size) { velocity = sqrt (coords->velocity); } if (paint_options->random_options->size) { random = 1.0 - g_random_double_range (0.0, 1.0); } else if (paint_options->random_options->inverse_size) { random = g_random_double_range (0.0, 1.0); } scale = gimp_paint_options_get_dynamics_mix (pressure, paint_options->pressure_options->prescale, velocity, paint_options->velocity_options->prescale, random, paint_options->random_options->prescale); if (scale < 1 / 64.0) scale = 1 / 8.0; else scale = sqrt (scale); } scale *= paint_options->brush_scale; return scale; }
/* --- adsr --- */ static double * noise_filterer_synth (BbInstrument *instrument, BbRenderInfo *render_info, GValue *params, guint *n_samples_out) { double repeat_count = g_value_get_double (params + 1); BbFilter1 *filter = g_value_dup_boxed (params + 2); double prepasses = g_value_get_double (params + 3); double falloff = g_value_get_double (params + 4); guint n = render_info->note_duration_samples; guint delay_line_len_unclamped = n / MAX (1, repeat_count); guint delay_line_len = MAX (delay_line_len_unclamped, 10); BbDelayLine *delay_line = bb_delay_line_new (delay_line_len); double *rv = g_new (double, n); double last = 0; guint i, j; if (repeat_count < 1.0) g_message ("repeat-count is too low (%.6f)", repeat_count); //g_message ("overall falloff: %.6f", falloff); falloff = pow (falloff, 1.0 / (1.0 + repeat_count)); //g_message ("per-instance falloff: %.6f", falloff); for (i = 0; i < delay_line_len; i++) delay_line->buffer[i] = g_random_double_range (-1, 1); for (j = 0; j < prepasses; j++) for (i = 0; i < delay_line_len; i++) last = bb_delay_line_add (delay_line, bb_filter1_run (filter, last)); for (i = 0; i < n; i++) { rv[i] = last = bb_delay_line_add (delay_line, bb_filter1_run (filter, last)); last *= falloff; } *n_samples_out = n; bb_filter1_free (filter); return rv; }
/** * uber_heat_map_render_fast: * @graph: A #UberGraph. * * XXX * * Returns: None. * Side effects: None. */ static void uber_heat_map_render_fast (UberGraph *graph, /* IN */ cairo_t *cr, /* IN */ GdkRectangle *area, /* IN */ guint epoch, /* IN */ gfloat each) /* IN */ { UberGraphPrivate *priv; gfloat height; gint i; g_return_if_fail(UBER_IS_HEAT_MAP(graph)); priv = graph->priv; /* * XXX: Temporarily draw nice little squares. */ #define COUNT 10 height = area->height / (gfloat)COUNT; for (i = 0; i < COUNT; i++) { cairo_rectangle(cr, area->x + area->width - each, area->y + (i * height), each, height); cairo_set_source_rgba(cr, .1, .1, .8, g_random_double_range(0., 1.)); cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); cairo_fill(cr); } }
static void _random_distribution (PointAccum **points, AranSolver3d *solver) { guint i, cptr = 0; gdouble tol = 1.e-2; aran_solver3d_set_tolerance (solver, tol); for (i=0; i<np; i++) { PointAccum *point = g_malloc0 (sizeof (PointAccum)); PointAccum *found; point->vector.x = g_random_double_range (-R,R); point->vector.y = g_random_double_range (-R,R); point->vector.z = g_random_double_range (-R,R); point->density = g_random_double_range (0., 2./np); point->field = VSG_V3D_ZERO; /* point->accum = 0.; */ point->id = cptr; if (direct) { points[cptr] = point; cptr ++; } else { found = aran_solver3d_find_point (solver, point); if (found != NULL) { found->density += point->density; g_free (point); } else { points[cptr] = point; aran_solver3d_insert_point (solver, point); cptr ++; } } } np = cptr; }
static void move_progress(GtkWidget *entry, gpointer progress) { gdouble step; g_return_if_fail(GTK_IS_PROGRESS_BAR(progress)); step = g_random_double_range(0.03, 0.1); gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(progress), step); gtk_progress_bar_pulse(GTK_PROGRESS_BAR(progress)); }
static void _random_distribution (PointAccum **points, AranSolver2d *solver) { guint i; for (i=0; i<np; i++) { PointAccum *point = g_malloc0 (sizeof (PointAccum)); point->vector.x = g_random_double_range (-R,R); point->vector.y = g_random_double_range (-R,R); point->density = 1.; point->accum = 0.; point->id = i; points[i] = point; aran_solver2d_insert_point (solver, point); } }
int main() { g_type_init(); if (!g_thread_supported ()) g_thread_init (NULL); g_printf("Testing spectrum_unfold()"); HosSpectrum *S1 = HOS_SPECTRUM(spectrum_test_cube_new()); HosSpectrum *S2 = spectrum_flakify(S1, 1.0 - 2e-4); HosSpectrum *S3 = spectrum_unfold(S2, 1, 2, 1, FALSE); HosSpectrum *S4 = spectrum_transpose(S2, 1); HosSpectrum *S5 = spectrum_transpose(S3, 1); gdouble y1 = g_random_double_range(spectrum_giro_ppm(S4, 0), spectrum_orig_ppm(S4, 0)); gdouble yn = g_random_double_range(spectrum_giro_ppm(S4, 0), spectrum_orig_ppm(S4, 0)); HosSpectrum *S6 = spectrum_extract_ppm(S4, y1, yn); HosSpectrum *S7 = spectrum_extract_ppm(S5, y1, yn); monitor_interval /= 10; spectrum_monitor(S7); gint i; for (i = 0; i < 50; ++i) { gint x = g_random_int_range(0, spectrum_np(S6, 0)); gint y = g_random_int_range(0, spectrum_np(S6, 1)); gint z = g_random_int_range(0, spectrum_np(S6, 2)); gdouble s6 = grok_point(S6, x, y, z); gdouble s7 = grok_point(S7, x, y, z); g_assert(fabs(s6 - s7) < 0.01); } g_print("OK\n"); return 0; }
static void add_grab(CrItem *group) { double x, y, w, h; GArray *array; CrItem *outlined_thing; /* This demonstrates how to use a rectangle (or any other path) * to grab something that is normally hard to grab */ x = g_random_double_range(0, 360); y = g_random_double_range(0, 360); w = g_random_double_range(20, 100); h = g_random_double_range(20, 100); /* normally you could grab this only by the outline which in this case * is specified to be one pixel wide. */ outlined_thing = cr_rectangle_new(group, x, y, w, h, "outline_color_rgba", 0x000000ff, "line_scaleable", FALSE, "line_width", 1.0, NULL); /* An invisible grabbable path is added as a child of the item that is * difficult to grab. It is important to remember the x,y positions * of child items are referenced against their parent, so 0, 0 is * used here.*/ cr_rectangle_new(outlined_thing, 0, 0, w, h, /* don't set fill or outline color and the item * will not paint, but will have bounds. */ "test-fill", TRUE, NULL); /* The event of the child item is pushed up to the parent since it is * not handled by the child item.*/ g_signal_connect(outlined_thing, "event", (GCallback) item_event, NULL); }
static Path * screen_saver_floater_create_path_to_random_point (ScreenSaver *screen_saver, ScreenSaverFloater *floater, gdouble duration) { Point start_position, end_position, start_control_point, end_control_point; start_position = floater->position; end_position.x = start_position.x + (g_random_double_range (-.5, .5) * 4 * FLOATER_MAX_SIZE); end_position.y = start_position.y + (g_random_double_range (-.5, .5) * 4 * FLOATER_MAX_SIZE); start_control_point.x = start_position.x + .95 * (end_position.x - start_position.x); start_control_point.y = start_position.y + .95 * (end_position.y - start_position.y); end_control_point.x = start_position.x + 1.0 * (end_position.x - start_position.x); end_control_point.y = start_position.y + 1.0 * (end_position.y - start_position.y); return path_new (&start_position, &start_control_point, &end_control_point, &end_position, duration); }
static gboolean dummy_scatter_func (UberScatter *scatter, /* IN */ GArray **array, /* OUT */ gpointer user_data) /* IN */ { gdouble val; gint i; *array = g_array_new(FALSE, FALSE, sizeof(gdouble)); for (i = 0; i < 4; i++) { val = g_random_double_range(0., 100.); g_array_append_val(*array, val); } return TRUE; }
static void screen_saver_create_floaters (ScreenSaver *screen_saver) { gint i; for (i = 0; i < screen_saver->max_floater_count; i++) { ScreenSaverFloater *floater; Point position; gdouble scale; position.x = g_random_double_range (screen_saver->canvas_rectangle.top_left_point.x, screen_saver->canvas_rectangle.bottom_right_point.x); position.y = g_random_double_range (screen_saver->canvas_rectangle.top_left_point.y, screen_saver->canvas_rectangle.bottom_right_point.y); scale = g_random_double (); floater = screen_saver_floater_new (screen_saver, &position, scale); screen_saver->floaters = g_list_prepend (screen_saver->floaters, floater); } }
void gameinfo_serve_set(GameInfo *gi, TEAM win) { if (win == BLUE) { ball_init(gi->ball, BLUE); } else { ball_init(gi->ball, RED); } slime_init(gi->slime_blue); slime_init(gi->slime_red); gi->penalty_y = g_random_double_range(120, WIN_HEIGHT - 40); // XXX gi->ball_count = 1; gi->wait_count = 0; gi->state = GS_PLAY; }
/** * rtp_stats_add_rtcp_jitter: * @stats: an #RTPSessionStats struct * @interval: an RTCP interval * * Apply a random jitter to the @interval. @interval is typically obtained with * rtp_stats_calculate_rtcp_interval(). * * Returns: the new RTCP interval. */ GstClockTime rtp_stats_add_rtcp_jitter (RTPSessionStats * stats, GstClockTime interval) { gdouble temp; /* see RFC 3550 p 30 * To compensate for "unconditional reconsideration" converging to a * value below the intended average. */ #define COMPENSATION (2.71828 - 1.5); temp = (interval * g_random_double_range (0.5, 1.5)) / COMPENSATION; return (GstClockTime) temp; }
static Path * screen_saver_floater_create_path_to_on_screen (ScreenSaver *screen_saver, ScreenSaverFloater *floater, gdouble duration) { Point start_position, end_position, start_control_point, end_control_point; start_position = floater->position; end_position.x = g_random_double_range (.25, .75) * (screen_saver->canvas_rectangle.top_left_point.x + screen_saver->canvas_rectangle.bottom_right_point.x); end_position.y = g_random_double_range (.25, .75) * (screen_saver->canvas_rectangle.top_left_point.y + screen_saver->canvas_rectangle.bottom_right_point.y); start_control_point.x = start_position.x + .9 * (end_position.x - start_position.x); start_control_point.y = start_position.y + .9 * (end_position.y - start_position.y); end_control_point.x = start_position.x + 1.0 * (end_position.x - start_position.x); end_control_point.y = start_position.y + 1.0 * (end_position.y - start_position.y); return path_new (&start_position, &start_control_point, &end_control_point, &end_position, duration); }
static gboolean on_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { OsmGpsMapPoint coord; float lat, lon; OsmGpsMap *map = OSM_GPS_MAP(widget); OsmGpsMapTrack *othertrack = OSM_GPS_MAP_TRACK(user_data); if (event->type == GDK_3BUTTON_PRESS) { if (event->button == 1) { if (g_last_image) osm_gps_map_image_remove (map, g_last_image); } if (event->button == 3) { osm_gps_map_track_remove(map, othertrack); } } if (event->type == GDK_2BUTTON_PRESS) { osm_gps_map_convert_screen_to_geographic(map, event->x, event->y, &coord); osm_gps_map_point_get_degrees(&coord, &lat, &lon); if (event->button == 1) { osm_gps_map_gps_add (map, lat, lon, g_random_double_range(0,360)); } if (event->button == 3) { osm_gps_map_track_add_point(othertrack, &coord); } } if (event->type == GDK_BUTTON_PRESS) { if (event->button == 2) { osm_gps_map_convert_screen_to_geographic(map, event->x, event->y, &coord); osm_gps_map_point_get_degrees(&coord, &lat, &lon); g_last_image = osm_gps_map_image_add ( map, lat, lon, g_star_image); } } return FALSE; }
static gboolean screen_saver_floater_should_come_on_screen (ScreenSaver *screen_saver, ScreenSaverFloater *floater, gdouble performance_ratio, gdouble *duration) { if (!screen_saver_floater_is_off_canvas (screen_saver, floater)) return FALSE; if ((abs (performance_ratio - .5) >= G_MINDOUBLE) && (g_random_double () > .5)) { if (duration) *duration = g_random_double_range (3.0, 7.0); return TRUE; } return FALSE; }
static void add_actor (ClutterContainer *container) { ClutterActor *rect; ClutterColor color = { 0xff, 0xff, 0xff, 255 }; static gboolean expand = TRUE; clutter_color_from_hls (&color, g_random_double_range (0.0, 360.0), 0.5, 0.5); rect = clutter_rectangle_new_with_color (&color); clutter_actor_set_size (rect, 32, 64); clutter_container_add_actor (container, rect); clutter_actor_set_reactive (rect, TRUE); g_signal_connect (rect, "enter-event", G_CALLBACK (enter_event), NULL); g_signal_connect (rect, "leave-event", G_CALLBACK (leave_event), NULL); g_signal_connect (rect, "button-release-event", G_CALLBACK (button_release_event), container); clutter_container_child_set (container, rect, "expand", expand, NULL); expand = !expand; }
static Path * screen_saver_floater_create_path (ScreenSaver *screen_saver, ScreenSaverFloater *floater) { gdouble performance_ratio; gdouble duration; performance_ratio = screen_saver_get_frames_per_second (screen_saver) / OPTIMAL_FRAME_RATE; if (abs (performance_ratio) <= G_MINDOUBLE) performance_ratio = 1.0; if (screen_saver_floater_should_bubble_up (screen_saver, floater, performance_ratio, &duration)) return screen_saver_floater_create_path_to_bubble_up (screen_saver, floater, duration); if (screen_saver_floater_should_come_on_screen (screen_saver, floater, performance_ratio, &duration)) return screen_saver_floater_create_path_to_on_screen (screen_saver, floater, duration); return screen_saver_floater_create_path_to_random_point (screen_saver, floater, g_random_double_range (3.0, 7.0)); }
static gboolean on_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { OsmGpsMapPoint coord; float lat, lon; OsmGpsMap *map = OSM_GPS_MAP(widget); double dist; double lat1,lon1; if (event->type == GDK_2BUTTON_PRESS) { osm_gps_map_convert_screen_to_geographic(map, event->x, event->y, &coord); osm_gps_map_point_get_degrees(&coord, &lat, &lon); fprintf(stderr, "lat %f lon %f\n",lat,lon); lat1=(double)lat; lon1=(double)lon; //send the function using last latitude,longitude and present latitude and longitude if(k==0) { k=1; dist=distance(0,0); fprintf(stderr, "distance betwwn two points %f", dist); lastlat=lat1; lastlon=lon1; } else { dist=distance(lat1,lon1); fprintf(stderr, "distance betwwn two points %f", dist); //i=i+1; } if (event->button == 1) { osm_gps_map_gps_add (map,lat,lon,g_random_double_range(0,360)); } } return FALSE; }
gdouble gimp_paint_options_get_dynamic_hardness (GimpPaintOptions *paint_options, const GimpCoords *coords) { gdouble hardness = 1.0; g_return_val_if_fail (GIMP_IS_PAINT_OPTIONS (paint_options), 1.0); g_return_val_if_fail (coords != NULL, 1.0); if (paint_options->pressure_options->hardness || paint_options->velocity_options->hardness || paint_options->random_options->hardness) { gdouble pressure = -1.0; gdouble velocity = -1.0; gdouble random = -1.0; if (paint_options->pressure_options->hardness) pressure = GIMP_PAINT_PRESSURE_SCALE * coords->pressure; if (paint_options->velocity_options->hardness) velocity = GIMP_PAINT_VELOCITY_SCALE * (1 - coords->velocity); if (paint_options->random_options->hardness) random = g_random_double_range (0.0, 1.0); hardness = gimp_paint_options_get_dynamics_mix (pressure, paint_options->pressure_options->prescale, velocity, paint_options->velocity_options->prescale, random, paint_options->random_options->prescale); } return hardness; }
static inline gdouble drand (void) { return g_random_double_range (-1, 1); }
int main (int argc, char **argv) { const ClutterColor transp = { 0x00, 0x00, 0x00, 0x00 }; const ClutterColor bg_color = { 0xe0, 0xf2, 0xfc, 0xff }; ClutterTimeline *timeline; ClutterActor *stage; gint i; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_stage_set_title (CLUTTER_STAGE (stage), "Circles"); clutter_stage_set_color (CLUTTER_STAGE (stage), &bg_color); clutter_actor_set_size (stage, SCREEN_W, SCREEN_H); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); timeline = clutter_timeline_new (5000); clutter_timeline_set_loop (timeline, TRUE); for (i = 0; i < N_CIRCLES; i++) { gint size; gdouble *angle; ClutterActor *actor; ClutterAlpha *alpha; ClutterBehaviour *behaviour; actor = clutter_rectangle_new_with_color (&transp); size = (i + 1) * (CIRCLE_W + CIRCLE_G) * 2; clutter_actor_set_size (actor, size, size); clutter_actor_set_position (actor, SCREEN_W - size / 2.0, SCREEN_H - size / 2.0); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); angle = g_slice_new (gdouble); *angle = g_random_double_range (0.0, 90.0); g_object_set_data (G_OBJECT (actor), "angle", angle); g_signal_connect (actor, "paint", G_CALLBACK (circle_paint_cb), NULL); /* Animate */ alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); behaviour = clutter_behaviour_rotate_new (alpha, CLUTTER_Z_AXIS, (i % 2) ? CLUTTER_ROTATE_CW : CLUTTER_ROTATE_CCW, 0.0, 0.0); clutter_behaviour_rotate_set_center (CLUTTER_BEHAVIOUR_ROTATE (behaviour), size / 2, size / 2, 0); clutter_behaviour_apply (behaviour, actor); } ClutterActor *actor2 = clutter_group_new(); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor2); clutter_actor_set_position(actor2, 10, 10); ClutterEffect *effect2 = nineslice_effect_new_from_source(source); clutter_actor_add_effect(actor2, effect2); ClutterActor *actor = clutter_group_new(); clutter_container_add_actor (CLUTTER_CONTAINER (actor2), actor); ClutterEffect *effect = nineslice_effect_new_from_source(source); clutter_actor_add_effect(actor, effect); ClutterActor *text = clutter_text_new_with_text("Sans 40px","Example Text"); clutter_actor_set_position(text, 0, 0); clutter_container_add_actor (CLUTTER_CONTAINER (actor), text); ClutterActor *rect = clutter_rectangle_new(); clutter_actor_set_position(rect, 10, 100); clutter_actor_set_size(rect, 50, 50); clutter_container_add_actor (CLUTTER_CONTAINER (actor), rect); clutter_actor_set_position(actor, 200, 100); //clutter_actor_set_rotation(actor, CLUTTER_Z_AXIS, 30.0, 130, 50, 0); /* GValue cvalue = G_VALUE_INIT; g_value_init(&cvalue, CLUTTER_TYPE_ACTOR_BOX); g_value_set_boxed(&cvalue, clutter_actor_box_new(0.0, 0.0, 0.0, 0.0)); GValue ovalue = G_VALUE_INIT; g_value_init(&ovalue, CLUTTER_TYPE_ACTOR_BOX); g_value_set_boxed(&ovalue, clutter_actor_box_new(50.0, 50.0, 50.0, 50.0)); ClutterState *transition = clutter_state_new(); clutter_state_set_duration(transition, NULL, NULL, 5000); clutter_state_set_key (transition, NULL, "close", G_OBJECT(effect), "padding", CLUTTER_LINEAR, &cvalue, 0.0, 0.0); clutter_state_set_key (transition, NULL, "open", G_OBJECT(effect), "padding", CLUTTER_LINEAR, &ovalue, 0.0, 0.0); //clutter_state_set(transition, NULL, "close", effect, "padding_right", CLUTTER_LINEAR, 0.0, NULL); //clutter_state_set(transition, NULL, "open", effect, "padding_right", CLUTTER_LINEAR, 50.0, NULL); clutter_state_warp_to_state(transition, "close"); clutter_state_set_state(transition, "open"); */ clutter_actor_animate(rect, CLUTTER_LINEAR, 5000, "height", 200.0, NULL); clutter_actor_show_all (stage); clutter_timeline_start (timeline); clutter_main (); return 0; }