user2063321
user2063321

Reputation:

Draw and position many png files in Cairo

My program runs a physics engine with a bunch of interacting circles, and I'm trying to draw an asteroid png image over each circle.

I understand you can make a surface from a png file from this:

cairo_surface_t *image = cairo_image_surface_create_from_png ("image.png");

I'm trying to figure out how I would go about scaling and drawing the png file to the right dimension? From what I understand of the API I think I might need to call cairo_image_surface_get_data (), but I don't know what to do with it. Thanks.

Upvotes: 0

Views: 2242

Answers (1)

drahnr
drahnr

Reputation: 6886

Generally you will need to invest some time reading the cairo API docs, e.g. for scaling you either use cairo_scale or cairo_transform read on

So after you did setup your view matrix with the above functions, all you have to do is a

cairo_set_source_surface (cr, surface, x, y);
cairo_paint (cr);

(freely taken from http://zetcode.com/gfx/cairo/cairoimages/)

Upvotes: 1

Related Questions