Esempio n. 1
0
int
main (int argc, char **argv)
{
  glong i;
  gdouble angle;
  ClutterColor color = { 0x00, 0x00, 0x00, 0xff };
  ClutterActor *stage, *rect;

  clutter_perf_fps_init ();

  if (CLUTTER_INIT_SUCCESS !=
        clutter_init_with_args (&argc, &argv,
                                NULL,
                                entries,
                                NULL,
                                NULL))
    {
      g_warning ("Failed to initialize clutter");
      return -1;
    }

  stage = clutter_stage_new ();
  clutter_actor_set_size (stage, 512, 512);
  clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Black);
  clutter_stage_set_title (CLUTTER_STAGE (stage), "Picking Performance");
  g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);

  printf ("Picking performance test with "
          "%d actors and %d events per frame\n",
          n_actors,
          n_events);

  for (i = n_actors - 1; i >= 0; i--)
    {
      angle = ((2.0 * G_PI) / (gdouble) n_actors) * i;

      color.red = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0, i))) /
                  (gdouble)(n_actors/4.0) - 1.0)) * 255.0;
      color.green = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0,
                    fmod (i + (n_actors/3.0)*2, n_actors)))) /
                    (gdouble)(n_actors/4) - 1.0)) * 255.0;
      color.blue = (1.0 - ABS ((MAX (0, MIN (n_actors/2.0 + 0,
                   fmod ((i + (n_actors/3.0)), n_actors)))) /
                   (gdouble)(n_actors/4.0) - 1.0)) * 255.0;

      rect = clutter_rectangle_new_with_color (&color);
      clutter_actor_set_size (rect, 100, 100);
      clutter_actor_set_anchor_point_from_gravity (rect,
                                                   CLUTTER_GRAVITY_CENTER);
      clutter_actor_set_position (rect,
                                  256 + 206 * cos (angle),
                                  256 + 206 * sin (angle));
      clutter_actor_set_reactive (rect, TRUE);
      g_signal_connect (rect, "motion-event",
                        G_CALLBACK (motion_event_cb), NULL);

      clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect);
    }

  clutter_actor_show (stage);

  clutter_perf_fps_start (CLUTTER_STAGE (stage));
  clutter_threads_add_idle (queue_redraw, stage);
  clutter_main ();
  clutter_perf_fps_report ("test-picking");

  return 0;
}
Esempio n. 2
0
gint
main (gint    argc,
      gchar **argv)
{
    ClutterColor  black= {0,0,0,0xff};
    ClutterActor *stage;
    ClutterState *layout_state;
    gint i;

    clutter_perf_fps_init ();
    if (CLUTTER_INIT_SUCCESS != clutter_init (&argc, &argv))
        g_error ("Failed to initialize Clutter");

    stage = clutter_stage_get_default ();
    layout_state = clutter_state_new ();
    clutter_stage_set_color (CLUTTER_STAGE (stage), &black);
    clutter_actor_set_size (stage, STAGE_WIDTH, STAGE_HEIGHT);

    for (i=0; i<TOTAL; i++)
    {
        ClutterActor *actor;
        ClutterState *a_state;

        int row = i/COLS;
        int col = i%COLS;

        actor = new_rect (255 * ( 1.0*col/COLS), 50,
                          255 * ( 1.0*row/ROWS), 255);
        clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
        clutter_actor_set_position (actor, 320.0, 240.0);
        clutter_actor_set_reactive (actor, TRUE);


        clutter_state_set (layout_state, NULL, "active",
                           actor, "delayed::x", CLUTTER_LINEAR,
                           ACTOR_WIDTH * 1.0 * ((TOTAL-1-i) % COLS),
                           ((row*1.0/ROWS))/2, (1.0-(row*1.0/ROWS))/2,
                           actor, "delayed::y", CLUTTER_LINEAR,
                           ACTOR_HEIGHT * 1.0 * ((TOTAL-1-i) / COLS),
                           ((row*1.0/ROWS))/2, 0.0,
                           actor, "rotation-angle-x", CLUTTER_LINEAR, 0.0,
                           actor, "rotation-angle-y", CLUTTER_LINEAR, 0.0,
                           NULL);

        clutter_state_set (layout_state, NULL, "right",
                           actor, "delayed::x", CLUTTER_LINEAR, STAGE_WIDTH * 1.0,
                           ((row*1.0/ROWS))/2,
                           (1.0-(row*1.0/ROWS))/2,
                           actor, "delayed::y", CLUTTER_LINEAR, STAGE_HEIGHT * 1.0,
                           ((row*1.0/ROWS))/2,
                           0.0,
                           NULL);

        clutter_state_set (layout_state, NULL, "left",
                           actor, "rotation-angle-x", CLUTTER_LINEAR, 45.0,
                           actor, "rotation-angle-y", CLUTTER_LINEAR, 5.0,
                           actor, "x", CLUTTER_LINEAR, 0-64.0,
                           actor, "y", CLUTTER_LINEAR, 0-64.0,
                           NULL);

        a_state = clutter_state_new ();
        g_object_set_data_full (G_OBJECT (actor), "hover-state-machine",
                                a_state, g_object_unref);

        clutter_state_set (a_state, NULL, "normal",
                           actor, "opacity", CLUTTER_LINEAR, 0x77,
                           actor, "rotation-angle-z", CLUTTER_LINEAR, 0.0,
                           NULL);
        clutter_state_set (a_state, NULL, "hover",
                           actor, "opacity", CLUTTER_LINEAR, 0xff,
                           actor, "rotation-angle-z", CLUTTER_LINEAR, 10.0,
                           NULL);
        clutter_actor_set_opacity (actor, 0x77);

        clutter_state_set_duration (a_state, NULL, NULL, 500);
    }

    clutter_state_set_duration (layout_state, NULL, NULL, 1000);
    clutter_state_set_duration (layout_state, "active", "left", 1400);

    g_signal_connect (layout_state, "completed", G_CALLBACK (completed), NULL);

    clutter_actor_show (stage);

    clutter_state_warp_to_state (layout_state, "left");
    clutter_state_set_state (layout_state, "active");

    clutter_perf_fps_start (CLUTTER_STAGE (stage));
    clutter_main ();
    clutter_perf_fps_report ("test-state");
    g_object_unref (layout_state);

    return EXIT_SUCCESS;
}