GIMP Chat
http://gimpchat.com/

A liitle Start Help with a Script-Fu Script
http://gimpchat.com/viewtopic.php?f=9&t=19333
Page 1 of 1

Author:  ThomasLahme [ Tue Apr 20, 2021 7:40 am ]
Post subject:  A liitle Start Help with a Script-Fu Script

Dear Community,
I have started to write Script-Fu Scripts for GIMP.
So I just know how to do simple Stuff with this Scripts:
1. I know how to load my Scripts
2. How to register Scripts proper
3. How to do one Procedure Scripts

And new I'm at Point 4:
How to write a Script which contains
One Main Procedure
and
Some Helper Procedure

As I'm rather an Artist then a Designer or a Programmer.
I have some Stuff which will be better done with Recursive-ty
So I need a Way to make Sub-Procedures.

But my Problem is that all may try's to write such things are failed.
I can write Sub-Procedures, and they can been executed.
But when the Program go future / go back in the caller
I will earn a "Illegal Function" call Error.

So can anybody help me to get this proper too.

In hope of Help

Thomas Lahme
CreCo

P.S.: In the Attachment the Script which I will try to get proper

Attachments:
MyFirstModrian.scm [1.51 KiB]
Downloaded 89 times

Author:  paynekj [ Tue Apr 20, 2021 8:35 am ]
Post subject:  Re: A liitle Start Help with a Script-Fu Script

Try this:
(define image 1)
(define layer 2)

(define (script-fu-Mondrian)
  (begin
    (gimp-message "Und meine Function läuft" )
    (mondrian-make-Canvas)
  )
)

(define (mondrian-make-Canvas)
    (let* (
        (canvas-dx 300)
        (canvas-dy 200)
        )
        (set! image (car (gimp-image-new canvas-dx canvas-dy RGB)))
        (set! layer (car (gimp-layer-new image canvas-dx canvas-dy RGB-IMAGE "Proj1" 100 0)))
        (gimp-image-add-layer image layer 0)
        (gimp-display-new image)
        (gimp-message (string-append "Test:" (number->string canvas-dx) "x" (number->string canvas-dy)))
        (mondrian-paint-image)
    )
)

(define (mondrian-paint-image)
  (begin
    (mondrian_paint_backgroud)
    (gimp-message "Du Doof")
  )
)

(define (mondrian_paint_backgroud)
  (begin
    (gimp-context-set-background '(0 0 122))
    (gimp-drawable-fill layer FILL-BACKGROUND)
    (gimp-message "tetanus here")
  )
)
   
   
  (script-fu-register
    "script-fu-Mondrian"                        ;func name
    "Create a Mondrian"                                  ;menu label
    "This is my first script-fu Script \
     It draws a Mondrian like Image"              ;description
    "Thomas Lahme"                             ;author
    "Copyright:: Its under the GPL"        ;copyright notice
    "19 April 2021"                          ;date created
    ""                     ;image type that the script works on
    SF-ADJUSTMENT  "Granularity"     '(50 1 1000 1 10 0 1)
   )
  (script-fu-menu-register "script-fu-Mondrian" "<Image>/Mondrian")


Without the begin the return from your help functions is being treated as a command to run.

Be warned, doing this:
(define image 1)
(define layer 2)

Will define image and layer for ALL scripts and might break other scripts.

Author:  ThomasLahme [ Tue Apr 20, 2021 9:35 am ]
Post subject:  Re: A liitle Start Help with a Script-Fu Script

Thanks a lot paynekj.
Just the Script Runs without that Error ...
... but you have right that a Global-Variable is a Dangerous Entity

A very Thankful
Thomas Lahme

Author:  ThomasLahme [ Tue Apr 20, 2021 11:33 am ]
Post subject:  Re: A liitle Start Help with a Script-Fu Script

Against I will express my best regards
New My Script runs very successfully.
And this was my first Script in GIMP Script-Fu

I wounder that it gives so a nice Program
With so a helpful Community

AWE :geek :kpix

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/