~ubuntu-branches/ubuntu/breezy/gimp/breezy

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/alien-neon-logo.scm

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-10-04 19:04:46 UTC
  • Revision ID: james.westby@ubuntu.com-20051004190446-ukh32kwk56s4sjhu
Tags: upstream-2.2.8
ImportĀ upstreamĀ versionĀ 2.2.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; The GIMP -- an image manipulation program
 
2
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 
4
; alien-neon-logo.scm - creates multiple outlines around the letters
 
5
; Copyright (C) 1999-2000 Raphael Quinet <quinet@gamers.org>
 
6
;
 
7
; This program is free software; you can redistribute it and/or modify
 
8
; it under the terms of the GNU General Public License as published by
 
9
; the Free Software Foundation; either version 2 of the License, or
 
10
; (at your option) any later version.
 
11
 
12
; This program is distributed in the hope that it will be useful,
 
13
; but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
; GNU General Public License for more details.
 
16
 
17
; You should have received a copy of the GNU General Public License
 
18
; along with this program; if not, write to the Free Software
 
19
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
20
;
 
21
; 1999-12-01 First version.
 
22
; 2000-02-19 Do not discard the layer mask so that it can still be edited.
 
23
; 2000-03-08 Adapted the script to my gimp-edit-fill changes.
 
24
; 2000-04-02 Split the script in two parts: one using text, one using alpha.
 
25
; 2000-05-29 More modifications for "Alpha to Logo" using a separate function.
 
26
;
 
27
; To do: use a channel mask for creating the bands, instead of working in the
 
28
; image.  gimp-invert would then work on one grayscale channel instead of
 
29
; wasting CPU cycles on three identical R, G, B channels.
 
30
 
31
 
 
32
(define (apply-alien-neon-logo-effect img
 
33
                                      logo-layer
 
34
                                      fg-color
 
35
                                      bg-color 
 
36
                                      band-size 
 
37
                                      gap-size 
 
38
                                      num-bands 
 
39
                                      do-fade)
 
40
  (let* ((fade-size (- (* (+ band-size gap-size) num-bands) 1))
 
41
         (width (car (gimp-drawable-width logo-layer)))
 
42
         (height (car (gimp-drawable-height logo-layer)))
 
43
         (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
 
44
         (bands-layer (car (gimp-layer-new img width height RGBA-IMAGE "Bands" 100 NORMAL-MODE))))
 
45
 
 
46
    (gimp-context-push)
 
47
 
 
48
    (script-fu-util-image-resize-from-layer img logo-layer)
 
49
    (gimp-image-add-layer img bg-layer 1)
 
50
    (gimp-image-add-layer img bands-layer 1)
 
51
    (gimp-selection-none img)
 
52
    (gimp-context-set-background bg-color)
 
53
    (gimp-edit-fill bg-layer BACKGROUND-FILL)
 
54
    (gimp-context-set-background '(0 0 0))
 
55
    (gimp-edit-fill bands-layer BACKGROUND-FILL)
 
56
    ; The text layer is never shown: it is only used to create a selection
 
57
    (gimp-selection-layer-alpha logo-layer)
 
58
    (gimp-context-set-foreground '(255 255 255))
 
59
    (gimp-edit-fill bands-layer FOREGROUND-FILL)
 
60
 
 
61
    ; Create multiple outlines by growing and inverting the selection
 
62
    ; The bands are black and white because they will be used as a mask.
 
63
    (while (> num-bands 0)
 
64
           (gimp-selection-grow img band-size)
 
65
           (gimp-invert bands-layer)
 
66
           (gimp-selection-grow img gap-size)
 
67
           (gimp-invert bands-layer)
 
68
           (set! num-bands (- num-bands 1)))
 
69
 
 
70
    ; The fading effect is obtained by masking the image with a gradient.
 
71
    ; The gradient is created by filling a bordered selection (white->black).
 
72
    (if (= do-fade TRUE)
 
73
        (let ((bands-layer-mask (car (gimp-layer-create-mask bands-layer
 
74
                                                             ADD-BLACK-MASK))))
 
75
          (gimp-layer-add-mask bands-layer bands-layer-mask)
 
76
          (gimp-selection-layer-alpha logo-layer)
 
77
          (gimp-selection-border img fade-size)
 
78
          (gimp-edit-fill bands-layer-mask FOREGROUND-FILL)
 
79
          (gimp-layer-remove-mask bands-layer MASK-APPLY)))
 
80
 
 
81
    ; Transfer the resulting grayscale bands into the layer mask.
 
82
    (let ((bands-layer-mask (car (gimp-layer-create-mask bands-layer
 
83
                                                         ADD-BLACK-MASK))))
 
84
      (gimp-layer-add-mask bands-layer bands-layer-mask)
 
85
      (gimp-selection-none img)
 
86
      (gimp-edit-copy bands-layer)
 
87
      (gimp-floating-sel-anchor (car (gimp-edit-paste bands-layer-mask
 
88
                                                      FALSE))))
 
89
 
 
90
    ; Fill the layer with the foreground color.  The areas that are not
 
91
    ; masked become visible.
 
92
    (gimp-context-set-foreground fg-color)
 
93
    (gimp-edit-fill bands-layer FOREGROUND-FILL)
 
94
    ;; (gimp-layer-remove-mask bands-layer MASK-APPLY)
 
95
 
 
96
    ; Clean up and exit.
 
97
    (gimp-drawable-set-visible logo-layer 0)
 
98
    (gimp-image-set-active-layer img bands-layer)
 
99
    (gimp-displays-flush)
 
100
    
 
101
    (gimp-context-pop)))
 
102
 
 
103
(define (script-fu-alien-neon-logo-alpha img
 
104
                                         logo-layer
 
105
                                         fg-color
 
106
                                         bg-color
 
107
                                         band-size
 
108
                                         gap-size
 
109
                                         num-bands
 
110
                                         do-fade)
 
111
  (begin
 
112
    (gimp-image-undo-group-start img)
 
113
    (apply-alien-neon-logo-effect img logo-layer fg-color bg-color 
 
114
                                  band-size gap-size num-bands do-fade)
 
115
    (gimp-image-undo-group-end img)
 
116
    (gimp-displays-flush)))
 
117
 
 
118
(script-fu-register "script-fu-alien-neon-logo-alpha"
 
119
                    _"Alien _Neon..."
 
120
                    "Creates a psychedelic effect with outlines of the specified color around the letters"
 
121
                    "Raphael Quinet (quinet@gamers.org)"
 
122
                    "Raphael Quinet"
 
123
                    "1999-2000"
 
124
                    "RGBA"
 
125
                    SF-IMAGE      "Image"             0
 
126
                    SF-DRAWABLE   "Drawable"          0
 
127
                    SF-COLOR      _"Glow color"       '(0 255 0)
 
128
                    SF-COLOR      _"Background color" '(0 0 0)
 
129
                    SF-ADJUSTMENT _"Width of bands"   '(2 1 60 1 10 0 0)
 
130
                    SF-ADJUSTMENT _"Width of gaps"    '(2 1 60 1 10 0 0)
 
131
                    SF-ADJUSTMENT _"Number of bands"  '(7 1 100 1 10 0 1)
 
132
                    SF-TOGGLE     _"Fade away"        TRUE)
 
133
 
 
134
(script-fu-menu-register "script-fu-alien-neon-logo-alpha"
 
135
                         _"<Image>/Script-Fu/Alpha to Logo")
 
136
 
 
137
 
 
138
(define (script-fu-alien-neon-logo text 
 
139
                                   size 
 
140
                                   fontname 
 
141
                                   fg-color 
 
142
                                   bg-color 
 
143
                                   band-size 
 
144
                                   gap-size 
 
145
                                   num-bands 
 
146
                                   do-fade)
 
147
  (let* ((img (car (gimp-image-new 256 256 RGB)))
 
148
         (fade-size (- (* (+ band-size gap-size) num-bands) 1))
 
149
         (text-layer (car (gimp-text-fontname img -1 0 0 text (+ fade-size 10) TRUE size PIXELS fontname))))
 
150
    (gimp-image-undo-disable img)
 
151
    (gimp-drawable-set-name text-layer text)
 
152
    (apply-alien-neon-logo-effect img text-layer fg-color bg-color
 
153
                                  band-size gap-size num-bands do-fade)
 
154
    (gimp-image-undo-enable img)
 
155
    (gimp-display-new img)))
 
156
 
 
157
(script-fu-register "script-fu-alien-neon-logo"
 
158
                    _"Alien _Neon..."
 
159
                    "Creates a psychedelic effect with outlines of the specified color around the letters"
 
160
                    "Raphael Quinet (quinet@gamers.org)"
 
161
                    "Raphael Quinet"
 
162
                    "1999-2000"
 
163
                    ""
 
164
                    SF-STRING     _"Text"               "The GIMP"
 
165
                    SF-ADJUSTMENT _"Font size (pixels)" '(150 2 1000 1 10 0 1)
 
166
                    SF-FONT       _"Font"               "Blippo"
 
167
                    SF-COLOR      _"Glow color"         '(0 255 0)
 
168
                    SF-COLOR      _"Background color"   '(0 0 0)
 
169
                    SF-ADJUSTMENT _"Width of bands"     '(2 1 60 1 10 0 0)
 
170
                    SF-ADJUSTMENT _"Width of gaps"      '(2 1 60 1 10 0 0)
 
171
                    SF-ADJUSTMENT _"Number of bands"    '(7 1 100 1 10 0 1)
 
172
                    SF-TOGGLE     _"Fade away"          TRUE)
 
173
 
 
174
(script-fu-menu-register "script-fu-alien-neon-logo"
 
175
                         _"<Toolbox>/Xtns/Script-Fu/Logos")