mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
test: interactive: port cairo flowers to ClutterCanvas
https://bugzilla.gnome.org/show_bug.cgi?id=759074
This commit is contained in:
parent
9c26a98a6f
commit
25e157ea42
@ -25,8 +25,12 @@ Flower;
|
|||||||
|
|
||||||
static ClutterActor *stage = NULL;
|
static ClutterActor *stage = NULL;
|
||||||
|
|
||||||
static ClutterActor *
|
static gboolean
|
||||||
make_flower_actor (void)
|
draw_flower (ClutterCanvas *canvas,
|
||||||
|
cairo_t *cr,
|
||||||
|
gint width,
|
||||||
|
gint height,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
/* No science here, just a hack from toying */
|
/* No science here, just a hack from toying */
|
||||||
gint i, j;
|
gint i, j;
|
||||||
@ -53,18 +57,11 @@ make_flower_actor (void)
|
|||||||
|
|
||||||
gint idx, last_idx = -1;
|
gint idx, last_idx = -1;
|
||||||
|
|
||||||
ClutterActor *ctex;
|
petal_size = GPOINTER_TO_INT (user_data);
|
||||||
cairo_t *cr;
|
|
||||||
|
|
||||||
petal_size = PETAL_MIN + rand() % PETAL_VAR;
|
|
||||||
size = petal_size * 8;
|
size = petal_size * 8;
|
||||||
|
|
||||||
n_groups = rand() % 3 + 1;
|
n_groups = rand() % 3 + 1;
|
||||||
|
|
||||||
ctex = clutter_cairo_texture_new (size, size);
|
|
||||||
|
|
||||||
cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (ctex));
|
|
||||||
|
|
||||||
cairo_set_tolerance (cr, 0.1);
|
cairo_set_tolerance (cr, 0.1);
|
||||||
|
|
||||||
/* Clear */
|
/* Clear */
|
||||||
@ -133,7 +130,29 @@ make_flower_actor (void)
|
|||||||
cairo_arc(cr, 0, 0, petal_size, 0, M_PI * 2);
|
cairo_arc(cr, 0, 0, petal_size, 0, M_PI * 2);
|
||||||
cairo_fill(cr);
|
cairo_fill(cr);
|
||||||
|
|
||||||
cairo_destroy(cr);
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ClutterActor *
|
||||||
|
make_flower_actor (void)
|
||||||
|
{
|
||||||
|
gint petal_size = PETAL_MIN + rand() % PETAL_VAR;
|
||||||
|
gint size = petal_size * 8;
|
||||||
|
ClutterActor *ctex;
|
||||||
|
ClutterContent *canvas;
|
||||||
|
|
||||||
|
canvas = clutter_canvas_new ();
|
||||||
|
g_signal_connect (canvas, "draw",
|
||||||
|
G_CALLBACK (draw_flower), GINT_TO_POINTER (petal_size));
|
||||||
|
|
||||||
|
clutter_canvas_set_size (CLUTTER_CANVAS (canvas), size, size);
|
||||||
|
ctex = g_object_new (CLUTTER_TYPE_ACTOR,
|
||||||
|
"content", canvas,
|
||||||
|
"width", (gfloat) size,
|
||||||
|
"height", (gfloat) size,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_object_unref (canvas);
|
||||||
|
|
||||||
return ctex;
|
return ctex;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user