예제 #1
0
static gdouble
aisleriot_slot_sine_animation_mode (ClutterAlpha *alpha,
                                    gpointer data)
{
  ClutterTimeline *tl = clutter_alpha_get_timeline (alpha);

  return sin (clutter_timeline_get_progress (tl) * G_PI);
}
예제 #2
0
파일: test-script.c 프로젝트: rib/clutter
gdouble
sine_alpha (ClutterAlpha *alpha,
            gpointer      dummy G_GNUC_UNUSED)
{
  ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);

  return sin (clutter_timeline_get_progress (timeline) * G_PI);
}
예제 #3
0
static gdouble
my_sine_wave (ClutterAlpha *alpha,
              gpointer      dummy G_GNUC_UNUSED)
{
    ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
    gdouble progress = clutter_timeline_get_progress (timeline);

    return sin (progress * G_PI);
}
예제 #4
0
/* This must return a value between 0 and 1.0
 *
 * This will be called as many times per seconds as specified in our call to clutter_timeline_new().
 *
 */
gdouble
on_alpha (ClutterAlpha *alpha, gpointer data G_GNUC_UNUSED)
{
  /* Get the position in the timeline,
   *  so we can base our value upon it:
   */
  ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
  return clutter_timeline_get_progress (timeline);
}
예제 #5
0
파일: mx-expander.c 프로젝트: 3v1n0/mx
static void
new_frame (ClutterTimeline *timeline,
           gint             frame_num,
           ClutterActor    *expander)
{
  MxExpanderPrivate *priv = MX_EXPANDER (expander)->priv;

  priv->progress = clutter_timeline_get_progress (priv->timeline);

  clutter_actor_queue_relayout (expander);
}
예제 #6
0
파일: test-script.c 프로젝트: rib/clutter
gdouble
double_ramp_alpha (ClutterAlpha *alpha,
                   gpointer      dummy G_GNUC_UNUSED)
{
  ClutterTimeline *timeline = clutter_alpha_get_timeline (alpha);
  gdouble progress = clutter_timeline_get_progress (timeline);

  if (progress >= 0.5)
    return 1.0 - progress;

  return progress;
}
void
st_theme_node_transition_paint (StThemeNodeTransition *transition,
                                ClutterActorBox       *allocation,
                                guint8                 paint_opacity)
{
  StThemeNodeTransitionPrivate *priv = transition->priv;

  CoglColor constant;
  float tex_coords[] = {
    0.0, 0.0, 1.0, 1.0,
    0.0, 0.0, 1.0, 1.0,
  };

  g_return_if_fail (ST_IS_THEME_NODE (priv->old_theme_node));
  g_return_if_fail (ST_IS_THEME_NODE (priv->new_theme_node));

  if (!clutter_actor_box_equal (allocation, &priv->last_allocation))
    priv->needs_setup = TRUE;

  if (priv->needs_setup)
    {
      priv->last_allocation = *allocation;

      calculate_offscreen_box (transition, allocation);
      priv->needs_setup = !setup_framebuffers (transition, allocation);

      if (priv->needs_setup) /* setting up framebuffers failed */
        return;
    }

  cogl_color_set_from_4f (&constant, 0., 0., 0.,
                          clutter_timeline_get_progress (priv->timeline));
  cogl_material_set_layer_combine_constant (priv->material, 1, &constant);

  cogl_material_set_color4ub (priv->material,
                              paint_opacity, paint_opacity,
                              paint_opacity, paint_opacity);

  cogl_set_source (priv->material);
  cogl_rectangle_with_multitexture_coords (priv->offscreen_box.x1,
                                           priv->offscreen_box.y1,
                                           priv->offscreen_box.x2,
                                           priv->offscreen_box.y2,
                                           tex_coords, 8);
}
예제 #8
0
파일: proto.c 프로젝트: aalex/tempi
static void
paint_cb (ClutterActor *self, ClutterTimeline *tl)
{
  gint paint_index = (clutter_timeline_get_progress (tl)
                      * G_N_ELEMENTS (paint_func));

  cogl_push_matrix ();

  paint_func[paint_index] ();

  cogl_translate (100, 100, 0);
  cogl_set_source_color4ub (0, 160, 0, 255);
  cogl_path_stroke_preserve ();

  cogl_translate (150, 0, 0);
  cogl_set_source_color4ub (200, 0, 0, 255);
  cogl_path_fill ();

  cogl_pop_matrix();
}
/* Timeline handler */
void
frame_cb (ClutterTimeline *timeline,
	  gint             msecs,
	  gpointer         data)
{
  double rotation = clutter_timeline_get_progress (timeline) * 360.0;
  gint i;

  if (!do_rotate)
    return;

  /* Rotate everything clockwise about stage center */
  clutter_actor_set_rotation_angle (group, CLUTTER_Z_AXIS, rotation);

  for (i = 0; i < nwidgets; i++)
    {
      clutter_actor_set_rotation_angle (widgets[i], CLUTTER_Z_AXIS, - 2 * rotation);
      clutter_actor_set_opacity (widgets[i], 50 * sin (2 * M_PI * rotation / 360) + (255 - 50));
    }
}
예제 #10
0
/* Timeline handler */
static void
frame_cb (ClutterTimeline *timeline, 
	  gint             msecs,
	  gpointer         data)
{
  SuperOH        *oh = (SuperOH *)data;
  gint            i;
  guint           rotation = clutter_timeline_get_progress (timeline) * 360.0f;

  /* Rotate everything clockwise about stage center*/
  clutter_actor_set_rotation_angle (oh->group, CLUTTER_Z_AXIS, rotation);

  for (i = 0; i < NHANDS; i++)
    {
      /* rotate each hand around there centers */
      clutter_actor_set_rotation_angle (oh->hand[i],
                                        CLUTTER_Z_AXIS,
                                        - 6.0 * rotation);
      if (fade == TRUE)
        clutter_actor_set_opacity (oh->hand[i], (255 - (rotation % 255)));
    }
}
예제 #11
0
파일: mx-adjustment.c 프로젝트: 3v1n0/mx
static void
interpolation_new_frame_cb (ClutterTimeline *timeline,
                            guint            msecs,
                            MxAdjustment    *adjustment)
{
  gdouble new_value;
  MxAdjustmentPrivate *priv = adjustment->priv;

  new_value = priv->old_position +
    (priv->new_position - priv->old_position) *
    clutter_timeline_get_progress (priv->interpolation);

  priv->interpolation = NULL;
  mx_adjustment_set_value (adjustment, new_value);
  priv->interpolation = timeline;

  /* Stop the interpolation if we've reached the end of the adjustment */
  if (!priv->elastic && priv->clamp_value &&
      ((new_value < priv->lower) ||
       (new_value > (priv->upper - priv->page_size))))
    stop_interpolation (adjustment);
}
예제 #12
0
static void
on_deceleration_new_frame (ClutterTimeline     *timeline,
                           gint                 elapsed_time,
                           ClutterPanAction    *self)
{
  ClutterPanActionPrivate *priv = self->priv;
  ClutterActor *actor;
  gdouble progress;
  gfloat interpolated_x, interpolated_y;

  progress = clutter_timeline_get_progress (timeline);

  interpolated_x = priv->target_x * progress;
  interpolated_y = priv->target_y * progress;
  priv->dx = interpolated_x - priv->interpolated_x;
  priv->dy = interpolated_y - priv->interpolated_y;
  priv->interpolated_x = interpolated_x;
  priv->interpolated_y = interpolated_y;

  actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (self));
  emit_pan (self, actor, TRUE);
}
예제 #13
0
static void
frame_cb (ClutterTimeline *timeline,
          gint             elapsed_msecs,
          TestState       *state)
{
  guint x, y;
  float period_progress = clutter_timeline_get_progress (timeline);
  float period_progress_sin = sinf (period_progress);
  float wave_shift = period_progress * WAVE_SPEED;
  float ripple_shift = period_progress * RIPPLE_SPEED;

  for (y = 0; y <= MESH_HEIGHT; y++)
    for (x = 0; x <= MESH_WIDTH; x++)
      {
        guint    vert_index = (MESH_WIDTH + 1) * y + x;
        float   *vert = &state->quad_mesh_verts[3 * vert_index];

        float    real_x = x * QUAD_WIDTH;
        float    real_y = y * QUAD_HEIGHT;

        float    wave_offset = (float)x / (MESH_WIDTH + 1);
        float    wave_angle =
                    (WAVE_PERIODS * 2 * G_PI * wave_offset) + wave_shift;
        float    wave_sin = sinf (wave_angle);

        float    a_sqr = (RIPPLE_CENTER_X - real_x) * (RIPPLE_CENTER_X - real_x);
        float    b_sqr = (RIPPLE_CENTER_Y - real_y) * (RIPPLE_CENTER_Y - real_y);
        float    ripple_offset = sqrtf (a_sqr + b_sqr) / RIPPLE_RADIUS;
        float    ripple_angle =
                    (RIPPLE_PERIODS * 2 * G_PI * ripple_offset) + ripple_shift;
        float    ripple_sin = sinf (ripple_angle);

        float    h, s, l;
        guint8  *color;

        vert[2] = (wave_sin * WAVE_DEPTH) + (ripple_sin * RIPPLE_DEPTH);

        /* Burn some CPU time picking a pretty color... */
        h = (HSL_OFFSET
             + wave_sin
             + ripple_sin
             + period_progress_sin) * HSL_SCALE;
        s = 0.5;
        l = 0.25 + (period_progress_sin + 1.0) / 4.0;
        color = &state->quad_mesh_colors[4 * vert_index];
        /* A bit of a sneaky cast, but it seems safe to assume the ClutterColor
         * typedef is set in stone... */
        clutter_color_from_hls ((ClutterColor *)color, h * 360.0, l, s);

        color[0] = (color[0] * color[3] + 128) / 255;
        color[1] = (color[1] * color[3] + 128) / 255;
        color[2] = (color[2] * color[3] + 128) / 255;
      }

  cogl_vertex_buffer_add (state->buffer,
                          "gl_Vertex",
                          3, /* n components */
                          COGL_ATTRIBUTE_TYPE_FLOAT,
                          FALSE, /* normalized */
                          0, /* stride */
                          state->quad_mesh_verts);
  cogl_vertex_buffer_add (state->buffer,
                          "gl_Color",
                          4, /* n components */
                          COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE,
                          FALSE, /* normalized */
                          0, /* stride */
                          state->quad_mesh_colors);

  cogl_vertex_buffer_submit (state->buffer);

  clutter_actor_set_rotation (state->dummy,
                              CLUTTER_Z_AXIS,
                              360 * period_progress,
                              (MESH_WIDTH * QUAD_WIDTH) / 2,
                              (MESH_HEIGHT * QUAD_HEIGHT) / 2,
                              0);
  clutter_actor_set_rotation (state->dummy,
                              CLUTTER_X_AXIS,
                              360 * period_progress,
                              (MESH_WIDTH * QUAD_WIDTH) / 2,
                              (MESH_HEIGHT * QUAD_HEIGHT) / 2,
                              0);
}