[gimp/gimp-2-10] Issue #360 - scripts that require brushes that GIMP no longer installs
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] Issue #360 - scripts that require brushes that GIMP no longer installs
- Date: Sun, 14 Jul 2019 12:02:16 +0000 (UTC)
commit 4bdb8792b5bd00f7bc8aa8af93e3ab3051896775
Author: Michael Natterer <mitch gimp org>
Date: Sun Jul 14 13:59:11 2019 +0200
Issue #360 - scripts that require brushes that GIMP no longer installs
carve-it.scm, chrome-it.scm: apply slightly modified patch from Carol
Spears which replaces hardcoding round brush names by creating a brush
on the fly and setting its radius.
Also fixed both scripts to not use deprecated color API which is
even completely gone from master.
(cherry picked from commit 3d049f565a3a88189e8d28562c0298042f717c2c)
plug-ins/script-fu/scripts/carve-it.scm | 42 +++++++++++++++++-----------
plug-ins/script-fu/scripts/chrome-it.scm | 48 +++++++++++++++++---------------
2 files changed, 51 insertions(+), 39 deletions(-)
---
diff --git a/plug-ins/script-fu/scripts/carve-it.scm b/plug-ins/script-fu/scripts/carve-it.scm
index efe2279194..a88fa086eb 100644
--- a/plug-ins/script-fu/scripts/carve-it.scm
+++ b/plug-ins/script-fu/scripts/carve-it.scm
@@ -6,24 +6,15 @@
; This layer is used as the mask for the carving effect
; NOTE: This script requires the image to be carved to either be an
; RGB color or grayscale image with a single layer. An indexed file
-; can not be used due to the use of gimp-histogram and gimp-levels.
+; can not be used due to the use of gimp-drawable-histogram and
+; gimp-drawable-levels.
-(define (carve-brush brush-size)
- (cond ((<= brush-size 5) "Circle (05)")
- ((<= brush-size 7) "Circle (07)")
- ((<= brush-size 9) "Circle (09)")
- ((<= brush-size 11) "Circle (11)")
- ((<= brush-size 13) "Circle (13)")
- ((<= brush-size 15) "Circle (15)")
- ((<= brush-size 17) "Circle (17)")
- (else "Circle (19)")))
-
(define (carve-scale val scale)
(* (sqrt val) scale))
(define (calculate-inset-gamma img layer)
- (let* ((stats (gimp-histogram layer 0 0 255))
+ (let* ((stats (gimp-drawable-histogram layer 0 0.0 1.0))
(mean (car stats)))
(cond ((< mean 127) (+ 1.0 (* 0.5 (/ (- 127 mean) 127.0))))
((>= mean 127) (- 1.0 (* 0.5 (/ (- mean 127) 127.0)))))))
@@ -56,6 +47,7 @@
(offy (carve-scale size 0.25))
(feather (carve-scale size 0.3))
(brush-size (carve-scale size 0.3))
+ (brush-name (car (gimp-brush-new "Carve It")))
(mask-fs 0)
(mask (car (gimp-channel-new img width height "Engraving Mask" 50 '(0 0 0))))
(inset-gamma (calculate-inset-gamma (car (gimp-item-get-image bg-layer)) bg-layer))
@@ -100,7 +92,17 @@
(set! mask-fat (car (gimp-channel-copy mask)))
(gimp-image-insert-channel img mask-fat -1 0)
(gimp-image-select-item img CHANNEL-OP-REPLACE mask-fat)
- (gimp-context-set-brush (carve-brush brush-size))
+
+ (gimp-brush-set-shape brush-name BRUSH-GENERATED-CIRCLE)
+ (gimp-brush-set-spikes brush-name 2)
+ (gimp-brush-set-hardness brush-name 1.0)
+ (gimp-brush-set-spacing brush-name 25)
+ (gimp-brush-set-aspect-ratio brush-name 1)
+ (gimp-brush-set-angle brush-name 0)
+ (cond (<= brush-size 17) (gimp-brush-set-radius brush-name (\ brush-size 2))
+ (else gimp-brush-set-radius brush-name (\ 19 2)))
+ (gimp-context-set-brush brush-name)
+
(gimp-context-set-foreground '(255 255 255))
(gimp-drawable-edit-stroke-selection mask-fat)
(gimp-selection-none img)
@@ -120,10 +122,16 @@
(set! mask-highlight (car (gimp-channel-copy mask-emboss)))
(gimp-image-insert-channel img mask-highlight -1 0)
- (gimp-levels mask-highlight 0 180 255 1.0 0 255)
+ (gimp-drawable-levels mask-highlight 0
+ 0.7056 1.0 TRUE
+ 1.0
+ 0.0 1.0 TRUE)
(set! mask-shadow mask-emboss)
- (gimp-levels mask-shadow 0 0 180 1.0 0 255)
+ (gimp-drawable-levels mask-shadow 0
+ 0.0 0.70586 TRUE
+ 1.0
+ 0.0 1.0 TRUE)
(gimp-edit-copy mask-shadow)
(set! shadow-layer (car (gimp-edit-paste layer1 FALSE)))
@@ -159,7 +167,7 @@
(gimp-drawable-edit-fill il-mask FILL-BACKGROUND)
(gimp-selection-none img)
(gimp-selection-none bg-image)
- (gimp-levels inset-layer 0 0 255 inset-gamma 0 255)
+ (gimp-drawable-levels inset-layer 0 0.0 1.0 TRUE inset-gamma 0.0 1.0 TRUE)
(gimp-image-remove-channel img mask)
(gimp-image-remove-channel img mask-fat)
(gimp-image-remove-channel img mask-highlight)
@@ -171,6 +179,8 @@
(gimp-item-set-name cast-shadow-layer _"Cast Shadow")
(gimp-item-set-name inset-layer _"Inset")
+ (gimp-brush-delete brush-name)
+
(gimp-display-new img)
(gimp-image-undo-enable img)
diff --git a/plug-ins/script-fu/scripts/chrome-it.scm b/plug-ins/script-fu/scripts/chrome-it.scm
index e5f1e1c378..761ac475ac 100644
--- a/plug-ins/script-fu/scripts/chrome-it.scm
+++ b/plug-ins/script-fu/scripts/chrome-it.scm
@@ -14,31 +14,20 @@
)
(define (spline-chrome-it)
- (let* ((a (cons-array 18 'byte)))
- (set-pt a 0 0 0)
- (set-pt a 1 31 235)
- (set-pt a 2 63 23)
- (set-pt a 3 95 230)
- (set-pt a 4 127 25)
- (set-pt a 5 159 210)
- (set-pt a 6 191 20)
- (set-pt a 7 223 240)
- (set-pt a 8 255 31)
+ (let* ((a (cons-array 18 'double)))
+ (set-pt a 0 0.0 0.0)
+ (set-pt a 1 0.125 0.9216)
+ (set-pt a 2 0.25 0.0902)
+ (set-pt a 3 0.375 0.9020)
+ (set-pt a 4 0.5 0.0989)
+ (set-pt a 5 0.625 0.9549)
+ (set-pt a 6 0.75 00784)
+ (set-pt a 7 0.875 0.9412)
+ (set-pt a 8 1.0 0.1216)
a
)
)
- (define (brush brush-size)
- (cond ((<= brush-size 5) "Circle Fuzzy (05)")
- ((<= brush-size 7) "Circle Fuzzy (07)")
- ((<= brush-size 9) "Circle Fuzzy (09)")
- ((<= brush-size 11) "Circle Fuzzy (11)")
- ((<= brush-size 13) "Circle Fuzzy (13)")
- ((<= brush-size 15) "Circle Fuzzy (15)")
- ((<= brush-size 17) "Circle Fuzzy (17)")
- (else "Circle Fuzzy (19)")
- )
- )
(define (shadows val)
(/ (* 0.96 val) 2.55)
@@ -99,6 +88,7 @@
(offy2 (sota-scale size (- 0.25) chrome-factor))
(feather (sota-scale size 0.5 chrome-factor))
(brush-size (sota-scale size 0.5 chrome-factor))
+ (brush-name (car (gimp-brush-new "Chrome It")))
(mask (car (gimp-channel-new img width height "Chrome Stencil" 50 '(0 0 0))))
(bg-layer (car (gimp-layer-new img width height GRAY-IMAGE _"Background" 100 LAYER-MODE-NORMAL)))
(layer1 (car (gimp-layer-new img banding-width banding-height banding-type _"Layer 1" 100
LAYER-MODE-NORMAL)))
@@ -154,7 +144,7 @@
(plug-in-gauss-iir RUN-NONINTERACTIVE img layer1 10 TRUE TRUE)
(gimp-layer-set-opacity layer1 50)
(set! layer1 (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))
- (gimp-curves-spline layer1 HISTOGRAM-VALUE 18 (spline-chrome-it))
+ (gimp-drawable-curves-spline layer1 HISTOGRAM-VALUE 18 (spline-chrome-it))
(set! layer-mask (car (gimp-layer-create-mask layer1 ADD-MASK-BLACK)))
(gimp-layer-add-mask layer1 layer-mask)
@@ -164,7 +154,17 @@
(set! layer2 (car (gimp-layer-copy layer1 TRUE)))
(gimp-image-insert-layer img layer2 0 0)
- (gimp-context-set-brush (brush brush-size))
+
+ (gimp-brush-set-shape brush-name BRUSH-GENERATED-CIRCLE)
+ (gimp-brush-set-spikes brush-name 2)
+ (gimp-brush-set-hardness brush-name 1.0)
+ (gimp-brush-set-spacing brush-name 25)
+ (gimp-brush-set-aspect-ratio brush-name 1)
+ (gimp-brush-set-angle brush-name 0)
+ (cond (<= brush-size 17) (gimp-brush-set-radius brush-name (\ brush-size 2))
+ (else gimp-brush-set-radius brush-name (\ 19 2)))
+ (gimp-context-set-brush brush-name)
+
(gimp-context-set-foreground '(255 255 255))
(gimp-drawable-edit-stroke-selection layer-mask)
@@ -219,6 +219,8 @@
(gimp-image-remove-channel img mask)
+ (gimp-brush-delete brush-name)
+
(gimp-display-new img)
(gimp-image-undo-enable img)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]