~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/coffee.scm

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
8
 
 
8
;
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.
13
 
 
13
;
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.
17
17
 
18
18
 
19
 
(define (script-fu-coffee-stain inImage
20
 
                                inLayer
21
 
                                inNumber
22
 
                                inDark)
23
 
 
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))
29
 
 
30
 
   (gimp-context-push)
31
 
 
32
 
   (gimp-image-undo-group-start theImage)
33
 
 
34
 
   (while (> theNumber 0)
35
 
          (set! theNumber (- theNumber 1))
36
 
          (set! theStain (car (gimp-layer-new theImage theSize theSize
37
 
                                              RGBA-IMAGE "Stain" 100
38
 
                                              (if (= inDark TRUE)
39
 
                                                  DARKEN-ONLY-MODE NORMAL-MODE))))
40
 
 
41
 
          (gimp-image-add-layer theImage theStain 0)
42
 
          (gimp-selection-all theImage)
43
 
          (gimp-edit-clear theStain)
44
 
 
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))
50
 
 
51
 
          (script-fu-distress-selection theImage theStain
52
 
                                        (* (+ (rand 15) 1) (+ (rand 15) 1))
53
 
                                        (/ theSize 25) 4 2 TRUE TRUE)
54
 
 
55
 
          (gimp-context-set-gradient "Coffee")
56
 
 
57
 
          (gimp-edit-blend theStain CUSTOM-MODE NORMAL-MODE
58
 
                           GRADIENT-SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE
59
 
                           FALSE 0 0 TRUE
60
 
                           0 0 0 0)
61
 
 
62
 
          (gimp-layer-set-offsets theStain
63
 
                                  (- (rand theWidth) (/ theSize 2))
64
 
                                  (- (rand theHeight) (/ theSize 2)) theSize))
65
 
 
66
 
   (gimp-selection-none theImage)
67
 
 
68
 
   (gimp-image-undo-group-end theImage)
69
 
 
70
 
   (gimp-displays-flush)
71
 
 
72
 
   (gimp-context-pop))
 
19
(define (script-fu-coffee-stain inImage inLayer inNumber inDark)
 
20
  (let* (
 
21
        (theImage inImage)
 
22
        (theHeight (car (gimp-image-height theImage)))
 
23
        (theWidth (car (gimp-image-width theImage)))
 
24
        (theNumber inNumber)
 
25
        (theSize (min theWidth theHeight))
 
26
        (theStain)
 
27
        )
 
28
 
 
29
    (gimp-context-push)
 
30
 
 
31
    (gimp-image-undo-group-start theImage)
 
32
 
 
33
    (while (> theNumber 0)
 
34
      (set! theNumber (- theNumber 1))
 
35
      (set! theStain (car (gimp-layer-new theImage theSize theSize
 
36
                                          RGBA-IMAGE "Stain" 100
 
37
                                          (if (= inDark TRUE)
 
38
                                              DARKEN-ONLY-MODE NORMAL-MODE))))
 
39
 
 
40
      (gimp-image-add-layer theImage theStain 0)
 
41
      (gimp-selection-all theImage)
 
42
      (gimp-edit-clear theStain)
 
43
 
 
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)
 
49
      )
 
50
 
 
51
      (script-fu-distress-selection theImage theStain
 
52
                                    (* (+ (rand 15) 1) (+ (rand 15) 1))
 
53
                                    (/ theSize 25) 4 2 TRUE TRUE)
 
54
 
 
55
      (gimp-context-set-gradient "Coffee")
 
56
 
 
57
      (gimp-edit-blend theStain CUSTOM-MODE NORMAL-MODE
 
58
                       GRADIENT-SHAPEBURST-DIMPLED 100 0 REPEAT-NONE FALSE
 
59
                       FALSE 0 0 TRUE
 
60
                       0 0 0 0)
 
61
 
 
62
      (gimp-layer-set-offsets theStain
 
63
                              (- (rand theWidth) (/ theSize 2))
 
64
                              (- (rand theHeight) (/ theSize 2)))
 
65
    )
 
66
 
 
67
    (gimp-selection-none theImage)
 
68
 
 
69
    (gimp-image-undo-group-end theImage)
 
70
 
 
71
    (gimp-displays-flush)
 
72
 
 
73
    (gimp-context-pop)
 
74
  )
 
75
)
73
76
 
74
77
; Register the function with the GIMP:
75
78
 
76
79
(script-fu-register "script-fu-coffee-stain"
77
 
                    _"_Coffee Stain..."
78
 
                    "Draws realistic looking coffee stains"
79
 
                    "Chris Gutteridge"
80
 
                    "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
81
 
                    "25th April 1998"
82
 
                    "RGB*"
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)
 
80
  _"_Coffee Stain..."
 
81
  _"Add realistic looking coffee stains to the image"
 
82
  "Chris Gutteridge"
 
83
  "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
 
84
  "25th April 1998"
 
85
  "RGB*"
 
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
 
90
)
87
91
 
88
92
(script-fu-menu-register "script-fu-coffee-stain"
89
 
                         _"<Image>/Script-Fu/Decor")
 
93
                         "<Image>/Filters/Decor")