Beispiel #1
0
static void clutter_widget_paint ( ClutterActor *_self ) {
    ClutterGeometry geom;
    ClutterWidgetPrivate *priv;
    int borderWidth = 1;

    priv = CLUTTER_WIDGET_GET_PRIVATE (_self);
    clutter_actor_get_geometry (_self, &geom);

    cogl_push_matrix ();
        cogl_path_round_rectangle ( -borderWidth, -borderWidth, 
                                    geom.width + borderWidth, geom.height + borderWidth, 
                                    5, 1 );
        cogl_set_source_color4ub ( priv->borderColor.red, 
                                   priv->borderColor.green, 
                                   priv->borderColor.blue, 
                                   priv->borderColor.alpha );
        cogl_path_fill ();

        cogl_path_round_rectangle ( 0, 0, geom.width, geom.height, 5, 1 );
        cogl_set_source_color4ub ( 0xcf, 0xcf, 0xcf, 0xff );
        cogl_path_fill ();
    cogl_pop_matrix();

    // call the parent paint
    CLUTTER_ACTOR_CLASS (clutter_widget_parent_class)->paint (_self);
}
Beispiel #2
0
static void
circle_paint_cb (ClutterActor *actor)
{
  const CoglColor fill_color = { 0xff, 0xff, 0xff, 0x80 };
  gint i;
  gdouble angle;
  guint radius = clutter_actor_get_width (actor) / 2;

  cogl_set_source_color (&fill_color);

  angle = *((gdouble *)g_object_get_data (G_OBJECT (actor), "angle"));
  for (i = 0; i < CIRCLE_S; i++, angle += (2.0 * G_PI) / (gdouble) CIRCLE_S)
    {
      gdouble angle2 = angle + ((2.0 * G_PI) / (gdouble)CIRCLE_S) / 2.0;
      cogl_path_move_to (((radius - CIRCLE_W) * cos (angle)) + radius,
                         ((radius - CIRCLE_W) * sin (angle)) + radius);
      cogl_path_arc (radius, radius, radius, radius,
                     CLUTTER_ANGLE_FROM_RAD (angle),
                     CLUTTER_ANGLE_FROM_RAD (angle2));
      cogl_path_line_to (((radius - CIRCLE_W) * cos (angle2)) + radius,
                         ((radius - CIRCLE_W) * sin (angle2)) + radius);
      cogl_path_arc (radius, radius, radius - CIRCLE_W, radius - CIRCLE_W,
                     CLUTTER_ANGLE_FROM_RAD (angle2),
                     CLUTTER_ANGLE_FROM_RAD (angle));
      cogl_path_close ();
      cogl_path_fill ();
    }
}
Beispiel #3
0
static void
st_polygon_pick (ClutterActor       *self,
                 const ClutterColor *pick_color)
{
    CoglPath *selection_path;
    gfloat coords[8];
    StPolygon *area = ST_POLYGON (self);
    StPolygonPrivate *priv = area->priv;

    if (!clutter_actor_should_pick_paint (self))
        return;

    coords[0] = priv->ulc_x;
    coords[1] = priv->ulc_y;
    coords[2] = priv->llc_x;
    coords[3] = priv->llc_y;
    coords[4] = priv->lrc_x;
    coords[5] = priv->lrc_y;
    coords[6] = priv->urc_x;
    coords[7] = priv->urc_y;

    cogl_set_source_color4ub (pick_color->red,
                              pick_color->green,
                              pick_color->blue,
                              pick_color->alpha);

    selection_path = cogl_path_new();
    cogl_path_polygon (selection_path, (float *)coords, 4);
    cogl_path_fill (selection_path);
    cogl_object_unref (selection_path);
}
Beispiel #4
0
static void
st_polygon_paint (ClutterActor *self)
{

    StPolygon *area = ST_POLYGON (self);
    StPolygonPrivate *priv = area->priv;
    if (priv->debug) {
        gfloat coords[8];
        CoglPath *selection_path;

        cogl_set_source_color4f (.50,
                                 .50,
                                 .50,
                                 .50);

        coords[0] = priv->ulc_x;
        coords[1] = priv->ulc_y;
        coords[2] = priv->llc_x;
        coords[3] = priv->llc_y;
        coords[4] = priv->lrc_x;
        coords[5] = priv->lrc_y;
        coords[6] = priv->urc_x;
        coords[7] = priv->urc_y;

        selection_path = cogl_path_new();
        cogl_path_polygon (selection_path, (float *)coords, 4);
        cogl_path_fill (selection_path);
        cogl_object_unref (selection_path);
    }
}
Beispiel #5
0
static VALUE
rb_cogl_path_fill (VALUE self)
{
  cogl_path_fill ();

  return Qnil;
}
static void
paint_circle (ClutterActor *actor)
{
  gfloat radius = MIN (clutter_actor_get_width (actor),
                       clutter_actor_get_height (actor)) / 2.f;
  cogl_set_source_color4ub (0xff, 0xff, 0xff, 0xff);
  cogl_path_arc (radius, radius, radius, radius, 0, 360);
  cogl_path_fill ();
}
static void
test_coglbox_paint(ClutterActor *self)
{
  TestCoglboxPrivate *priv;
  
  ClutterColor cfill;
  ClutterColor cstroke;
  
  static GTimer *timer = NULL;
  static gint paint_index = 0;
  
  gint NUM_PAINT_FUNCS;
 
  NUM_PAINT_FUNCS = G_N_ELEMENTS (paint_func);
  
  priv = TEST_COGLBOX_GET_PRIVATE (self);
  
  
  if (!timer)
    {
      timer = g_timer_new ();
      g_timer_start (timer);
    }
  
  if (g_timer_elapsed (timer, NULL) >= 1)
    {
      paint_index += 1;
      paint_index = paint_index % NUM_PAINT_FUNCS;
      g_timer_start (timer);
    }
  
  cfill.red    = 0;
  cfill.green  = 160;
  cfill.blue   = 0;
  cfill.alpha  = 255;
  
  cstroke.red    = 200;
  cstroke.green  = 0;
  cstroke.blue   = 0;
  cstroke.alpha  = 255;
  
  cogl_push_matrix ();
  
  paint_func[paint_index] ();
  
  cogl_translate (100,100,0);
  cogl_color (&cstroke);
  cogl_path_stroke ();
  
  cogl_translate (150,0,0);
  cogl_color (&cfill);
  cogl_path_fill ();
  
  cogl_pop_matrix();

}
static void
paint_triangle (ClutterActor *actor)
{
  gfloat width, height;

  clutter_actor_get_size (actor, &width, &height);
  cogl_set_source_color4ub (0xff, 0xff, 0xff, 0xff);

  cogl_path_move_to (width/2, 0);
  cogl_path_line_to (width, height);
  cogl_path_line_to (0, height);
  cogl_path_close ();
  cogl_path_fill ();
}
static void
pick (ClutterActor *self,
    const ClutterColor *color)
{
  ChamplainPointPrivate *priv = GET_PRIVATE (self);
  gdouble radius = priv->size / 2.0;

  cogl_path_new ();

  cogl_set_source_color4ub (color->red,
      color->green,
      color->blue,
      color->alpha);

  cogl_path_move_to (radius, radius);
  cogl_path_arc (radius, radius, radius, radius, 0, 360.0);
  cogl_path_close ();
  cogl_path_fill ();
}
Beispiel #10
0
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();
}
void
_cogl_pango_display_list_render (CoglPangoDisplayList *dl,
                                 const CoglColor *color)
{
  GSList *l;

  for (l = dl->nodes; l; l = l->next)
    {
      CoglPangoDisplayListNode *node = l->data;
      CoglColor draw_color;

      if (node->pipeline == NULL)
        {
          if (node->type == COGL_PANGO_DISPLAY_LIST_TEXTURE)
            node->pipeline =
              _cogl_pango_pipeline_cache_get (dl->pipeline_cache,
                                              node->d.texture.texture);
          else
            node->pipeline =
              _cogl_pango_pipeline_cache_get (dl->pipeline_cache,
                                              NULL);
        }

      if (node->color_override)
        /* Use the override color but preserve the alpha from the
           draw color */
        cogl_color_init_from_4ub (&draw_color,
                                  cogl_color_get_red_byte (&node->color),
                                  cogl_color_get_green_byte (&node->color),
                                  cogl_color_get_blue_byte (&node->color),
                                  cogl_color_get_alpha_byte (color));
      else
        draw_color = *color;
      cogl_color_premultiply (&draw_color);

      cogl_pipeline_set_color (node->pipeline, &draw_color);
      cogl_push_source (node->pipeline);

      switch (node->type)
        {
        case COGL_PANGO_DISPLAY_LIST_TEXTURE:
          _cogl_pango_display_list_render_texture (node);
          break;

        case COGL_PANGO_DISPLAY_LIST_RECTANGLE:
          cogl_rectangle (node->d.rectangle.x_1,
                          node->d.rectangle.y_1,
                          node->d.rectangle.x_2,
                          node->d.rectangle.y_2);
          break;

        case COGL_PANGO_DISPLAY_LIST_TRAPEZOID:
          {
            float points[8];
            CoglPath *path;

            points[0] =  node->d.trapezoid.x_11;
            points[1] =  node->d.trapezoid.y_1;
            points[2] =  node->d.trapezoid.x_12;
            points[3] =  node->d.trapezoid.y_2;
            points[4] =  node->d.trapezoid.x_22;
            points[5] =  node->d.trapezoid.y_2;
            points[6] =  node->d.trapezoid.x_21;
            points[7] =  node->d.trapezoid.y_1;

            path = cogl_path_new ();
            cogl_path_polygon (path, points, 4);
            cogl_path_fill (path);
            cogl_object_unref (path);
          }
          break;
        }

      cogl_pop_source ();
    }
}