Re: [Gimp-user] gimp-drawable-curves-spline




On 24 feb 2016, at 16:59, Simon Budig <simon budig de> wrote:

Maurizio Loreti (maurizio loreti gmail com) wrote:
    (let* ((a (cons-array 8 'byte)))

Just changing the procedure name in the last line to
gimp-drawable-curves-spline is not enough.  If I understand correctly,
the program allocates an array of 8 bytes where 8 integer values (0,0;
63,60; 191,194; 155.255) are stored.

To be more specific: the program allocates an 8 entry array, where each
entry contains a byte.

The memory to be allocated
should be adequate for 8 floating point values (8 * 32 bytes?), and
the values stored there.  Is set-pt adequate?  Or intended for integer
values only?  May somebody help me?

Allocate an array with 8 entries where each entry contains a
"double"-float-value:

(cons-array 8 'double)

You might need to change the scale of the values in there - instead from
0 to 255 they might be normalized to 0.0 to 1.0.

It works indeed; the new code is the following:

    (define (spline)
      (let* ((a (cons-array 8 'double)))
    (set-pt a 0 0.0 0.0)
    (set-pt a 1 0.24706 0.23529)
    (set-pt a 2 0.74902 0.76078)
    (set-pt a 3 1.0 1.0)
    a))
    (define (set-pt a index x y)
    (prog1
    (aset a (* index 2) x)
    (aset a (+ (* index 2) 1) y)))
    (gimp-drawable-curves-spline inDrw 0 8 (spline))

    (gimp-image-undo-group-end inImg)
    (gimp-displays-flush)
    )
 
Thank you for the quick answer, and thank you all for working on such a wonderful program as GIMP.

-- 
Maurizio Loreti   -   Maurizio Loreti gmail com








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