It is currently Sun Jun 30, 2024 3:56 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: A liitle Start Help with a Script-Fu Script
PostPosted: Tue Apr 20, 2021 7:40 am  (#1) 
Offline
GimpChat Member

Joined: Apr 20, 2021
Posts: 13
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 88 times
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: A liitle Start Help with a Script-Fu Script
PostPosted: Tue Apr 20, 2021 8:35 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
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.


Top
 Post subject: Re: A liitle Start Help with a Script-Fu Script
PostPosted: Tue Apr 20, 2021 9:35 am  (#3) 
Offline
GimpChat Member

Joined: Apr 20, 2021
Posts: 13
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


Top
 Post subject: Re: A liitle Start Help with a Script-Fu Script
PostPosted: Tue Apr 20, 2021 11:33 am  (#4) 
Offline
GimpChat Member

Joined: Apr 20, 2021
Posts: 13
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


Top
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Looking for Script Coder to make Script of my VHS effect

2

No new posts Attachment(s) Cannot run test script-fu script via console

7

No new posts Attachment(s) Script-fu

6

No new posts Will it need to be done again from the start?

5

No new posts Naturalize Script

2



* Login  



Powered by phpBB3 © phpBB Group