5
5
; it under the terms of the GNU General Public License as published by
6
6
; the Free Software Foundation; either version 2 of the License, or
7
7
; (at your option) any later version.
9
9
; This program is distributed in the hope that it will be useful,
10
10
; but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
12
; GNU General Public License for more details.
14
14
; You should have received a copy of the GNU General Public License
15
15
; along with this program; if not, write to the Free Software
16
16
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
(define (script-fu-coffee-stain inImage
24
(set! theImage inImage)
25
(set! theHeight (car (gimp-image-height theImage)))
26
(set! theWidth (car (gimp-image-width theImage)))
27
(set! theNumber inNumber)
28
(set! theSize (min theWidth theHeight))
32
(gimp-image-undo-group-start theImage)
34
(while (> theNumber 0)
35
(set! theNumber (- theNumber 1))
36
(set! theStain (car (gimp-layer-new theImage theSize theSize
37
RGBA-IMAGE "Stain" 100
39
DARKEN-ONLY-MODE NORMAL-MODE))))
41
(gimp-image-add-layer theImage theStain 0)
42
(gimp-selection-all theImage)
43
(gimp-edit-clear theStain)
45
(let ((blobSize (/ (rand (- theSize 40)) (+ (rand 3) 1))))
46
(gimp-ellipse-select theImage
47
(/ (- theSize blobSize) 2)
48
(/ (- theSize blobSize) 2)
49
blobSize blobSize CHANNEL-OP-REPLACE TRUE 0 FALSE))
51
(script-fu-distress-selection theImage theStain
52
(* (+ (rand 15) 1) (+ (rand 15) 1))
53
(/ theSize 25) 4 2 TRUE TRUE)
55
(gimp-context-set-gradient "Coffee")
57
(gimp-edit-blend theStain CUSTOM-MODE NORMAL-MODE
58
GRADIENT-SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE
62
(gimp-layer-set-offsets theStain
63
(- (rand theWidth) (/ theSize 2))
64
(- (rand theHeight) (/ theSize 2)) theSize))
66
(gimp-selection-none theImage)
68
(gimp-image-undo-group-end theImage)
19
(define (script-fu-coffee-stain inImage inLayer inNumber inDark)
22
(theHeight (car (gimp-image-height theImage)))
23
(theWidth (car (gimp-image-width theImage)))
25
(theSize (min theWidth theHeight))
31
(gimp-image-undo-group-start theImage)
33
(while (> theNumber 0)
34
(set! theNumber (- theNumber 1))
35
(set! theStain (car (gimp-layer-new theImage theSize theSize
36
RGBA-IMAGE "Stain" 100
38
DARKEN-ONLY-MODE NORMAL-MODE))))
40
(gimp-image-add-layer theImage theStain 0)
41
(gimp-selection-all theImage)
42
(gimp-edit-clear theStain)
44
(let ((blobSize (/ (rand (- theSize 40)) (+ (rand 3) 1))))
45
(gimp-ellipse-select theImage
46
(/ (- theSize blobSize) 2)
47
(/ (- theSize blobSize) 2)
48
blobSize blobSize CHANNEL-OP-REPLACE TRUE 0 FALSE)
51
(script-fu-distress-selection theImage theStain
52
(* (+ (rand 15) 1) (+ (rand 15) 1))
53
(/ theSize 25) 4 2 TRUE TRUE)
55
(gimp-context-set-gradient "Coffee")
57
(gimp-edit-blend theStain CUSTOM-MODE NORMAL-MODE
58
GRADIENT-SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE
62
(gimp-layer-set-offsets theStain
63
(- (rand theWidth) (/ theSize 2))
64
(- (rand theHeight) (/ theSize 2)))
67
(gimp-selection-none theImage)
69
(gimp-image-undo-group-end theImage)
74
77
; Register the function with the GIMP:
76
79
(script-fu-register "script-fu-coffee-stain"
78
"Draws realistic looking coffee stains"
80
"1998, Chris Gutteridge / ECS dept, University of Southampton, England."
83
SF-IMAGE "The image" 0
84
SF-DRAWABLE "The layer" 0
85
SF-ADJUSTMENT _"Stains" '(3 1 10 1 1 0 0)
86
SF-TOGGLE _"Darken only\n(Better, but only for images with alot of white)" TRUE)
81
_"Add realistic looking coffee stains to the image"
83
"1998, Chris Gutteridge / ECS dept, University of Southampton, England."
86
SF-IMAGE "The image" 0
87
SF-DRAWABLE "The layer" 0
88
SF-ADJUSTMENT _"Stains" '(3 1 10 1 1 0 0)
89
SF-TOGGLE _"Darken only\n(Better, but only for images with a lot of white)" TRUE
88
92
(script-fu-menu-register "script-fu-coffee-stain"
89
_"<Image>/Script-Fu/Decor")
93
"<Image>/Filters/Decor")