Commit 748021dd authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

Converted the last bunch of scripts to the new context API:

2004-09-23  Sven Neumann  <sven@gimp.org>

	Converted the last bunch of scripts to the new context API:

	* plug-ins/script-fu/scripts/[s-z]*.scm
parent cf221a14
2004-09-23 Sven Neumann <sven@gimp.org>
Converted the last bunch of scripts to the new context API:
* plug-ins/script-fu/scripts/[s-z]*.scm
2004-09-23 Sven Neumann <sven@gimp.org>
Converted more scripts to the new context API:
......
......@@ -28,17 +28,17 @@
(define (script-fu-selection-to-brush image
drawable
desc
name
filename
spacing)
(let* ((type (car (gimp-drawable-type-with-alpha drawable)))
(old-bg (car (gimp-context-get-background))))
(set! selection-bounds (gimp-selection-bounds image))
(set! select-offset-x (cadr selection-bounds))
(set! select-offset-y (caddr selection-bounds))
(set! selection-width (- (cadr (cddr selection-bounds)) select-offset-x))
(set! selection-height (- (caddr (cddr selection-bounds)) select-offset-y))
(selection-bounds (gimp-selection-bounds image))
(select-offset-x (cadr selection-bounds))
(select-offset-y (caddr selection-bounds))
(selection-width (- (cadr (cddr selection-bounds)) select-offset-x))
(selection-height (- (caddr (cddr selection-bounds)) select-offset-y)))
(gimp-context-push)
(gimp-image-undo-disable image)
......@@ -94,21 +94,22 @@
(number->string image)
".gbr"))
(file-gbr-save 1 brush-image brush-draw filename2 "" spacing desc)
(gimp-brushes-refresh)
(gimp-brushes-set-brush desc)
(file-gbr-save 1 brush-image brush-draw filename2 "" spacing name)
(if (= from-selection TRUE)
(begin
(gimp-selection-load active-selection)
(gimp-image-remove-channel image active-selection)))
(gimp-context-set-background old-bg)
(gimp-image-undo-enable image)
(gimp-image-set-active-layer image drawable)
(gimp-image-delete brush-image)
(gimp-displays-flush)))
(gimp-displays-flush)
(gimp-context-pop)
(gimp-brushes-refresh)
(gimp-brushes-set-brush name)))
(script-fu-register "script-fu-selection-to-brush"
_"<Image>/Script-Fu/Selection/To _Brush..."
......
......@@ -24,16 +24,15 @@
(define (script-fu-selection-to-image image drawable)
(let* (
(draw-type (car (gimp-drawable-type-with-alpha drawable)))
(let* ((draw-type (car (gimp-drawable-type-with-alpha drawable)))
(image-type (car (gimp-image-base-type image)))
(old-bg (car (gimp-context-get-background))))
(selection-bounds (gimp-selection-bounds image))
(select-offset-x (cadr selection-bounds))
(select-offset-y (caddr selection-bounds))
(selection-width (- (cadr (cddr selection-bounds)) select-offset-x))
(selection-height (- (caddr (cddr selection-bounds)) select-offset-y)))
(set! selection-bounds (gimp-selection-bounds image))
(set! select-offset-x (cadr selection-bounds))
(set! select-offset-y (caddr selection-bounds))
(set! selection-width (- (cadr (cddr selection-bounds)) select-offset-x))
(set! selection-height (- (caddr (cddr selection-bounds)) select-offset-y))
(gimp-context-push)
(gimp-image-undo-disable image)
......@@ -48,20 +47,23 @@
(gimp-edit-copy drawable)
(set! new-image (car (gimp-image-new selection-width selection-height image-type)))
(set! new-draw (car (gimp-layer-new new-image selection-width selection-height draw-type "Selection" 100 NORMAL-MODE)))
(set! new-image (car (gimp-image-new selection-width
selection-height image-type)))
(set! new-draw (car (gimp-layer-new new-image
selection-width selection-height
draw-type "Selection" 100 NORMAL-MODE)))
(gimp-image-add-layer new-image new-draw 0)
(gimp-drawable-fill new-draw BACKGROUND-FILL)
(let ((floating-sel (car (gimp-edit-paste new-draw FALSE))))
(gimp-floating-sel-anchor floating-sel)
)
(gimp-floating-sel-anchor floating-sel))
(gimp-context-set-background old-bg)
(gimp-image-undo-enable image)
(gimp-image-set-active-layer image drawable)
(gimp-display-new new-image)
(gimp-displays-flush)))
(gimp-displays-flush)
(gimp-context-pop)))
(script-fu-register "script-fu-selection-to-image"
_"<Image>/Script-Fu/Selection/To _Image"
......
......@@ -74,8 +74,6 @@
(hole-height (/ width 12))
(hole-radius (/ hole-width 4))
(hole-start (- (/ (rand 1000) 1000) 0.5))
(old-bg (car (gimp-context-get-background)))
(old-fg (car (gimp-context-get-foreground)))
(film-layer (car (gimp-layer-new image
width
height
......@@ -93,138 +91,140 @@
(pic-layer (car (gimp-image-get-active-drawable image)))
(numbera (string-append number "A")))
(gimp-context-push)
(gimp-image-undo-disable image)
(gimp-image-undo-disable image)
; add an alpha channel to the image
(gimp-layer-add-alpha pic-layer)
(gimp-layer-add-alpha pic-layer)
; crop, resize and eventually rotate the image
(gimp-image-crop image
crop-width
crop-height
(/ (- owidth crop-width) 2)
(/ (- oheight crop-height) 2))
(gimp-image-resize image
width
height
(/ (- width crop-width) 2)
(/ (- height crop-height) 2))
(if (< ratio 1) (plug-in-rotate 1
image
pic-layer
1
FALSE))
(gimp-image-crop image
crop-width
crop-height
(/ (- owidth crop-width) 2)
(/ (- oheight crop-height) 2))
(gimp-image-resize image
width
height
(/ (- width crop-width) 2)
(/ (- height crop-height) 2))
(if (< ratio 1) (plug-in-rotate 1
image
pic-layer
1
FALSE))
; add the background layer
(gimp-drawable-fill bg-layer BACKGROUND-FILL)
(gimp-image-add-layer image bg-layer -1)
(gimp-drawable-fill bg-layer BACKGROUND-FILL)
(gimp-image-add-layer image bg-layer -1)
; add the film layer
(gimp-context-set-background '(0 0 0))
(gimp-drawable-fill film-layer BACKGROUND-FILL)
(gimp-image-add-layer image film-layer -1)
(gimp-context-set-background '(0 0 0))
(gimp-drawable-fill film-layer BACKGROUND-FILL)
(gimp-image-add-layer image film-layer -1)
; add the text
(gimp-context-set-foreground font-color)
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* -0.25 width))
(* 0.01 height)
text
0
TRUE
(* 0.040 height) PIXELS fontname)))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.75 width))
(* 0.01 height)
text
0
TRUE
(* 0.040 height) PIXELS
fontname )))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.35 width))
0.0
number
0
TRUE
(* 0.050 height) PIXELS
fontname )))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.35 width))
(* 0.94 height)
number
0
TRUE
(* 0.050 height) PIXELS
fontname )))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.85 width))
(* 0.945 height)
numbera
0
TRUE
(* 0.045 height) PIXELS
fontname )))
(gimp-context-set-foreground font-color)
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* -0.25 width))
(* 0.01 height)
text
0
TRUE
(* 0.040 height) PIXELS fontname)))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.75 width))
(* 0.01 height)
text
0
TRUE
(* 0.040 height) PIXELS
fontname )))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.35 width))
0.0
number
0
TRUE
(* 0.050 height) PIXELS
fontname )))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.35 width))
(* 0.94 height)
number
0
TRUE
(* 0.050 height) PIXELS
fontname )))
(gimp-floating-sel-anchor (car (gimp-text-fontname image
film-layer
(+ hole-start (* 0.85 width))
(* 0.945 height)
numbera
0
TRUE
(* 0.045 height) PIXELS
fontname )))
; create a mask for the holes and cut them out
(let* ((film-mask (car (gimp-layer-create-mask film-layer ADD-WHITE-MASK)))
(hole hole-start)
(top-y (* height 0.06))
(bottom-y(* height 0.855)))
(gimp-selection-none image)
(while (< hole 8)
(gimp-rect-select image
(* hole-space hole)
top-y
hole-width
hole-height
CHANNEL-OP-ADD
FALSE
0)
(gimp-rect-select image
(* hole-space hole)
bottom-y
hole-width
hole-height
CHANNEL-OP-ADD
FALSE
0)
(set! hole (+ hole 1)))
(gimp-context-set-foreground '(0 0 0))
(gimp-edit-fill film-mask BACKGROUND-FILL)
(gimp-selection-none image)
(plug-in-gauss-rle 1 image film-mask hole-radius TRUE TRUE)
(gimp-threshold film-mask 127 255)
(gimp-layer-add-mask film-layer film-mask)
(gimp-layer-remove-mask film-layer MASK-APPLY))
(let* ((film-mask (car (gimp-layer-create-mask film-layer ADD-WHITE-MASK)))
(hole hole-start)
(top-y (* height 0.06))
(bottom-y(* height 0.855)))
(gimp-selection-none image)
(while (< hole 8)
(gimp-rect-select image
(* hole-space hole)
top-y
hole-width
hole-height
CHANNEL-OP-ADD
FALSE
0)
(gimp-rect-select image
(* hole-space hole)
bottom-y
hole-width
hole-height
CHANNEL-OP-ADD
FALSE
0)
(set! hole (+ hole 1)))
(gimp-context-set-foreground '(0 0 0))
(gimp-edit-fill film-mask BACKGROUND-FILL)
(gimp-selection-none image)
(plug-in-gauss-rle 1 image film-mask hole-radius TRUE TRUE)
(gimp-threshold film-mask 127 255)
(gimp-layer-add-mask film-layer film-mask)
(gimp-layer-remove-mask film-layer MASK-APPLY))
; reorder the layers
(gimp-image-raise-layer image pic-layer)
(gimp-image-raise-layer image pic-layer)
(gimp-image-raise-layer image pic-layer)
(gimp-image-raise-layer image pic-layer)
; eventually rotate the whole thing back
(if (< ratio 1)
(plug-in-rotate 1
image
pic-layer
3
TRUE))
(if (< ratio 1)
(plug-in-rotate 1
image
pic-layer
3
TRUE))
; clean up after the script
(gimp-selection-none image)
(gimp-context-set-background old-bg)
(gimp-context-set-foreground old-fg)
(gimp-image-undo-enable image)
(if (= work-on-copy TRUE) (gimp-display-new image))
(gimp-displays-flush)))
(gimp-selection-none image)
(gimp-image-undo-enable image)
(if (= work-on-copy TRUE)
(gimp-display-new image))
(gimp-displays-flush)
(gimp-context-pop)))
(script-fu-register "script-fu-slide"
_"<Image>/Script-Fu/Decor/_Slide..."
......
......@@ -83,11 +83,9 @@
(layer2 (car (gimp-layer-new img width height GRAYA-IMAGE "Layer 2" 100 DIFFERENCE-MODE)))
(layer3 (car (gimp-layer-new img width height GRAYA-IMAGE "Layer 3" 100 NORMAL-MODE)))
(shadow (car (gimp-layer-new img width height GRAYA-IMAGE "Drop Shadow" 100 NORMAL-MODE)))
(layer-mask 0)
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background)))
(old-brush (car (gimp-brushes-get-brush)))
(old-pattern (car (gimp-patterns-get-pattern))))
(layer-mask 0))
(gimp-context-push)
(gimp-image-undo-disable img)
(gimp-image-resize img width height 0 0)
......@@ -174,12 +172,10 @@
(gimp-layer-translate layer2 (/ b-size -4) (/ b-size -4))
(gimp-layer-translate layer1 (/ b-size -4) (/ b-size -4))
(gimp-context-set-foreground old-fg)
(gimp-context-set-background old-bg)
(gimp-brushes-set-brush old-brush)
(gimp-patterns-set-pattern old-pattern)
(gimp-image-undo-enable img)
(gimp-display-new img)))
(gimp-display-new img)
(gimp-context-pop)))
(script-fu-register "script-fu-sota-chrome-logo"
_"<Toolbox>/Xtns/Script-Fu/Logos/SOTA Chrome..."
......
......@@ -29,9 +29,9 @@
(text-mask 0)
(saved-select 0)
(cell-size (/ font-size 8))
(grey (/ (* density 255) 100))
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background))))
(grey (/ (* density 255) 100)))
(gimp-context-push)
(gimp-image-undo-disable img)
(gimp-image-add-layer img bg-layer 1)
......@@ -71,11 +71,10 @@
(gimp-layer-remove-mask text-layer MASK-APPLY)
(gimp-context-set-foreground old-fg)
(gimp-context-set-background old-bg)
(gimp-image-undo-enable img)
(gimp-display-new img)))
(gimp-display-new img)
(gimp-context-pop)))
(script-fu-register "script-fu-speed-text"
_"<Toolbox>/Xtns/Script-Fu/Logos/Speed Text..."
......
......@@ -24,9 +24,9 @@
(light-y (- cy (* radius (* 0.6 (sin radians)))))
(light-end-x (+ cx (* radius (cos (+ *pi* radians)))))
(light-end-y (- cy (* radius (sin (+ *pi* radians)))))
(offset (* radius 0.1))
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background))))
(offset (* radius 0.1)))
(gimp-context-push)
(gimp-image-undo-disable img)
(gimp-image-add-layer img drawable 0)
......@@ -59,10 +59,10 @@
light-x light-y light-end-x light-end-y)
(gimp-selection-none img)
(gimp-context-set-background old-bg)
(gimp-context-set-foreground old-fg)
(gimp-image-undo-enable img)
(gimp-display-new img)))
(gimp-display-new img)
(gimp-context-pop)))
(script-fu-register "script-fu-sphere"
_"<Toolbox>/Xtns/Script-Fu/Misc/_Sphere..."
......
......@@ -116,12 +116,6 @@
(cx 0) ; Current x,y
(cy 0)
; Save old foreground color, brush, opacity and paint mode
(old-fg-color (car (gimp-context-get-foreground)))
(old-brush (car (gimp-brushes-get-brush)))
(old-opacity (car (gimp-brushes-get-opacity)))
(old-paint-mode (car (gimp-brushes-get-paint-mode)))
; If its a polygon or frame, how many sides does it have.
(poly (if (= shape 1) 4 ; A frame has four sides.
(if (> shape 1) (+ shape 1) 0)))
......@@ -242,6 +236,8 @@
;; Execution starts here.
;;
(gimp-context-push)
(gimp-image-undo-group-start img)
; Set new color, brush, opacity, paint mode.
......@@ -285,16 +281,10 @@
; Draw remaining points.
(flush-points point-index)
; Restore foreground color, brush and opacity
(gimp-context-set-foreground old-fg-color)
(gimp-brushes-set-brush old-brush)
(gimp-brushes-set-opacity old-opacity)
(gimp-brushes-set-paint-mode old-paint-mode)
(gimp-image-undo-group-end img)
(gimp-displays-flush)
)
)
(gimp-context-pop)))
; This routine is invoked by a dialog.
......
......@@ -18,10 +18,9 @@
(bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
(shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Shadow" 100 NORMAL-MODE)))
(burst-layer (car (gimp-layer-new img width height RGBA-IMAGE "Burst" 100 NORMAL-MODE)))
(layer-mask (car (gimp-layer-create-mask burst-layer ADD-BLACK-MASK)))
(old-pattern (car (gimp-patterns-get-pattern)))
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background))))
(layer-mask (car (gimp-layer-create-mask burst-layer ADD-BLACK-MASK))))
(gimp-context-push)
(gimp-selection-none img)
(script-fu-util-image-resize-from-layer img logo-layer)
......@@ -59,9 +58,7 @@
(set! count (+ count 1)))
(gimp-selection-none img)
(gimp-patterns-set-pattern old-pattern)
(gimp-context-set-background old-bg)
(gimp-context-set-foreground old-fg)))
(gimp-context-pop)))
(define (script-fu-starburst-logo-alpha img
......
......@@ -59,10 +59,9 @@
(bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
(glow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Glow" 100 NORMAL-MODE)))
(shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Drop Shadow" 100 NORMAL-MODE)))
(bump-channel (car (gimp-channel-new img width height "Bump Map" 50 '(0 0 0))))
(old-pattern (car (gimp-patterns-get-pattern)))
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background))))
(bump-channel (car (gimp-channel-new img width height "Bump Map" 50 '(0 0 0)))))
(gimp-context-push)
(gimp-selection-none img)
(script-fu-util-image-resize-from-layer img logo-layer)
......@@ -109,9 +108,8 @@
(gimp-image-remove-channel img bump-channel)
(gimp-selection-none img)
(gimp-patterns-set-pattern old-pattern)
(gimp-context-set-background old-bg)
(gimp-context-set-foreground old-fg)))
(gimp-context-pop)))
(define (script-fu-starscape-logo-alpha img
logo-layer
......
......@@ -13,8 +13,10 @@
(layer-one (car (gimp-layer-new img width height
RGB-IMAGE "TEST" 100 NORMAL-MODE)))
(cx (/ width 2))
(cy (/ height 2))
(old-bg (car (gimp-context-get-background))))
(cy (/ height 2)))
(gimp-context-push)
(gimp-image-undo-disable img)
(gimp-context-set-background bg-color)
(gimp-edit-fill layer-one BACKGROUND-FILL)
......@@ -36,7 +38,9 @@
(plug-in-bump-map 1 img layer-one layer-one azimuth elevation depth 0 0 0 0 FALSE FALSE 0)
(gimp-display-new img)
(gimp-image-undo-enable img)))
(gimp-image-undo-enable img)
(gimp-context-pop)))
(script-fu-register "script-fu-swirl-tile"
_"<Toolbox>/Xtns/Script-Fu/Patterns/Swirl-_Tile..."
......
......@@ -32,12 +32,9 @@
(img (car (gimp-image-new img-size img-size RGB)))
(drawable (car (gimp-layer-new img img-size img-size
RGB-IMAGE "Swirly pattern"
100 NORMAL-MODE)))
100 NORMAL-MODE))))
; Save old foregound and background colors
(old-fg-color (car (gimp-context-get-foreground)))
(old-bg-color (car (gimp-context-get-background))))
(gimp-context-push)
(gimp-image-undo-disable img)
(gimp-image-add-layer img drawable 0)
......@@ -74,10 +71,10 @@
; Terminate
(gimp-selection-none img)
(gimp-context-set-foreground old-fg-color)
(gimp-context-set-background old-bg-color)
(gimp-image-undo-enable img)
(gimp-display-new img)))
(gimp-display-new img)
(gimp-context-pop)))
(script-fu-register "script-fu-swirly-pattern"
_"<Toolbox>/Xtns/Script-Fu/Patterns/_Swirly..."
......
......@@ -18,11 +18,10 @@
(shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Shadow" 90 ADDITION-MODE)))
(bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
(selection 0)
(white '(255 255 255))
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background)))
(old-brush (car (gimp-brushes-get-brush)))
(old-paint-mode (car (gimp-brushes-get-paint-mode))))
(white '(255 255 255)))
(gimp-context-push)
(script-fu-util-image-resize-from-layer img logo-layer)
(gimp-image-add-layer img sparkle-layer 2)
(gimp-image-add-layer img shadow-layer 3)
......@@ -71,12 +70,10 @@
(gimp-brushes-set-brush "Circle Fuzzy (07)")
(gimp-context-set-foreground '(255 255 255))
(gimp-selection-none img)
(gimp-context-set-foreground old-fg)
(gimp-context-set-background old-bg)
(gimp-brushes-set-brush old-brush)
(gimp-brushes-set-paint-mode old-paint-mode)
(gimp-drawable-set-visible logo-layer 0)
(gimp-image-set-active-layer img sparkle-layer)))
(gimp-image-set-active-layer img sparkle-layer)
(gimp-context-pop)))
(define (script-fu-t-o-p-logo-alpha img
......
......@@ -32,10 +32,9 @@
(drop-shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Drop Shadow" 100 MULTIPLY-MODE)))
(dsl-layer-mask (car (gimp-layer-create-mask drop-shadow-layer
ADD-BLACK-MASK)))
(old-fg (car (gimp-context-get-foreground)))
(old-bg (car (gimp-context-get-background)))
(old-pattern (car (gimp-patterns-get-pattern))))
ADD-BLACK-MASK))))
(gimp-context-push)
(script-fu-util-image-resize-from-layer img logo-layer)
(gimp-image-add-layer img shadow-layer 1)
......@@ -93,9 +92,8 @@
(gimp-edit-fill dsl-layer-mask BACKGROUND-FILL)
(gimp-layer-remove-mask drop-shadow-layer MASK-APPLY)
(gimp-selection-none img)