[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cairo
Subject:    Re: [cairo] Drawing/filling image as a pattern
From:       Ravindra <rkumar () novell ! com>
Date:       2004-03-25 16:09:29
Message-ID: 1080230249.2172.444.camel () ravi
[Download RAW message or body]

On Fri, 2004-03-19 at 21:47, Ravindra wrote:
> Hello,
>  I want to use an Image as a pattern when I draw/fill any figure using
> Cairo. Unfortunately, I'm getting no clues how to get it done :-(. The
> image might also need to be flipped along X or Y axis or both depending
> on the requirement. I'm trying to implement the functionality of texture
> brush of MS GDI+.

So finally, I was able to do it with some help from Pippin on IRC.

Following can be used to draw an image over a surface,

// start
pattern = cairo_surface_create_for_image (...);
cairo_surface_set_matrix (pattern, matrix);
cairo_surface_set_repeat (pattern, 1);
cairo_set_pattern (ct, pattern);
cairo_surface_destroy (pattern);
// end

Following can be used to flip the image along X-axis,

// start
pattern = cairo_surface_create_for_image (...);
cairo_matrix_translate (matrix, width, 0);
/* scale in -X direction to flip along X */
cairo_matrix_scale (matrix, -1.0, 1.0);
cairo_surface_set_matrix (pattern, matrix);
cairo_show_surface (ct, pattern, width, height);
cairo_surface_destroy (pattern);
// end

Thanks for all the help!

Regards,
Ravindra



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic