How can I draw image with rounded corners in Cairo/Gtk? -


how can draw image rounded corners in cairo/gtk? in language.

ok, it's realy simple. here vala code:

private void draw_rounded_path(context ctx, double x, double y,     double width, double height, double radius) {      double degrees = m_pi / 180.0;      ctx.new_sub_path();     ctx.arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);     ctx.arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);     ctx.arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);     ctx.arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees);     ctx.close_path(); } 

and example of expose_event:

public override bool expose_event(gdk.eventexpose event) {     //base.expose_event(event);     context ctx = gdk.cairo_create(this.window);      draw_rounded_path(ctx, allocation.x, allocation.y, allocation.width,         allocation.height, 5);      if(pixbuf != null) {         gdk.cairo_set_source_pixbuf(ctx, pixbuf, allocation.x, allocation.y);         ctx.clip();     }      ctx.paint();     return false; } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -