It is currently Fri May 24, 2013 4:57 pm


Latest GIMP Scripts & Plug-ins

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 9:08 pm  (#1) 
Offline
Gimp Scripts Editor
User avatar

Joined: Feb 18, 2011
Posts: 1569
Location: 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


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Profile  
 

 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 9:18 pm  (#2) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 9027
Location: "Looking for my eraser" =P
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
Code:
       (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/
Code:
   (gimp-curves-spline theDrawable 0 8 #(0 0 55 27 176 197 255 255))


Perhaps it is the addition of the hash mark?

_________________
Image
Gimp Rocks Blog
Simply Gimp Tutorials
"Once your in the cloud, you're in the net"
____________
OK, . . . . so what's the speed of dark?


Top
 Profile  
 
 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 9:28 pm  (#3) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 9027
Location: "Looking for my eraser" =P
Or perhaps this will help.
http://code.google.com/p/paynekj-gimp-s ... curves.scm

_________________
Image
Gimp Rocks Blog
Simply Gimp Tutorials
"Once your in the cloud, you're in the net"
____________
OK, . . . . so what's the speed of dark?


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

Joined: May 22, 2008
Posts: 2094
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.

_________________
Image


Top
 Profile  
 
 Post subject: Re: syntax for curves in script-fu
PostPosted: Fri Sep 23, 2011 10:06 pm  (#5) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 9027
Location: "Looking for my eraser" =P
Wow
So is value = red,green,blue, and alpha channels combined.
and RGB = just red green and blue without alpha?

_________________
Image
Gimp Rocks Blog
Simply Gimp Tutorials
"Once your in the cloud, you're in the net"
____________
OK, . . . . so what's the speed of dark?


Top
 Profile  
 
 Post subject: Re: syntax for curves in script-fu(solved)
PostPosted: Fri Sep 23, 2011 11:53 pm  (#6) 
Offline
Gimp Scripts Editor
User avatar

Joined: Feb 18, 2011
Posts: 1569
Location: 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


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

Joined: May 16, 2010
Posts: 9027
Location: "Looking for my eraser" =P
Cool! so what are you working on now? :)

_________________
Image
Gimp Rocks Blog
Simply Gimp Tutorials
"Once your in the cloud, you're in the net"
____________
OK, . . . . so what's the speed of dark?


Top
 Profile  
 

 Post subject: Re: syntax for curves in script-fu(solved)
PostPosted: Sat Sep 24, 2011 1:29 am  (#8) 
Offline
GimpChat Member
User avatar

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

Code:
   (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.

Code:
(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.

Code:
(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.
Code:
(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 ))

_________________
There are two types of people in the world. Those who believe in the principle of bivalence, and those who do not.


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

Top
 Profile  
 
 Post subject: Re: syntax for curves in script-fu
PostPosted: Sat Sep 24, 2011 1:38 am  (#9) 
Offline
GimpChat Member

Joined: Oct 06, 2010
Posts: 2688
Code:
(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?

_________________
You cannot do a kindness too soon because you never know how soon it will be too late.

~Ralph Waldo Emerson


Top
 Profile  
 
 Post subject: Re: syntax for curves in script-fu
PostPosted: Sat Sep 24, 2011 1:46 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Apr 23, 2010
Posts: 822
Location: not from Guildford after all
mahvin wrote:
Code:
(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.

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

_________________
There are two types of people in the world. Those who believe in the principle of bivalence, and those who do not.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

* Login   * Subscribe to RSS Feed


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group