2006-12-09 21:33:38 +00:00
|
|
|
; GIMP - The GNU Image Manipulation Program
|
1997-11-24 22:05:25 +00:00
|
|
|
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
;
|
|
|
|
; Weave script --- make an image look as if it were woven
|
|
|
|
; Copyright (C) 1997 Federico Mena Quintero
|
|
|
|
; federico@nuclecu.unam.mx
|
|
|
|
;
|
2009-01-17 22:28:01 +00:00
|
|
|
; This program is free software: you can redistribute it and/or modify
|
1997-11-24 22:05:25 +00:00
|
|
|
; it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
; the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 22:05:25 +00:00
|
|
|
; (at your option) any later version.
|
|
|
|
;
|
|
|
|
; This program is distributed in the hope that it will be useful,
|
|
|
|
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
; GNU General Public License for more details.
|
|
|
|
;
|
|
|
|
; You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
; Copies the specified rectangle from/to the specified drawable
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (copy-rectangle img
|
2006-10-16 01:08:54 +00:00
|
|
|
drawable
|
|
|
|
x1
|
|
|
|
y1
|
|
|
|
width
|
|
|
|
height
|
|
|
|
dest-x
|
|
|
|
dest-y)
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-image-select-rectangle img CHANNEL-OP-REPLACE x1 y1 width height)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(gimp-edit-copy 1 (vector drawable))
|
|
|
|
(let* (
|
|
|
|
(pasted (gimp-edit-paste drawable FALSE))
|
|
|
|
(num-pasted (car pasted))
|
|
|
|
(floating-sel (aref (cadr pasted) (- num-pasted 1)))
|
|
|
|
)
|
|
|
|
(gimp-layer-set-offsets floating-sel dest-x dest-y)
|
|
|
|
(gimp-floating-sel-anchor floating-sel)
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-selection-none img))
|
|
|
|
|
|
|
|
; Creates a single weaving tile
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (create-weave-tile ribbon-width
|
2006-10-16 01:08:54 +00:00
|
|
|
ribbon-spacing
|
|
|
|
shadow-darkness
|
|
|
|
shadow-depth)
|
1997-11-24 22:05:25 +00:00
|
|
|
(let* ((tile-size (+ (* 2 ribbon-width) (* 2 ribbon-spacing)))
|
2006-10-16 01:08:54 +00:00
|
|
|
(darkness (* 255 (/ (- 100 shadow-darkness) 100)))
|
|
|
|
(img (car (gimp-image-new tile-size tile-size RGB)))
|
|
|
|
(drawable (car (gimp-layer-new img tile-size tile-size RGB-IMAGE
|
2017-01-09 20:37:30 +01:00
|
|
|
"Weave tile" 100 LAYER-MODE-NORMAL))))
|
2011-11-06 15:55:45 -05:00
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-disable img)
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer img drawable 0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(0 0 0))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Create main horizontal ribbon
|
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-foreground '(255 255 255))
|
|
|
|
(gimp-context-set-background (list darkness darkness darkness))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-image-select-rectangle img
|
|
|
|
CHANNEL-OP-REPLACE
|
|
|
|
0
|
|
|
|
ribbon-spacing
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
ribbon-width)
|
2003-07-22 14:24:11 +00:00
|
|
|
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-context-set-gradient-fg-bg-rgb)
|
|
|
|
(gimp-drawable-edit-gradient-fill drawable
|
|
|
|
GRADIENT-BILINEAR (- 100 shadow-depth)
|
2024-02-14 23:52:18 +00:00
|
|
|
FALSE 1 0
|
2018-04-16 20:12:12 +02:00
|
|
|
TRUE
|
|
|
|
(/ (+ (* 2 ribbon-spacing) ribbon-width -1) 2) 0
|
|
|
|
0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Create main vertical ribbon
|
|
|
|
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-image-select-rectangle img
|
|
|
|
CHANNEL-OP-REPLACE
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
0
|
|
|
|
ribbon-width
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width))
|
2003-07-22 14:24:11 +00:00
|
|
|
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-gradient-fill drawable
|
|
|
|
GRADIENT-BILINEAR (- 100 shadow-depth)
|
2024-02-14 23:52:18 +00:00
|
|
|
FALSE 1 0
|
2018-04-16 20:12:12 +02:00
|
|
|
TRUE
|
|
|
|
0 (/ (+ (* 2 ribbon-spacing) ribbon-width -1) 2)
|
|
|
|
0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Create the secondary horizontal ribbon
|
|
|
|
|
|
|
|
(copy-rectangle img
|
2006-10-16 01:08:54 +00:00
|
|
|
drawable
|
|
|
|
0
|
|
|
|
ribbon-spacing
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
ribbon-width
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
(copy-rectangle img
|
2006-10-16 01:08:54 +00:00
|
|
|
drawable
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
ribbon-spacing
|
|
|
|
ribbon-spacing
|
|
|
|
ribbon-width
|
|
|
|
0
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Create the secondary vertical ribbon
|
|
|
|
|
|
|
|
(copy-rectangle img
|
2006-10-16 01:08:54 +00:00
|
|
|
drawable
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
0
|
|
|
|
ribbon-width
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
ribbon-spacing
|
|
|
|
(+ ribbon-width ribbon-spacing))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
(copy-rectangle img
|
2006-10-16 01:08:54 +00:00
|
|
|
drawable
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
ribbon-spacing
|
|
|
|
0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Done
|
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-enable img)
|
1997-11-24 22:05:25 +00:00
|
|
|
(list img drawable)))
|
|
|
|
|
|
|
|
; Creates a complete weaving mask
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (create-weave width
|
2006-10-16 01:08:54 +00:00
|
|
|
height
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
shadow-darkness
|
|
|
|
shadow-depth)
|
2003-07-22 14:24:11 +00:00
|
|
|
(let* ((tile (create-weave-tile ribbon-width ribbon-spacing shadow-darkness
|
2006-10-16 01:08:54 +00:00
|
|
|
shadow-depth))
|
|
|
|
(tile-img (car tile))
|
|
|
|
(tile-layer (cadr tile))
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(weaving (plug-in-tile RUN-NONINTERACTIVE tile-img 1 (vector tile-layer) width height TRUE)))
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete tile-img)
|
|
|
|
weaving))
|
|
|
|
|
|
|
|
; Creates a single tile for masking
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (create-mask-tile ribbon-width
|
2006-10-16 01:08:54 +00:00
|
|
|
ribbon-spacing
|
|
|
|
r1-x1
|
|
|
|
r1-y1
|
|
|
|
r1-width
|
|
|
|
r1-height
|
|
|
|
r2-x1
|
|
|
|
r2-y1
|
|
|
|
r2-width
|
|
|
|
r2-height
|
|
|
|
r3-x1
|
|
|
|
r3-y1
|
|
|
|
r3-width
|
|
|
|
r3-height)
|
1997-11-24 22:05:25 +00:00
|
|
|
(let* ((tile-size (+ (* 2 ribbon-width) (* 2 ribbon-spacing)))
|
2006-10-16 01:08:54 +00:00
|
|
|
(img (car (gimp-image-new tile-size tile-size RGB)))
|
|
|
|
(drawable (car (gimp-layer-new img tile-size tile-size RGB-IMAGE
|
2017-01-09 20:37:30 +01:00
|
|
|
"Mask" 100 LAYER-MODE-NORMAL))))
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-disable img)
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer img drawable 0 0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(0 0 0))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-image-select-rectangle img CHANNEL-OP-REPLACE r1-x1 r1-y1 r1-width r1-height)
|
|
|
|
(gimp-image-select-rectangle img CHANNEL-OP-ADD r2-x1 r2-y1 r2-width r2-height)
|
|
|
|
(gimp-image-select-rectangle img CHANNEL-OP-ADD r3-x1 r3-y1 r3-width r3-height)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(255 255 255))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-selection-none img)
|
|
|
|
|
1999-10-17 00:07:55 +00:00
|
|
|
(gimp-image-undo-enable img)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
(list img drawable)))
|
|
|
|
|
|
|
|
; Creates a complete mask image
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (create-mask final-width
|
2006-10-16 01:08:54 +00:00
|
|
|
final-height
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
r1-x1
|
|
|
|
r1-y1
|
|
|
|
r1-width
|
|
|
|
r1-height
|
|
|
|
r2-x1
|
|
|
|
r2-y1
|
|
|
|
r2-width
|
|
|
|
r2-height
|
|
|
|
r3-x1
|
|
|
|
r3-y1
|
|
|
|
r3-width
|
|
|
|
r3-height)
|
1997-11-24 22:05:25 +00:00
|
|
|
(let* ((tile (create-mask-tile ribbon-width ribbon-spacing
|
2006-10-16 01:08:54 +00:00
|
|
|
r1-x1 r1-y1 r1-width r1-height
|
|
|
|
r2-x1 r2-y1 r2-width r2-height
|
|
|
|
r3-x1 r3-y1 r3-width r3-height))
|
|
|
|
(tile-img (car tile))
|
|
|
|
(tile-layer (cadr tile))
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(mask (plug-in-tile RUN-NONINTERACTIVE tile-img 1 (vector tile-layer) final-width final-height
|
2006-10-16 01:08:54 +00:00
|
|
|
TRUE)))
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete tile-img)
|
|
|
|
mask))
|
|
|
|
|
|
|
|
; Creates the mask for horizontal ribbons
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (create-horizontal-mask ribbon-width
|
2006-10-16 01:08:54 +00:00
|
|
|
ribbon-spacing
|
|
|
|
final-width
|
|
|
|
final-height)
|
1997-11-24 22:05:25 +00:00
|
|
|
(create-mask final-width
|
2006-10-16 01:08:54 +00:00
|
|
|
final-height
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
0
|
|
|
|
ribbon-spacing
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
ribbon-width
|
|
|
|
0
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
ribbon-spacing
|
|
|
|
ribbon-width
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
ribbon-width))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Creates the mask for vertical ribbons
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (create-vertical-mask ribbon-width
|
2006-10-16 01:08:54 +00:00
|
|
|
ribbon-spacing
|
|
|
|
final-width
|
|
|
|
final-height)
|
1997-11-24 22:05:25 +00:00
|
|
|
(create-mask final-width
|
2006-10-16 01:08:54 +00:00
|
|
|
final-height
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
0
|
|
|
|
ribbon-width
|
|
|
|
(+ (* 2 ribbon-spacing) ribbon-width)
|
|
|
|
ribbon-spacing
|
|
|
|
0
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
ribbon-spacing
|
|
|
|
(+ ribbon-width ribbon-spacing)
|
|
|
|
ribbon-width
|
|
|
|
(+ ribbon-width ribbon-spacing)))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Adds a threads layer at a certain orientation to the specified image
|
|
|
|
|
2003-07-22 14:24:11 +00:00
|
|
|
(define (create-threads-layer img
|
2006-10-16 01:08:54 +00:00
|
|
|
width
|
|
|
|
height
|
|
|
|
length
|
|
|
|
density
|
|
|
|
orientation)
|
2003-10-16 12:47:33 +00:00
|
|
|
(let* ((drawable (car (gimp-layer-new img width height RGBA-IMAGE
|
2017-01-09 20:37:30 +01:00
|
|
|
"Threads" 100 LAYER-MODE-NORMAL)))
|
2006-10-16 01:08:54 +00:00
|
|
|
(dense (/ density 100.0)))
|
2011-03-02 02:55:43 -05:00
|
|
|
(gimp-image-insert-layer img drawable 0 -1)
|
2004-09-22 18:43:09 +00:00
|
|
|
(gimp-context-set-background '(255 255 255))
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-drawable-edit-fill drawable FILL-BACKGROUND)
|
2007-10-01 19:44:23 +00:00
|
|
|
(plug-in-noisify RUN-NONINTERACTIVE img drawable FALSE dense dense dense dense)
|
|
|
|
(plug-in-c-astretch RUN-NONINTERACTIVE img drawable)
|
1997-11-24 22:05:25 +00:00
|
|
|
(cond ((eq? orientation 'horizontal)
|
2007-10-01 19:44:23 +00:00
|
|
|
(plug-in-gauss-rle RUN-NONINTERACTIVE img drawable length TRUE FALSE))
|
2006-10-16 01:08:54 +00:00
|
|
|
((eq? orientation 'vertical)
|
2007-10-01 19:44:23 +00:00
|
|
|
(plug-in-gauss-rle RUN-NONINTERACTIVE img drawable length FALSE TRUE)))
|
|
|
|
(plug-in-c-astretch RUN-NONINTERACTIVE img drawable)
|
1997-11-24 22:05:25 +00:00
|
|
|
drawable))
|
|
|
|
|
|
|
|
(define (create-complete-weave width
|
2006-10-16 01:08:54 +00:00
|
|
|
height
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
shadow-darkness
|
|
|
|
shadow-depth
|
|
|
|
thread-length
|
|
|
|
thread-density
|
|
|
|
thread-intensity)
|
2003-07-22 14:24:11 +00:00
|
|
|
(let* ((weave (create-weave width height ribbon-width ribbon-spacing
|
2006-10-16 01:08:54 +00:00
|
|
|
shadow-darkness shadow-depth))
|
|
|
|
(w-img (car weave))
|
|
|
|
(w-layer (cadr weave))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
(h-layer (create-threads-layer w-img width height thread-length
|
|
|
|
thread-density 'horizontal))
|
2017-01-09 20:37:30 +01:00
|
|
|
(h-mask (car (gimp-layer-create-mask h-layer ADD-MASK-WHITE)))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
(v-layer (create-threads-layer w-img width height thread-length
|
|
|
|
thread-density 'vertical))
|
2017-01-09 20:37:30 +01:00
|
|
|
(v-mask (car (gimp-layer-create-mask v-layer ADD-MASK-WHITE)))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
(hmask (create-horizontal-mask ribbon-width ribbon-spacing
|
|
|
|
width height))
|
|
|
|
(hm-img (car hmask))
|
|
|
|
(hm-layer (cadr hmask))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
(vmask (create-vertical-mask ribbon-width ribbon-spacing width height))
|
|
|
|
(vm-img (car vmask))
|
|
|
|
(vm-layer (cadr vmask)))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2003-12-08 22:33:17 +00:00
|
|
|
(gimp-layer-add-mask h-layer h-mask)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-selection-all hm-img)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(gimp-edit-copy 1 (vector hm-layer))
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete hm-img)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(let* (
|
|
|
|
(pasted (gimp-edit-paste h-mask FALSE))
|
|
|
|
(num-pasted (car pasted))
|
|
|
|
(floating-sel (aref (cadr pasted) (- num-pasted 1)))
|
|
|
|
)
|
|
|
|
(gimp-floating-sel-anchor floating-sel)
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-layer-set-opacity h-layer thread-intensity)
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-layer-set-mode h-layer LAYER-MODE-MULTIPLY)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2003-12-08 22:33:17 +00:00
|
|
|
(gimp-layer-add-mask v-layer v-mask)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-selection-all vm-img)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(gimp-edit-copy 1 (vector vm-layer))
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete vm-img)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(let* (
|
|
|
|
(pasted (gimp-edit-paste v-mask FALSE))
|
|
|
|
(num-pasted (car pasted))
|
|
|
|
(floating-sel (aref (cadr pasted) (- num-pasted 1)))
|
|
|
|
)
|
|
|
|
(gimp-floating-sel-anchor floating-sel)
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-layer-set-opacity v-layer thread-intensity)
|
2017-01-09 20:37:30 +01:00
|
|
|
(gimp-layer-set-mode v-layer LAYER-MODE-MULTIPLY)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; Uncomment this if you want to keep the weaving mask image
|
2001-06-12 19:23:07 +00:00
|
|
|
; (gimp-display-new (car (gimp-image-duplicate w-img)))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
(list w-img
|
2006-10-16 01:08:54 +00:00
|
|
|
(car (gimp-image-flatten w-img)))))
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
; The main weave function
|
|
|
|
|
|
|
|
(define (script-fu-weave img
|
2006-10-16 01:08:54 +00:00
|
|
|
drawable
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
shadow-darkness
|
|
|
|
shadow-depth
|
|
|
|
thread-length
|
|
|
|
thread-density
|
|
|
|
thread-intensity)
|
2018-05-16 21:34:33 +02:00
|
|
|
(gimp-context-push)
|
|
|
|
(gimp-image-undo-group-start img)
|
|
|
|
|
2006-10-16 01:08:54 +00:00
|
|
|
(let* (
|
2010-08-03 00:13:51 +03:00
|
|
|
(d-img (car (gimp-item-get-image drawable)))
|
2021-04-20 17:47:11 +02:00
|
|
|
(d-width (car (gimp-drawable-get-width drawable)))
|
|
|
|
(d-height (car (gimp-drawable-get-height drawable)))
|
|
|
|
(d-offsets (gimp-drawable-get-offsets drawable))
|
2006-10-16 01:08:54 +00:00
|
|
|
|
|
|
|
(weaving (create-complete-weave d-width
|
|
|
|
d-height
|
|
|
|
ribbon-width
|
|
|
|
ribbon-spacing
|
|
|
|
shadow-darkness
|
|
|
|
shadow-depth
|
|
|
|
thread-length
|
|
|
|
thread-density
|
|
|
|
thread-intensity))
|
|
|
|
(w-img (car weaving))
|
|
|
|
(w-layer (cadr weaving))
|
|
|
|
)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2018-04-16 20:12:12 +02:00
|
|
|
(gimp-context-set-paint-mode LAYER-MODE-NORMAL)
|
|
|
|
(gimp-context-set-opacity 100.0)
|
2011-11-06 15:55:45 -05:00
|
|
|
(gimp-context-set-feather FALSE)
|
2004-09-23 11:16:23 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-selection-all w-img)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(gimp-edit-copy 1 (vector w-layer))
|
1997-11-24 22:05:25 +00:00
|
|
|
(gimp-image-delete w-img)
|
Fix #6026, SF scripts use v3 API for multilayer gimp-edit-copy, -cut, -paste.
Why: in v3 the signature for gimp-edit-foo PDB procedures changed to support multilayer selection.
This finishes the task for ScriptFu scripts in the GIMP repo.
This is not a complete list, since some calls were changed incidentally by prior commits.
You can grep for "edit-copy" etc. in script-fu/scripts to find instances.
This also makes incidental changes, to script calls to plug-in-tile,
which now also has a changed signature to support multilayer.
The changes are simple code transformations.
The changes to gimp-edit-paste calls are more complex,
a mixed bag of a few lines transformed to more lines.
I did not try to understand the larger logic of the changed plugins.
I did not test the changed plugins functionally.
I used a harness to call each changed plugin with improvised parameters,
only checking that the test plugin did not throw runtime errors,
not checking that they produced correct images.
As noted in the issue, this might be undone if the original signatures
for gimp-edit-foo are restored as convenience functions.
2022-05-06 16:40:19 -04:00
|
|
|
(let* (
|
|
|
|
(pasted (gimp-edit-paste drawable FALSE))
|
|
|
|
(num-pasted (car pasted))
|
|
|
|
(floating-sel (aref (cadr pasted) (- num-pasted 1)))
|
|
|
|
)
|
|
|
|
(gimp-layer-set-offsets floating-sel
|
|
|
|
(car d-offsets)
|
|
|
|
(cadr d-offsets))
|
|
|
|
(gimp-layer-set-mode floating-sel LAYER-MODE-MULTIPLY)
|
|
|
|
(gimp-floating-sel-to-layer floating-sel)
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
|
|
|
)
|
2018-05-16 21:34:33 +02:00
|
|
|
(gimp-context-pop)
|
|
|
|
(gimp-image-undo-group-end img)
|
|
|
|
(gimp-displays-flush)
|
2006-10-16 01:08:54 +00:00
|
|
|
)
|
2004-11-18 22:44:28 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
(script-fu-register "script-fu-weave"
|
2006-10-16 01:08:54 +00:00
|
|
|
_"_Weave..."
|
|
|
|
_"Create a new layer filled with a weave effect to be used as an overlay or bump map"
|
|
|
|
"Federico Mena Quintero"
|
|
|
|
"Federico Mena Quintero"
|
|
|
|
"June 1997"
|
|
|
|
"RGB* GRAY*"
|
|
|
|
SF-IMAGE "Image to Weave" 0
|
|
|
|
SF-DRAWABLE "Drawable to Weave" 0
|
|
|
|
SF-ADJUSTMENT _"Ribbon width" '(30 0 256 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Ribbon spacing" '(10 0 256 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Shadow darkness" '(75 0 100 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Shadow depth" '(75 0 100 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Thread length" '(200 0 256 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Thread density" '(50 0 100 1 10 1 1)
|
|
|
|
SF-ADJUSTMENT _"Thread intensity" '(100 0 100 1 10 1 1)
|
|
|
|
)
|
2004-11-18 22:44:28 +00:00
|
|
|
|
|
|
|
(script-fu-menu-register "script-fu-weave"
|
2006-10-16 01:08:54 +00:00
|
|
|
"<Image>/Filters/Artistic")
|