[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] how to create a cairo_matrix_t (defined by define-fo

From: Christian Kellermann
Subject: Re: [Chicken-users] how to create a cairo_matrix_t (defined by define-foreign-type) ?
Date: Tue, 17 Jan 2012 21:06:31 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

* Markus Klotzbuecher <address@hidden> [120115 18:02]:
> Is this branch available somewhere? I would prefer a correct but
> untested version to my wrong but coincidentally working one :-)

I am not sure yet what's best. What I am using now is this:

(define %fill-matrix
  (foreign-lambda* (c-pointer cairo_matrix_t)
                   ((f64vector v))
                   "cairo_matrix_t *m = malloc(sizeof(cairo_matrix_t));
                    int i=0;
                    m->xx = v[i++];
                    m->xy = v[i++];
                    m->yx = v[i++];
                    m->yx = v[i++];
                    m->x0 = v[i++];
                    m->y0 = v[i++];

(define (cairo-transform/matrix ctx v)
  (when (not (= (vector-length v) 6))
    (error "Vector size mismatch should be 6, is " (vector-length v)))
  (let ((m (%fill-matrix v)))
    (cairo-transform ctx m)
    (free m)))

(define new-matrix
  (foreign-lambda* cairo_matrix_t ()

There is still a freeing operation missing, I tend to use the
cairo-transform/matrix procedure most of the time though.

What do others think?

Who can (make) the muddy water (clear)? Let it be still, and it will
gradually become clear. Who can secure the condition of rest? Let
movement go on, and the condition of rest will gradually arise.
 -- Lao Tse. 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]