Пример #1
0
void clarity_cover_set_rotation_behaviour(ClarityCover *self, ClutterAlpha *alpha, int final_angle, ClutterRotateDirection direction) {
    g_return_if_fail(CLARITY_IS_COVER(self));

    double current = clutter_actor_get_rotation(CLUTTER_ACTOR(self), CLUTTER_Y_AXIS, 0, 0, 0);

    if(current < 0)
        current += 360;
    else if(current > 360)
        current -= 360;

    if(current != final_angle) {
        self->priv->rotateBehaviour = clutter_behaviour_rotate_new (
                alpha,
                CLUTTER_Y_AXIS,
                direction ,
                current,
                final_angle);

        clutter_behaviour_rotate_set_center(
                CLUTTER_BEHAVIOUR_ROTATE(self->priv->rotateBehaviour),
                clutter_actor_get_width(CLUTTER_ACTOR(self)) / 2,
                0, 0);

        clutter_behaviour_apply (self->priv->rotateBehaviour, CLUTTER_ACTOR(self));
    }
}
Пример #2
0
G_MODULE_EXPORT int
test_viewport_main (int argc, char *argv[])
{
  ClutterTimeline  *timeline;
  ClutterAlpha     *alpha;
  ClutterBehaviour *r_behave;
  ClutterActor     *stage;
  ClutterActor     *hand;
  ClutterColor      stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
  gchar            *file;

  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();

  clutter_stage_set_color (CLUTTER_STAGE (stage),
		           &stage_color);

  /* Make a hand */
  file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
  hand = clutter_texture_new_from_file (file, NULL);
  if (!hand)
    g_error("Unable to load image '%s'", file);

  g_free (file);

  clutter_actor_set_position (hand, 300, 200);
  clutter_actor_set_clip (hand, 20, 21, 132, 170);
  clutter_actor_set_anchor_point (hand, 86, 125);
  clutter_actor_show (hand);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand);

  /* Make a timeline */
  timeline = clutter_timeline_new (7692);
  clutter_timeline_set_loop (timeline, TRUE);

  /* Set an alpha func to power behaviour */
  alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);

  /* Create a behaviour for that alpha */
  r_behave = clutter_behaviour_rotate_new (alpha,
					   CLUTTER_Z_AXIS,
					   CLUTTER_ROTATE_CW,
					   0.0, 360.0); 

  /* Apply it to our actor */
  clutter_behaviour_apply (r_behave, hand);

  /* start the timeline and thus the animations */
  clutter_timeline_start (timeline);

  clutter_actor_show_all (stage);

  clutter_main();

  g_object_unref (r_behave);

  return 0;
}
Пример #3
0
static VALUE
rbclt_behaviour_rotate_initialize (VALUE self, VALUE alpha,
                                   VALUE axis, VALUE direction,
                                   VALUE angle_start, VALUE angle_end)
{
  ClutterBehaviour *behaviour;

  behaviour = clutter_behaviour_rotate_new
    (RVAL2GOBJ (alpha),
     RVAL2GENUM (axis, CLUTTER_TYPE_ROTATE_AXIS),
     RVAL2GENUM (direction, CLUTTER_TYPE_ROTATE_DIRECTION),
     NUM2DBL (angle_start),
     NUM2DBL (angle_end));

  G_INITIALIZE (self, behaviour);

  return Qnil;
}
Пример #4
0
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;
}
Пример #5
0
int main(int argc,char *argv[])
{

  ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };

  clutter_init(&argc, &argv);

  ClutterActor *stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 521, 577);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  //ClutterActor * _group = clutter_group_new();
   _group = clutter_group_new();
  clutter_actor_set_position(_group, 0,0);
  clutter_container_add_actor(CLUTTER_CONTAINER(stage),_group);
  clutter_actor_show(_group);

  /** 加载棋盘图片*/
  ClutterActor* _board = clutter_texture_new_from_file("./wood/wood.png",NULL);

  clutter_actor_set_position(_board,0,0);
  //clutter_actor_set_rotation(_board, CLUTTER_Y_AXIS, 20,0,0,0);
  //clutter_actor_set_rotation(_board, CLUTTER_X_AXIS, 20,0,0,0);
  //clutter_actor_set_rotation(_board, CLUTTER_Z_AXIS, 20,0,0,0);


  //clutter_container_add_actor(CLUTTER_CONTAINER(stage),_board);
  clutter_container_add_actor(CLUTTER_CONTAINER(_group),_board);
  clutter_actor_show(_board);



#if 0
  load_chess();
#else 
  /** 加载棋子*/
  ClutterActor* _rking = clutter_texture_new_from_file("./wood/red_king.png",NULL);
  clutter_actor_set_position(_rking,235,8);
  clutter_container_add_actor(CLUTTER_CONTAINER(_group),_rking);
  clutter_actor_show(_rking);

  clutter_actor_set_reactive(_rking,TRUE);
  g_signal_connect(_rking, "button-press-event",G_CALLBACK(on_rking_button_press),NULL);

  timeline=clutter_timeline_new(3000);
  //g_signal_connect(timeline,"new-frame",G_CALLBACK(on_timeline_new_frame),_rking);
  clutter_timeline_set_loop(timeline,TRUE);

  ClutterAlpha* alpha_ = clutter_alpha_new_full(timeline,
         CLUTTER_EASE_IN_OUT_QUAD);//CLUTTER_EASE_IN_SINE);

  ClutterBehaviour* behaviour_ = clutter_behaviour_rotate_new(alpha_, 
		  CLUTTER_Y_AXIS,
		CLUTTER_ROTATE_CW,
		0,
		360);
  clutter_behaviour_rotate_set_center(CLUTTER_BEHAVIOUR_ROTATE(behaviour_), clutter_actor_get_width(_rking)/2,0,0);
  clutter_behaviour_apply(behaviour_, _rking);

  clutter_actor_set_rotation(_group, CLUTTER_X_AXIS, 40,2,600,0);
  //clutter_actor_set_rotation(_group, CLUTTER_Y_AXIS, 40,221,200,0);


#endif

  clutter_actor_show(stage);
  clutter_main();

  g_object_unref(timeline);

	printf("\n");
	return 0;
}
Пример #6
0
void
aisleriot_slot_renderer_set_animations (AisleriotSlotRenderer *srend,
                                        guint n_anims,
                                        const AisleriotAnimStart *anims,
                                        guint n_unexposed_animated_cards)
{
  AisleriotSlotRendererPrivate *priv;
  guint i;
  gint card_num;

  g_return_if_fail (AISLERIOT_IS_SLOT_RENDERER (srend));

  priv = srend->priv;

  g_return_if_fail (n_anims <= priv->slot->exposed);

  /* Destroy the current animations */
  for (i = 0; i < priv->animations->len; i++) {
    AnimationData *anim_data;

    anim_data = &g_array_index (priv->animations, AnimationData, i);

    if (anim_data->move)
      g_object_unref (anim_data->move);
    if (anim_data->rotate)
      g_object_unref (anim_data->rotate);
    if (anim_data->depth)
      g_object_unref (anim_data->depth);

    clutter_actor_destroy (anim_data->card_tex);
    g_object_unref (anim_data->card_tex);
  }

  g_array_set_size (priv->animations, 0);

  card_num = priv->slot->cards->len - n_anims;

  for (i = 0; i < n_anims; i++) {
    AnimationData anim_data;
    ClutterAlpha *alpha;
    ClutterKnot knots[2];
    Card card = CARD (priv->slot->cards->data[card_num]);
    guint card_width, card_height;

    memset (&anim_data, 0, sizeof (anim_data));

    anim_data.card_tex = aisleriot_card_new (priv->cache,
                                             anims[i].old_card,
                                             card);

    card_width = clutter_actor_get_width (anim_data.card_tex);
    card_height = clutter_actor_get_height (anim_data.card_tex);

    g_object_ref_sink (anim_data.card_tex);
    if (priv->animation_layer)
      clutter_container_add (priv->animation_layer,
                             CLUTTER_ACTOR (anim_data.card_tex), NULL);

    clutter_actor_set_position (anim_data.card_tex,
                                anims[i].cardx, anims[i].cardy);

    knots[0].x = anims[i].cardx;
    knots[0].y = anims[i].cardy;

    aisleriot_game_get_card_offset (priv->slot, card_num, FALSE,
                                    &knots[1].x, &knots[1].y);
    knots[1].x += priv->slot->rect.x;
    knots[1].y += priv->slot->rect.y;

    alpha = clutter_alpha_new_full (priv->timeline, CLUTTER_LINEAR);

    anim_data.move
      = clutter_behaviour_path_new_with_knots (alpha, knots,
                                               G_N_ELEMENTS (knots));
    clutter_behaviour_apply (anim_data.move, anim_data.card_tex);

    if (anims[i].old_card.value != card.value) {
      int center_x, center_y;

      center_x = card_width / 2;
      center_y = card_height / 2;

      clutter_actor_set_rotation (anim_data.card_tex, CLUTTER_Y_AXIS,
                                  180.0,
                                  center_x, center_y, 0);

      anim_data.rotate = clutter_behaviour_rotate_new (alpha,
                                                       CLUTTER_Y_AXIS,
                                                       CLUTTER_ROTATE_CW,
                                                       180.0, 0.0);
      clutter_behaviour_rotate_set_center (CLUTTER_BEHAVIOUR_ROTATE
                                           (anim_data.rotate),
                                           center_x, center_y, 0);

      clutter_behaviour_apply (anim_data.rotate, anim_data.card_tex);
    }

    if (anims[i].raise) {
      alpha = clutter_alpha_new_with_func (priv->timeline,
                                           aisleriot_slot_sine_animation_mode,
                                           NULL, NULL);

      anim_data.depth = clutter_behaviour_depth_new (alpha,
                                                     0, card_height);
      clutter_behaviour_apply (anim_data.depth, anim_data.card_tex);
    }

    g_array_append_val (priv->animations, anim_data);

    card_num++;
  }

  if (n_anims > 0) {
    clutter_timeline_rewind (priv->timeline);
    clutter_timeline_start (priv->timeline);
  }

  priv->n_unexposed_animated_cards = n_unexposed_animated_cards;

  clutter_actor_queue_redraw (CLUTTER_ACTOR (srend));
}
Пример #7
0
int
main (int argc, char *argv[])
{
  ClutterActor *stage;
  ClutterActor *rect;
  ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
  ClutterColor rect_color = { 0xee, 0x55, 0x55, 0x99 };
  ClutterColor progress_color = { 0x55, 0xee, 0x55, 0xbb };
  ClutterBehaviour *r_behaviour, *p_behaviour;
  const ClutterKnot knots[] = {
    {  75, 150 },
    { 400, 150 }
  };

  g_thread_init (NULL);
  clutter_threads_init ();
  clutter_init (&argc, &argv);

  stage = clutter_stage_get_default ();
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
  clutter_actor_set_size (stage, 600, 300);
  
  count_label = clutter_label_new_with_text ("Mono 12", "Counter");
  clutter_actor_set_position (count_label, 350, 50);

  help_label = clutter_label_new_with_text ("Mono 12", "Press 's' to start");
  clutter_actor_set_position (help_label, 50, 50);

  rect = clutter_rectangle_new_with_color (&rect_color);
  clutter_actor_set_position (rect, 75, 150);
  clutter_actor_set_size (rect, 50, 50);
  clutter_actor_set_anchor_point (rect, 25, 25);

  progress_rect = clutter_rectangle_new_with_color (&progress_color);
  clutter_actor_set_position (progress_rect, 50, 225);
  clutter_actor_set_size (progress_rect, 350, 50);

  clutter_container_add (CLUTTER_CONTAINER (stage),
                         count_label, help_label,
                         rect, progress_rect,
                         NULL);

  timeline = clutter_timeline_new (150, 50);
  clutter_timeline_set_loop (timeline, TRUE);
  r_behaviour = clutter_behaviour_rotate_new (clutter_alpha_new_full (timeline,
                                                                      CLUTTER_ALPHA_RAMP_INC,
                                                                      NULL, NULL),
                                              CLUTTER_Z_AXIS,
                                              CLUTTER_ROTATE_CW,
                                              0.0, 360.0);
  clutter_behaviour_apply (r_behaviour, rect);

  p_behaviour = clutter_behaviour_path_new (clutter_alpha_new_full (timeline,
                                                                    CLUTTER_ALPHA_SINE,
                                                                    NULL, NULL),
                                            knots,
                                            G_N_ELEMENTS (knots));
  clutter_behaviour_apply (p_behaviour, rect);

  g_signal_connect (stage,
                    "button-press-event", G_CALLBACK (clutter_main_quit),
                    NULL);
  g_signal_connect (stage,
                    "key-press-event", G_CALLBACK (on_key_press_event),
                    NULL);

  clutter_actor_show (stage);

  clutter_threads_enter ();
  clutter_main ();
  clutter_threads_leave ();

  g_object_unref (p_behaviour);
  g_object_unref (r_behaviour);
  g_object_unref (timeline);

  return EXIT_SUCCESS;
}