It is currently Sun Jul 21, 2024 12:23 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 8:08 pm  (#1) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Does anyone know a script where the curves command has been used as Iam having trouble with (curves-explicit) or (curves-spline).
e.g. ;(gimp-curves-spline layer 0 16 (0 0 63 73 95 125 127 31 156 188 191 151 223 227 255 255)) without the ()around the control points wilbur says 19 arguments instead of 4 with the () wilbur says incorect syntax.
Yep iv'e tried everything but no go, Wilbur is being difficult.

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 8:18 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
Not sure if this is correct syntax but it comes from the urbin acid script here
http://www.aljacom.com/~gimp/Urban_Acid_2.6.scm
       (define (splineValue)
          (let* ((a (cons-array 10 'byte)))
            (set-pt a 0 0 0)
            (set-pt a 1 44 27)
            (set-pt a 2 99 117)
            (set-pt a 3 195 229)
            (set-pt a 4 255 255)
            a
          )
       )
       (gimp-curves-spline copy-layer VALUE-LUT 10 (splineValue))

       (define (splineRed)
          (let* ((a (cons-array 10 'byte)))
            (set-pt a 0 0 0)
            (set-pt a 1 51 6)
            (set-pt a 2 151 137)
            (set-pt a 3 204 228)
            (set-pt a 4 255 255)
            a
          )
       )
       (gimp-curves-spline copy-layer RED-LUT 10 (splineRed))

       (define (splineGreen)
          (let* ((a (cons-array 10 'byte)))
            (set-pt a 0 0 0)
            (set-pt a 1 38 31)
            (set-pt a 2 125 129)
            (set-pt a 3 197 223)
            (set-pt a 4 255 255)
            a
          )
       )
       (gimp-curves-spline copy-layer GREEN-LUT 10 (splineGreen))

       (define (splineBLue)
          (let* ((a (cons-array 8 'byte)))
            (set-pt a 0 0 0)
            (set-pt a 1 22 33)
            (set-pt a 2 149 126)
            (set-pt a 4 255 255)
            a
          )
       )
       (gimp-curves-spline copy-layer BLUE-LUT 8 (splineRed))


But it is also written like this in another script
http://snipplr.com/view/21978/gimp-scri ... ephotoscm/
   (gimp-curves-spline theDrawable 0 8 #(0 0 55 27 176 197 255 255))


Perhaps it is the addition of the hash mark?

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 8:28 pm  (#3) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
Or perhaps this will help.
http://code.google.com/p/paynekj-gimp-s ... curves.scm

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 8:53 pm  (#4) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
In addition to what Rod posted, from the Script-Fu Procedure Browser..

Image

The 3rd argument specifies the number of integer values in the 4th argument (which is an integer array).

For example, a 4 element integer array: #(int1 int2 int3 int4)

Or you can define and initialize the array, as shown in the first example Rod posted.

The only difference in syntax is that gimp-curves-explicit always uses 256 as the value of the 3rd argument.

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 9:06 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
Wow
So is value = red,green,blue, and alpha channels combined.
and RGB = just red green and blue without alpha?

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: syntax for curves in script-fu(solved)
PostPosted: Fri Sep 23, 2011 10:53 pm  (#6) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
Got it with this

(define (splineValue)
(let* (
(cp.1 0 0)
(cp.2 38 31)
(cp.3 125 129)
(cp.4 197 223)
(cp.5 255 255)
(cp.6 255 255)
(cp.7 255 255)
(cp.8 255 255))
(gimp-curves-spline inner-bevel-layer 0 16 (splineValue))
)
)
Thanks to all as getting the right syntax was driving me MAD


_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 11:12 pm  (#7) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14715
Location: USA
Cool! so what are you working on now? :)

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: syntax for curves in script-fu(solved)
PostPosted: Sat Sep 24, 2011 12:29 am  (#8) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Graechan wrote:
Got it with this

   (define (splineValue)
          (let* (
            (cp.1 0 0)
            (cp.2 38 31)
            (cp.3 125 129)
            (cp.4 197 223)
            (cp.5 255 255)
            (cp.6 255 255)
            (cp.7 255 255)
            (cp.8 255 255))
       (gimp-curves-spline inner-bevel-layer 0 16 (splineValue))
          )
       )

Thanks to all as getting the right syntax was driving me MAD

No, what you've presented will not work. You have defined a procedure which calls itself and will loop forever. I think you have misplaced a parenthesis.

The gimp-curves-* procedures expect the last argument to be a Scheme 'vector', which in some other programming languages might be called an 'array'. A 'vector' is very similar to a Scheme 'list' but has some important differences (e.g., you can't take a 'car' or a 'cdr' of a vector and you can't use 'map' or 'apply' on them).

The methods of specifying the gimp-curves vector that have been presented so far in this thread are overly complicated at best, and might not work depending upon the user's setup.

There are two simple ways of creating a 'vector' suitable for use in the gimp-curves-* filters. The first is to use the #(...) form to generate a constant vector.

(gimp-curves-spline drawable HISTOGRAM-VALUE 4 #(0 255 255 0))
(gimp-curves-explicit drawable
                      HISTOGRAM-VALUE
                      256
                      #(0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 10 10 10
                        20 20 20 20 20 20 20 20 20 20 30 30 30 30 30 30 30 30 30
                        40 40 40 40 40 40 40 40 40 40 40 50 50 50 50 50 50 50 50 50 50
                        60 60 60 60 60 60 60 60 60 70 70 70 70 70 70 70 70 70 70 70
                        80 80 80 80 80 80 80 80 80 80 90 90 90 90 90 90 90 90 90
                        100 100 100 100 100 100 100 100 100 100 110 110 110 110 110 110 110 110 110 110 110
                        120 120 120 120 120 120 120 120 120 130 130 130 130 130 130 130 130 130 130
                        140 140 140 140 140 140 140 140 140 140 140 150 150 150 150 150 150 150 150 150
                        160 160 160 160 160 160 160 160 160 160 170 170 170 170 170 170 170 170 170 170 170
                        180 180 180 180 180 180 180 180 180 180 190 190 190 190 190 190 190 190 190
                        200 200 200 200 200 200 200 200 200 200 200 210 210 210 210 210 210 210 210 210 210
                        220 220 220 220 220 220 220 220 220 230 230 230 230 230 230 230 230 230 230 230
                        240 240 240 240 240 240 240 240 240 240 250 250 250 250 250)


But the #(...) form only works for constants; i.e., everything in the curves vector has to be a specific number and not a variable or result of an evaluated function.

If you want to create a calculated curve, or one that is obtained from external data (such as a file), then you need to use the (vector ...) procedure.

(gimp-curves-spline drawable
                      HISTOGRAM-VALUE
                      6
                      (vector 0 0 gray-point (gamma gray-point) 255 255))
(gimp-curves-explicit drawable
                      HISTOGRAM-VALUE
                      256
                      (vector step-0 step-0 step-0 step-0 step-0 step-0 step-0 step-0 step-0 step-0 step-0 step-0 step-0
                              step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1
                              step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1 step-1
                              step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2
                              step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2 step-2
                              step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3
                              step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3 step-3
                              step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4
                              step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4 step-4
                              step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5
                              step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5 step-5
                              step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6
                              step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6 step-6
                              step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7
                              step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7 step-7
                              step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8
                              step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8 step-8
                              step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9
                              step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9 step-9
                              step-10 step-10 step-10 step-10 step-10 step-10 step-10 step-10 step-10 step-10 step-10 step-10
                              step-10 )


These two forms of #(...) and (vector ...) are quite similar to their corresponding operations with lists: '(...) and (list ...)

Of course, you can generate your vector of points using an algorithmic procedure, just make sure your final result is vector and that you pass the number of points in the vector to the gimp-curves-* procedure.
(let* ((curve (generate-some-kind-of-curve 0 255 256 2.2 ))
       (number-of-points (vector-length curve)) )
  (gimp-curves-explicit drawable
                        HISTOGRAM-VALUE
                        number-of-points
                        curve ))

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Last edited by saulgoode on Sat Sep 24, 2011 12:47 am, edited 2 times in total.

Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Sat Sep 24, 2011 12:38 am  (#9) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
(gimp-curves-spline drawable
                      HISTOGRAM-VALUE
                      6
                      (vector 0 0 gray-point (gamma gray-point) 255 255))


What does the 6 represent in this procedure?

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Sat Sep 24, 2011 12:46 am  (#10) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
mahvin wrote:
(gimp-curves-spline drawable
                      HISTOGRAM-VALUE
                      6
                      (vector 0 0 gray-point (gamma gray-point) 255 255))


What does the 6 represent in this procedure?

That is the number of elements in the vector.

(let* ((curve (vector 0 0 gray-point (gamma gray-point) 255 255)))
  (gimp-curves-spline drawable
                      HISTOGRAM-VALUE
                      (vector-length curve)
                      curve ))

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Sat Sep 24, 2011 12:54 am  (#11) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
(gimp-curves-spline drawable HISTOGRAM-VALUE 4 #(0 255 255 0))


Ok, now I get it. Thanks.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: syntax for curves in script-fu
PostPosted: Sat Sep 24, 2011 2:28 pm  (#12) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
As saulgoode mentioned, single dimensional arrays are sometimes referred to as "vectors". Two dimensional arrays are sometimes referred to as "tables" and with three or more dimensions, they're called N-dimensional arrays (or multidimensional arrays). Technically, they are all arrays.

Unfortunately, GIMP's implementation of Scheme (TinyScheme) doesn't directly support N-dimensional arrays (can be simulated), as do more robust versions of Scheme. The array commands have been dropped in favor of vector commands.

In the interest of clarity, I think a few more basic examples might be helpful..

These two methods of defining the single dimensional array: my-vector are identical..
(define my-vector #(8 16 32 64))
(define my-vector (vector 8 16 32 64))

They both return my-vector as
#( 8 16 32 64 )

The value of each element in my-vector can be changed by using vector-set!
(vector-set! my-vector 0 255)

my-vector returns..
#( 255 16 32 64 )

Note that when using vector-set!, the index to each element in my-vector begins with zero (0-3 not 1-4)

You can use variables within vector-set! to change the value of each element in my-vector.

(define index 1)
(define new-value 200)
(vector-set! my-vector index new-value)

my-vector now returns..
#( 255 200 32 64 )

Graechan wrote:
Got it with this.

Looks like that will result in an infinite recursion loop.

It should be more like this..

(define splineValue #(0 0 38 31 125 129 197 223 255 255 255 255 255 255 255 255))

or

(define splineValue (vector 0 0 38 31 125 129 197 223 255 255 255 255 255 255 255 255))

(gimp-curves-spline inner-bevel-layer 0 16 splineValue)

Hope that helps!!

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Get use to using GEGL Graph syntax.I can't make a filter of everything

13

No new posts Attachment(s) Gimp curves import

2

No new posts Attachment(s) Gimp Gap Curves Issue

13

No new posts Custom curves files

3

No new posts [solved ] settings saved in Curves

2



* Login  



Powered by phpBB3 © phpBB Group