It is currently Sat Jul 06, 2024 7:37 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Re: iccii-aquabou.scm
PostPosted: Mon May 31, 2021 5:00 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jan 06, 2020
Posts: 347
Location: The Netherlands
Thank you ... now I am really completely satisfied!


Attachments:
thankyou.png
thankyou.png [ 133.4 KiB | Viewed 2831 times ]
Top
 Post subject: Re: iccii-aquabou.scm
PostPosted: Mon May 31, 2021 1:29 pm  (#12) 
Offline
GimpChat Member

Joined: Dec 19, 2018
Posts: 158
I didn't know this script.
I liked it a lot, a nice result in a simple and fast way.
Jappaloe63 thanks for commenting on this script.
Nidhogg, thx for making it functional again!

However...

One thing I noticed from the first time I tested the script is that it doesn't warn about the user not having the default font.
I don't have the font classicheavylight. The script selects another font and runs without giving the user any information about which font they are using.

I also noticed that with the Logo In Pill:
01- If I enter 3 separate words in the Text field, 3 individual blocks are generated for each word.
02- But if I enter only one word, instead of generating a block with this word, the script generates a block for each letter of the word.

This result (individual blocks for letters of a word) is welcome, but it would be nice if the script also generated an entire word per block.
Attachment:
LIP.png
LIP.png [ 268.14 KiB | Viewed 2806 times ]


Thx.

Edited (PS)
I think I get it... with the Button option you can generate a whole word per block.
Attachment:
LIP02.png
LIP02.png [ 118.5 KiB | Viewed 2803 times ]


Top
 Post subject: Re: iccii-aquabou.scm
PostPosted: Mon May 31, 2021 6:12 pm  (#13) 
Offline
GimpChat Member
User avatar

Joined: May 10, 2013
Posts: 1389
Location: FInland
Yeah that's how it works. I didn't want to edit the font name because I'm on Linux, and you never know what fonts people have installed on their systems. Just replaced "classicheavylight" to "Proxima Nova Alt", that I have installed and it worked. It's in the lines 668-670 and 851-853 under ; Default setting


Top
 Post subject: Re: iccii-aquabou.scm
PostPosted: Mon May 31, 2021 9:08 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 794
Location: SEA - South East Asia
This is an Awesome script!
Image

_________________
Patrice


Top
 Post subject: Re: iccii-aquabou.scm
PostPosted: Tue Jun 01, 2021 2:11 am  (#15) 
Offline
GimpChat Member

Joined: Apr 09, 2018
Posts: 1792
Location: France
Image

_________________
Les parfums, les couleurs et les sons se répondent.Baudelaire (Les fleurs du mal)
2.10.14 (Samj),2.10.21 (Samj) and 2.10.23(Samj) OS Windows 10 Home 64 bits


Top
 Post subject: iccii-aquabou.scm v2_10_28 No LONGER deprecated
PostPosted: Tue Nov 16, 2021 6:00 pm  (#16) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
Hello Nidhogg
Attachment:
NoLongerDeprecated.jpg
NoLongerDeprecated.jpg [ 140.67 KiB | Viewed 1531 times ]

The historical comment in Japanese about strbreakup highlighted in yellow
"Making it easier to split strings, so improve them" has been kept as an encouragement.

Introducing iccii-aquabou v2.10.28 22 KB Aqua style pill buttons
Attachment:
iccii-aquabou2_10_28.zip [6.07 KiB]
Downloaded 64 times


Firstly, AlSchemist added you in the credits. :jumpclap

Nidhogg wrote:
File > Create >AquaPro2


Caution: there are not any new features. It is a version for :geek who does not hate Scheme.

This version includes shortcuts, separated menu registration, some optimizations about constants "(* 512 2)" => "1024",
new pretty-print with aligned parenthesis and longer lines of Scheme beyond 80 char per line in full screen Notepad++.

AlSchemist removed deprecated API and (- 867 333) => 534 lines of Scheme. :shock:

This main subject of this article is:

1. How to find deprecated API in Gimp Script-Fu?
Gimp menu "Filters" > "Script-Fu" > "Console":
Copy and paste the following function in the input area of the console then validate by ENTER:
(define (deprecated? strFnc)
   (let*   (   (pdb (gimp-procedural-db-query ".*" ".*Deprecated.*"
               ".*Deprecated.*" ".*" ".*" ".*" ".*")
            )
            (nbrDeprec (car pdb))
            (lstPdbDeprec (cadr pdb))
         )
      (and (member strFnc lstPdbDeprec) #t)
)   )

;-> Script-Fu replies by the name of the function deprecated? meaning that the Scheme code is OK.

Ask Script-Fu:
After the name of the function, enter as parameter directly the name of any function such as gimp-version between double quote as a string:
(deprecated? "gimp-version")

;-> #f

gimp-version is not deprecated.

On the other hand:
(deprecated? "gimp-image-add-layer")

;-> #t

If you try unknown name of function, deprecated? will fail to preserve the future:
(deprecated? "unknown")

;-> #f

However parsing a function from iccii-aquabou.scm is out of the scope of this post.
Send a Private Message to AlSchemist if you are interested in the code in Scheme of deprecated-list.

In short, hereafter enclosed is the result for the first big function of the Aqua style button:
(deprecated-list script-fu-aqua-button2)

;-> ("gimp-blend" "gimp-drawable-set-visible" "gimp-ellipse-select" "gimp-gradients-get-gradient" "gimp-gradients-set-gradient" "gimp-image-add-layer" "gimp-palette-get-background" "gimp-palette-get-foreground" "gimp-palette-set-background" "gimp-palette-set-foreground" "gimp-patterns-get-pattern" "gimp-patterns-set-pattern" "gimp-perspective" "gimp-rect-select" "gimp-selection-layer-alpha")

We can classify the deprecated API in three families from easy to difficult:
  1. Change of API name only: the list of parameters is unchanged ;)
  2. Change of order of the parameters. Some extra parameters could be removed.
  3. Add new parameters :roll:

Stay tuned to sweeten the pill! :oops:


Top
 Post subject: Re: iccii-aquabou.scm
PostPosted: Tue Nov 16, 2021 9:31 pm  (#17) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2607
Location: California
Examples:

Logo in Pill:
Image

Button:
Image


Top
 Post subject: Re: iccii-aquabou.scm v2_10_28 No LONGER deprecated
PostPosted: Wed Nov 17, 2021 1:58 am  (#18) 
Offline
GimpChat Member
User avatar

Joined: May 24, 2021
Posts: 794
Location: SEA - South East Asia
AlSchemist wrote:
Hello Nidhogg
Attachment:
The attachment NoLongerDeprecated.jpg is no longer available

The historical comment in Japanese about strbreakup highlighted in yellow
"Making it easier to split strings, so improve them" has been kept as an encouragement.

Introducing iccii-aquabou v2.10.28 22 KB Aqua style pill buttons
Attachment:
The attachment iccii-aquabou2_10_28.zip is no longer available


Firstly, AlSchemist added you in the credits. :jumpclap

Nidhogg wrote:
File > Create >AquaPro2


Caution: there are not any new features. It is a version for :geek who does not hate Scheme.

This version includes shortcuts, separated menu registration, some optimizations about constants "(* 512 2)" => "1024",
new pretty-print with aligned parenthesis and longer lines of Scheme beyond 80 char per line in full screen Notepad++.

AlSchemist removed deprecated API and (- 867 333) => 534 lines of Scheme. :shock:

This main subject of this article is:

1. How to find deprecated API in Gimp Script-Fu?
Gimp menu "Filters" > "Script-Fu" > "Console":
Copy and paste the following function in the input area of the console then validate by ENTER:
(define (deprecated? strFnc)
   (let*   (   (pdb (gimp-procedural-db-query ".*" ".*Deprecated.*"
               ".*Deprecated.*" ".*" ".*" ".*" ".*")
            )
            (nbrDeprec (car pdb))
            (lstPdbDeprec (cadr pdb))
         )
      (and (member strFnc lstPdbDeprec) #t)
)   )

;-> Script-Fu replies by the name of the function deprecated? meaning that the Scheme code is OK.

Ask Script-Fu:
After the name of the function, enter as parameter directly the name of any function such as gimp-version between double quote as a string:
(deprecated? "gimp-version")

;-> #f

gimp-version is not deprecated.

On the other hand:
(deprecated? "gimp-image-add-layer")

;-> #t

If you try unknown name of function, deprecated? will fail to preserve the future:
(deprecated? "unknown")

;-> #f

However parsing a function from iccii-aquabou.scm is out of the scope of this post.
Send a Private Message to AlSchemist if you are interested in the code in Scheme of deprecated-list.

In short, hereafter enclosed is the result for the first big function of the Aqua style button:
(deprecated-list script-fu-aqua-button2)

;-> ("gimp-blend" "gimp-drawable-set-visible" "gimp-ellipse-select" "gimp-gradients-get-gradient" "gimp-gradients-set-gradient" "gimp-image-add-layer" "gimp-palette-get-background" "gimp-palette-get-foreground" "gimp-palette-set-background" "gimp-palette-set-foreground" "gimp-patterns-get-pattern" "gimp-patterns-set-pattern" "gimp-perspective" "gimp-rect-select" "gimp-selection-layer-alpha")

We can classify the deprecated API in three families from easy to difficult:
  1. Change of API name only: the list of parameters is unchanged ;)
  2. Change of order of the parameters. Some extra parameters could be removed.
  3. Add new parameters :roll:

Stay tuned to sweeten the pill! :oops:


AlSchemist seems to have a great knowledge about tiny script
PixLab (a.k.a. Patrice) is no programmer at All, but if you can tell to AlSchemist what Patrice did found about the original script that make Patrice feel "limited" in many ways with the original script (Patrice did not try the one from AlSchemist yet, he will wait)

Limitation about size of the font with "File/Create/AquaPro2/Button..."> Patrice cannot make font bigger than 685 pixels as at 686 he got an error, with the default font(which I don't have), and with another font, Patrice can go up to 697 pixels, but at 698 he got the same type of error.
Same error appear with "File/Create/AquaPro2/Logo in Pill..." Thus this tells him that there is limitation somewhere...
Same limitation/Error about the "File/Create/AquaPro2/Hrule..." about the "width" and "Height"
Same Error/Limitation about the "File/Create/AquaPro2/Round..." about the radius
All error got this message (only the floating point number change):
Error: Procedure execution of plug-in-gauss-rle2 failed on invalid input arguments: Procedure 'plug-in-gauss-rle2' has been called with value '860.504202' for argument 'horizontal' (#4, type gdouble). This value is out of range.

Attachment:
screenshot_20211117-121912.png
screenshot_20211117-121912.png [ 23.4 KiB | Viewed 1511 times ]



Also, Patrice found extremely annoying to not have a slider on the UI to increase quickly the font size and other options, so he did discovered by comparing some tinyscripts that by changing only 1 parameter and 1 parameter only
SF-ADJUSTMENT   _"Font Size (pixels)"   '(75 2 2048 1 1 0 1)
//by
SF-ADJUSTMENT   _"Font Size (pixels)"   '(75 2 2048 1 1 0 0)
//Note the 1 to 0 on the last parameter

He now got a slider and an input box with arrows up and down at the same time (no need to tell how Patrice is now happy), but in the end why tinyscripter don't do that?

Anyway thanks AlSchemist for me for having a look at this script :bigthup

In the very end I'm exhausted to speak about me at the third person, and about you at the third of the third person, my next post will be back to "normal mode" ;)

_________________
Patrice


Top
 Post subject: Re: iccii-aquabou.scm
PostPosted: Wed Nov 17, 2021 9:46 am  (#19) 
Offline
GimpChat Member
User avatar

Joined: May 10, 2013
Posts: 1389
Location: FInland
AlSchemist, thanks for sweetening the pill. It turned 20 years old 2 months ago!


Top
 Post subject: Is there a limit in gauss function?
PostPosted: Wed Nov 17, 2021 4:40 pm  (#20) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
:tyspin Mackenzieh, PixLab and Nidhogg!

PixLab wrote:
SF-ADJUSTMENT _"Font Size (pixels)" '(75 2 2048 1 1 0 0)

The upper limit "2048" is a little bit too big. :faint However why not for the last zero! :clap
The original version with 867 lines said:
  • "SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 500 1 1 0 1)"
  • "SF-ADJUSTMENT _"Font Size (pixels)" '(75 2 500 1 1 0 1)"

Is there a limit in gauss function?

Copy and paste the following tool in the Script-Fu console:
(define (proc-arg-search proc token) ; search token in all arguments of PDB functions matching proc
   (let loopApi ((lstApi (cadr (gimp-procedural-db-query (string-append ".*" proc ".*") ".*" ".*" ".*" ".*" ".*" ".*"))))
      (if (not (pair? lstApi)) (string->symbol "") ; return nothing
         (let*   (   (procedure-name (car lstApi))
                  (nbrPrm (car (last (butlast (gimp-procedural-db-proc-info procedure-name)))))
               )
            (let loopPrm ((arg-num 0))
               (if (= arg-num nbrPrm) (loopApi (cdr lstApi))
                  (let*   (   (lstInfo (gimp-procedural-db-proc-arg procedure-name arg-num))
                           (arg-name  (cadr lstInfo))
                           (arg-descr (caddr lstInfo))
                           (lstToken (strbreakup (car (strbreakup (car (strbreakup arg-descr "-")) ")")) " "))
                           (strInfo (string-append procedure-name ": " arg-name ": " arg-descr))
                        )
                     (if (and (member token lstToken) #t) (displayln strInfo))
                     (loopPrm (+ arg-num 1))
)   )   )   )   )   )   )


Then ask the Script-Fu console by:
(proc-arg-search "gauss" "500")

;-> Script-Fu will tell you a long story about the known limit "500" in the gauss procedures:
plug-in-gauss-iir2: horizontal: Horizontal radius of gaussian blur (in pixels (0 <= horizontal <= 500)
plug-in-gauss-iir2: vertical: Vertical radius of gaussian blur (in pixels (0 <= vertical <= 500)
plug-in-gauss: horizontal: Horizontal radius of gaussian blur (in pixels (0 <= horizontal <= 500)
plug-in-gauss: vertical: Vertical radius of gaussian blur (in pixels (0 <= vertical <= 500)
plug-in-gauss-rle2: horizontal: Horizontal radius of gaussian blur (in pixels (0 <= horizontal <= 500)
plug-in-gauss-rle2: vertical: Vertical radius of gaussian blur (in pixels (0 <= vertical <= 500)
plug-in-gauss-iir: radius: Radius of gaussian blur (in pixels (0 <= radius <= 500)
plug-in-gauss-rle: radius: Radius of gaussian blur (in pixels (0 <= radius <= 500)

:yesnod 500 is an historical limit in the main gauss procedures!

Anyway, replace all calls of plug-in-gauss-rle2 in Aqua Btn with our new "gauss" function:
(define (gauss run-mode image drawable horizontal vertical)
   (plug-in-gauss-rle2 run-mode image drawable (min horizontal 500) (min vertical 500))
)

gauss calls plug-in-gauss-rle2 with the same parameters but within the limit of 500.
The entire region will be not processed in the giant Aqua pill but the issue is solved.
Drawing is longer. :zzz However maybe the final result is also acceptable :paint


Top
 Post subject: How to update deprecated functions? Part 1: the easy way
PostPosted: Thu Nov 18, 2021 3:18 pm  (#21) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
1. Change of name of deprecated functions: level easy

Firstly, we list the deprecated API found in Aqua btn.
Then, in the second line, we align the parameters of the modern function of replacement found in PDB. :coolthup

(gimp-blend      drawable blend-mode paint-mode gradient-type opacity offset repeat reverse supersample max-depth threshold dither x1 y1 x2 y2)
(gimp-edit-blend drawable blend-mode paint-mode gradient-type opacity offset repeat reverse supersample max-depth threshold dither x1 y1 x2 y2)

(gimp-drawable-set-visible item visible)
(gimp-item-set-visible     item visible)

(gimp-gradients-set-gradient name)
(gimp-context-set-gradient   name)

(gimp-palette-set-background background)
(gimp-context-set-background background)

(gimp-palette-set-foreground foreground)
(gimp-context-set-foreground foreground)

(gimp-patterns-set-pattern name)
(gimp-context-set-pattern  name)

(gimp-drawable-set-name item name)
(gimp-item-set-name     item name)

(gimp-image-raise-layer-to-top image item)
(gimp-image-raise-item-to-top  image item)

(gimp-image-lower-layer-to-bottom image item)
(gimp-image-lower-item-to-bottom  image item)

(gimp-image-lower-layer image item)
(gimp-image-lower-item  image item)

Notepad++ menu "Search" > "Replace..."
Find what: copy and paste the name of the deprecated function without parameters
Replace with: copy and paste the name of the modern function without parameters

:geekon We call this basic replacement a rule of rewriting. :keybdtype

Be sure to process the longest functions before any short functions.
For example: replace "gimp-image-lower-layer-to-bottom" before "gimp-image-lower-layer" that begins with the same tokens. :otb


Top
 Post subject: Introducing regular expressions
PostPosted: Fri Nov 19, 2021 3:26 pm  (#22) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
2. Insert a new parameter: level average

This article is a short introduction of so called "regular expression" to capture symbolically tokens inside a string.
Consider the couple of deprecated/modern functions:
(gimp-image-add-layer    image layer        position)
(gimp-image-insert-layer image layer parent position)

The parent parameter has been added in the modern function between layer and position.

Notepad++ menu "Search" > "Replace..."

[x] Regular expression :yesnod check this option that changes the semantic of letter preceded with backslash.

The rule of rewriting becomes:
Find what: :geek:
gimp-image-add-layer\s+(\w+\s+\w+)

Replace with: :sglasses
gimp-image-insert-layer \1 0

In Find what:
"\s" captures one white-space
"\s+" captures one white-space or more

"\w+" captures one or more letter or number that is to say a word. Minus "-" will be processed soon.
In our case, the first "\w+" captures the first parameter for example "image" or often "img" in Aqua btn.
So the second "\w+" captures the second parameter corresponding to "layer".

:arrow: We build our first group between parenthesis: "(\w+\s+\w+)" to capture both "image" + "layer"
because we wish to insert a new parameter called parent after this group.
Its meaning is the first parameter image + one or more white-space + the second parameter layer.

:idea: The idea is that we can symbolically reuse this group in the "Replace with" input area.
The name of the first group --that is to say the first expression between parenthesis-- is automatically named "\1".

Hence the 'Replace with' input string that includes:
  • the modern function gimp-image-insert-layer;
  • a single space before the first parameter;
  • our first group code-named "\1" containing both the first parameter and the second parameter;
  • "0" which is the compatible parent since we do not need to create any group of layers.

:help With PDB, consult the help of the modern function for more information about the new parameter parent.

Take in consideration that we do not process the last parameter "position" :nono
because it does not change of position :pipe relatively to the new parameter "parent". :)


Last edited by AlSchemist on Sat Nov 20, 2021 6:18 am, edited 1 time in total.

Top
 Post subject: Minus in the name of Scheme variable
PostPosted: Sat Nov 20, 2021 6:13 am  (#23) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
3. Minus-in-the-name-of-Scheme variable: level average++

In Scheme, minus "-" is both:
  • the operator of subtraction
  • an acceptable character in the name of a parameter.
The entire Gimp API uses minus as separator.

It is also true for the parameters. For example, the Aqua btn variable "acopy-mask" include minus inside its name.
The only problem is that the regular expression "\w+" captures only the first part "acopy" of the name before minus.

To be compatible with the Scheme syntax of variable, we need to add minus in the definition of a element of word.
To do that, we search the definition of "\w" as an interval of regular expressions: "[_\d\l\u]"
with:
  • "_" underscore is valid character of variable
  • "\d" standing for digit
  • "\l" standing for lower letter
  • "\u" standing for upper letter


In addition of underscore "_", we add in the interval the minus "-" character.
However minus "-" is also a specific operator :hoh to define an interval between characters. For example "[0-9]" captures a digit.
That is why, we need to use a backslash before minus. :gaah

So the rule of rewriting becomes more complex: :geek
Find what:
gimp-image-add-layer\s+([_\-\d\l\u]+\s+[_\-\d\l\u]+)

Replace with:
gimp-image-insert-layer \1 0


Before running this rule of rewriting in Notepad++,
try to only find the deprecated function with the group of its two first --full-- parameters as an exercice to validate the improved regular expression. :mcof


Top
 Post subject: Moving parameters in the modern Script-Fu function
PostPosted: Sun Nov 21, 2021 9:49 am  (#24) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
4. Move parameter: level difficult

Let us progress in the Notepad++ regular expressions to replace more complex deprecated functions.

In the deprecated function gimp-ellipse-select, the 6th parameter operation is moved after image.
(gimp-ellipse-select       image           x y width height operation antialias feather feather-radius)
(gimp-image-select-ellipse image operation x y width height)

Not only operation is moved before its actual position :wh
but the three last parameters antialias, feather and feather-radius disappear in the modern function. :bye

In Aqua btn, a real example could be moving the operation "CHANNEL-OP-REPLACE" just after "img":
(gimp-ellipse-select       img                    xscale40 yscale40 radius4 radius4 CHANNEL-OP-REPLACE TRUE 0 0)
(gimp-image-select-ellipse img CHANNEL-OP-REPLACE xscale40 yscale40 radius4 radius4)

To capture all constants beginning with "CHANNEL", the regular expression starts with:
CHANNEL.*

Since the multiple joker ".*" matches everything such as CHANNEL-OP-REPLACE but also CHANNEL-OP-SUBTRACT, etc.,
it is usual to indicate a separator after the constant to indicate the end of the constant.
We already know the separator "\s+" capturing at least one white-space or more.

The regular expression to capture the entire constant and its next separator becomes:
CHANNEL.*\s+


Hereafter enclosed is the "simplified" rule of rewriting using "\w+" without minus in the name of parameter:

Notepad++ menu "Search" > "Replace..."
[x] Regular expression

Find what: :geek:
gimp-ellipse-select\s+(\w+)\s+(.*)\s+(CHANNEL.*)\s+\w+\s+\d+\s+\d+\)


Replace with: :sglasses
gimp-image-select-ellipse \1 \3 \2\)

We have three groups and the third group "\3" has been moved between the two first groups "\1" and "\2". :clap


Top
 Post subject: Regex ".*" is greedy
PostPosted: Sun Nov 21, 2021 10:31 am  (#25) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
4.1 Scope of the capture of the multiple joker ".*"

The second group is delimited between two separators:
\s+(.*)\s+

This regular expression (regex) could be interpreted as capturing " xscale40 " that is to say the first parameter.
However this regular expression is greedy or gluttonous. :pizza
It captures the maximum possible of input until the supplied constant "(CHANNEL.*)\s+".
That is why group2 captures " xscale40 yscale40 radius4 radius4 ".

:arrow: Always before replacing, test your regex-based searching until you reach exactly the wished capture.

The third group code-named operation that is to say "(CHANNEL.*)" will be inserted between the two first groups.

Please, pay attention that the rewriting rule takes in consideration --for the very first time-- the three last parameters --a word and two numbers--
"TRUE 0 0)" until the closing parenthesis. Always focus on the separators of the language.

:idea: The idea is to remove those three last parameters in the modern function replacing them only with the closing parenthesis.

\s+\w+\s+\d+\s+\d+\)

  • "\w+" matches "TRUE"
  • "\d+" matches "0"
  • the last "\d+" matches also "0"
  • "\)" matches ")". We need to backslash the closing parenthesis to avoid the known semantic of group.

Moreover let us indicate another similar example:
Again in the legacy function gimp-rect-select, the two last parameters "feather feather-radius" will be forgotten. :wizwand

Existing deprecated function: :geek:
(gimp-rect-select            image           x y width height operation feather feather-radius)


Goal of the replacement with the modern function: :sglasses
(gimp-image-select-rectangle image operation x y width height)


The rewriting rule could be defined by the following:

Notepad++ menu "Search" > "Replace..."
[x] Regular expression

Find what: :geek:
gimp-rect-select\s+(\w+)\s+(.*)\s+(CHANNEL.*)\s+\d+\s+\d+\)


Replace with: :sglasses
gimp-image-select-rectangle \1 \3 \2\)

Please note that in the "Replace with", the closing parenthesis does not need to be backslashed.


Top
 Post subject: Capturing one newline
PostPosted: Sun Nov 21, 2021 10:51 am  (#26) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
4.2 Newline inside the parameters

In Aqua btn, the previous regular expressions work if the deprecated function is on only one line.
What appends if the list of parameters is split on two lines.
             (gimp-ellipse-select img (*  40 xscale) (*  40 yscale)
                             (* 2 radius2) (* 2 radius2) CHANNEL-OP-REPLACE TRUE 0 0)

After the Notepad++ option [x] Regular expression, checking [x] . matches newline
will capture to many functions until the last constant "CHANNEL" of the file. The regular expression is too greedy. :pac

Of course, you can replace manually the deprecated functions without using regular expressions.
It depends of the number of the replacements.

However searching in the online help of Notepad++ regular expression,
you may wish to try the "/R" regular expression that captures EOL (End of line).
EOL depends on the operating system:
  • Windows: "\r\n"
  • Linux and macOS: "\n"
  • classic Mac OS: "\r"

Notepad++ menu "Search" > "Replace..."
[x] Regular expression

Find what: :geek:
gimp-ellipse-select\s+(\w+)\s+(.*\R{1}.*)\s+(CHANNEL.*)\s+\d+\s+\d+\)

We accept only one newline "\R{1}" inside the list of parameters before the constant "CHANNEL".
The number of the previous character is indicated between brace parenthesis "{1}".

There is probably a better, shorter solution. It is up to you to improve this solution replying to this thread.

According to a previous chapter 3. Minus-in-the-name-of-Scheme variable, if the Scheme code uses minus inside the name of variable,
feel free to replace each word "\w+" by the interval "[_\-\d\l\u]+" including minus "-" in the name of a parameter.


Top
 Post subject: Upgrading deprecated functions could add new parameters
PostPosted: Mon Nov 22, 2021 2:33 pm  (#27) 
Offline
GimpChat Member
User avatar

Joined: Oct 23, 2021
Posts: 67
5. New parameters in the modern function: level difficult

Finally the last family of deprecated functions introduces new parameters often unknown parameters.

As usual, the first function is the deprecated function:
(gimp-invert          drawable)
(gimp-drawable-invert drawable linear) ; linear: Whether to invert in linear space (TRUE or FALSE)

The second function is the associated modern function having linear as new last parameter.

Since there is only one occurrence of gimp-invert in Aqua btn, you can manually replace it with the modern function.
However, the rewriting rule with regex could be:

Notepad++ menu "Search" > "Replace..."
[x] Regular expression

Find what: :geek:
gimp-invert\s+(.*)\)

The hypothesis is that the parameter drawable is a variable but not the result of the call of a function including parenthesis.

Replace with: :sglasses
gimp-drawable-invert \1 TRUE)

In line 167 of AquaBou2_10_28.scm, AlSchemist preferred TRUE for linear however this is an open discussion.
The final result of the generated aqua pill does not suffer to this new parameter with the modern function. :hi5

In the final example, PDB could not help anymore.
The difficulty increases with the number of options for the new parameter code-named operation: :roll:
(gimp-selection-layer-alpha                 layer)
(gimp-image-select-item     image operation item) ; operation: CHANNEL-OP-ADD (0), CHANNEL-OP-SUBTRACT (1), CHANNEL-OP-REPLACE (2), CHANNEL-OP-INTERSECT (3)

The alignment indicates that layer = item.
According to the following rewriting rule, AlSchemist chose "CHANNEL-OP-REPLACE" for operation
however the relationship with the selection of layer alpha is not patent. :gaah

Notepad++ menu "Search" > "Replace..."
[x] Regular expression

Find what: :geek:
gimp-selection-layer-alpha\s+(\w+)


Replace with: :sglasses
gimp-image-select-item img CHANNEL-OP-REPLACE \1

There are four occurrences: lines 39, 52, 58 and 168.
It is up to you to test the other alternatives if you prefer them. :geek

This post :party concludes :grooving the series of articles about:
migrating Script-Fu deprecated functions in Gimp 2.10.28


Top
Post new topic Reply to topic  [ 27 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Error with ICCII's Random Blends Script

6



* Login  



Powered by phpBB3 © phpBB Group