chicken-users
[Top][All Lists]
Advanced

[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: Markus Klotzbuecher
Subject: Re: [Chicken-users] how to create a cairo_matrix_t (defined by define-foreign-type) ?
Date: Wed, 9 May 2012 17:20:20 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Christian,

On Thu, Feb 02, 2012 at 10:06:07PM +0100, Markus Klotzbuecher wrote:
> Hi Christian,
> 
> On Fri, Jan 27, 2012 at 11:44:55AM +0100, Christian Kellermann wrote:
> > Hi all fans of cairo bindings,
> > 
> > * Christian Kellermann <address@hidden> [120117 21:06]:
> > > * 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++];
> > >                     C_return(m);"))
> > > 
> > > (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 ()
> > >     "C_return(malloc(sizeof(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?
> > 
> > Markus did you have a chance to have a look at the code? I would
> > love to release a new cairo version. If there are any missing
> > features on your wishlist, please let me know!
> 
> The new-matrix works fine for me. (I only need to store the current
> ctx, before I temporarily set it to the identity matrix for writing
> something in device space).
> 
> I tried to test cairo-transform/matrix using csi too, but I get the
> following error:
> 
> #;1> (use cairo)
> ; loading /usr/local/lib/chicken/6/cairo.import.so ...
> ; loading /usr/local/lib/chicken/6/srfi-1.import.so ...
> ; loading /usr/local/lib/chicken/6/srfi-4.import.so ...
> ; loading /usr/local/lib/chicken/6/srfi-13.import.so ...
> ; loading /usr/local/lib/chicken/6/lolevel.import.so ...
> ; loading /usr/local/lib/chicken/6/cairo.so ...
> #;2> (define m (new-matrix))
> #;3> (cairo-transform/matrix m (make-f64vector 6 1))
> 
> Error: (vector-length) bad argument type: #f64(1.0 1.0 1.0 1.0 1.0 1.0)
> 
>       Call history:
> 
>       <syntax>          (cairo-transform/matrix m (make-f64vector 6 1))
>       <syntax>          (make-f64vector 6 1)
>       <eval>              (cairo-transform/matrix m (make-f64vector 6 1))
>       <eval>    (make-f64vector 6 1)  <--
> #;3> 
> 
> Should the two "vector-length" be "f64vector-length" or am I missing
> something?

Any plans to merge this patch?

Best regards
Markus



reply via email to

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