Thread: Move an object in cairo

  1. #1
    Registered User
    Join Date
    Jan 2016

    Move an object in cairo

    Hey guys,

    I need to use Cairo for my college C project. My project consists in simulate Brownian movement and so I need to have lots of circles moving. But as this is very simple on other frameworks I've worked with (SDL, pygame), I do not understand how it's done in Cairo.

    Here is my problem: I use
    cairo_translate(cr, x, y)
    to "move" my object within the drawing area. But as such, the referential for the other circles changes. I want to be able to change every circle independently from (0, 0) beign the upper left corner of the drawing area.

        /* creates big ball */
        cairo_set_line_width(cr, 5);
        cairo_set_source_rgb(cr, 0, 0, 0);
        cairo_arc(cr, balls_MAP[0].x, balls_MAP[0].y, CONF.big_rad, 0, 2 * M_PI);
        cairo_set_source_rgb(cr, 0.9, 0.9, 0.9);
        /* creates other balls */
        int i;
        cairo_set_source_rgb(cr, 0, 0, 0);
        for(i = 1; i < numOfBalls; i++) {
            cairo_arc(cr, balls_MAP[i].x, balls_MAP[i].y, CONF.small_rad, 0, 2 * M_PI);
    At the moment all the circles are still. Thanks.

  2. #2
    Make Fortran great again
    Join Date
    Sep 2009
    Have you looked at the animation examples here: Examples ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CAIRO - error when converting txt to pdf
    By leonardoadoado in forum C++ Programming
    Replies: 17
    Last Post: 12-05-2012, 01:38 PM
  2. cairo-dock issue
    By Annonymous in forum Linux Programming
    Replies: 2
    Last Post: 06-03-2012, 12:14 AM
  3. Using image as a mask in cairo (a c library)
    By javaeyes in forum C Programming
    Replies: 3
    Last Post: 03-21-2012, 05:09 AM
  4. cairo, rasterizing text
    By javaeyes in forum C Programming
    Replies: 1
    Last Post: 03-06-2012, 08:51 PM
  5. Cairo and GTK, still need a pixmap?
    By TriKri in forum Linux Programming
    Replies: 0
    Last Post: 03-18-2008, 04:18 PM

Tags for this Thread