|
From: | Matt Welland |
Subject: | Re: [Chicken-users] How to use bezier function in 2d-primitives? |
Date: | Thu, 26 Oct 2017 08:47:41 -0700 |
On Tue, 24 Oct 2017 22:15:47 -0700 Matt WellandLooks like the 2d-primitives egg has a bug indeed! I’ll open a ticket.
<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
> -=-
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)))))))
[Prev in Thread] | Current Thread | [Next in Thread] |