[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] How to use bezier function in 2d-primitives?
From: |
Kooda |
Subject: |
Re: [Chicken-users] How to use bezier function in 2d-primitives? |
Date: |
Thu, 26 Oct 2017 01:32:49 +0200 |
On Tue, 24 Oct 2017 22:15:47 -0700 Matt Welland
<address@hidden> wrote:
> I tried this:
>
> (use 2d-primitives)
> (with-output-to-file "test.csv"
> (lambda ()
> (for-each
> (lambda (v)
> (print (f32vector-ref v 0)","(f32vector-ref v 1)))
> (bezier->vects (bezier:create (vect:create 0 0)(vect:create 2
> 5)(vect:create 7 5)(vect:create 10 0) 10))))
>
> Then load test.csv into gnumeric and graph it and I see two straight
> line segments. Either I'm not correctly understanding how to use
> bezier or there is a bug.
>
> Thanks,
>
> Matt
> -=-
Looks like the 2d-primitives egg has a bug indeed! I’ll open a ticket.
Here is a version of bezier->vects that does what you expect. I hope
this will help!
(define (bezier->vects* b n)
(let ((increment (/ 1 n)))
(let loop ((step 0))
(if (>= step 1)
(list (bezier:ref b 1))
(cons (bezier:ref b step)
(loop (+ step increment)))))))