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

« back to all changes in this revision

Viewing changes to plug-ins/script-fu/scripts/starscape-logo.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:
1
1
;  Nova Starscape
2
2
;  Create a text effect that simulates an eerie alien glow around text
3
3
 
4
 
(define (find-blend-coords w
5
 
                           h)
6
 
  (let* ((denom (+ (/ w h) (/ h w)))
7
 
         (bx    (/ (* -2 h) denom))
8
 
         (by    (/ (* -2 w) denom)))
9
 
    (cons bx by)))
10
 
 
11
 
(define (find-nova-x-coord drawable
12
 
                           x1
13
 
                           x2
14
 
                           y)
15
 
  (let* ((x 0)
16
 
         (alpha 3)
17
 
         (range (- x2 x1))
18
 
         (min-clearance 5)
19
 
         (val '())
20
 
         (val-left '())
21
 
         (val-right '())
22
 
         (val-top '())
23
 
         (val-bottom '())
24
 
         (limit 100)
25
 
         (clearance 0))
26
 
    (while (and (= clearance 0) (> limit 0))
27
 
           (set! x (+ (rand range) x1))
28
 
           (set! val (cadr (gimp-drawable-get-pixel drawable x y)))
29
 
           (set! val-left (cadr (gimp-drawable-get-pixel drawable (- x min-clearance) y)))
30
 
           (set! val-right (cadr (gimp-drawable-get-pixel drawable (+ x min-clearance) y)))
31
 
           (set! val-top (cadr (gimp-drawable-get-pixel drawable x (- y min-clearance))))
32
 
           (set! val-bottom (cadr (gimp-drawable-get-pixel drawable x (+ y min-clearance))))
33
 
           (if (and (= (aref val alpha) 0) (= (aref val-left alpha) 0) (= (aref val-right alpha) 0)
34
 
                    (= (aref val-top alpha) 0) (= (aref val-bottom alpha) 0))
35
 
               (set! clearance 1) (set! limit (- limit 1))))
36
 
    x))
37
 
 
38
 
(define (apply-starscape-logo-effect img
39
 
                                     logo-layer
40
 
                                     size
41
 
                                     glow-color)
42
 
  (let* ((border (/ size 4))
43
 
         (grow (/ size 30))
44
 
         (offx (* size 0.03))
45
 
         (offy (* size 0.02))
46
 
         (feather (/ size 4))
47
 
         (shadow-feather (/ size 25))
48
 
         (width (car (gimp-drawable-width logo-layer)))
49
 
         (height (car (gimp-drawable-height logo-layer)))
50
 
         (w (* (/ (- width (* border 2)) 2.0) 0.75))
51
 
         (h (* (/ (- height (* border 2)) 2.0) 0.75))
52
 
         (novay (* height 0.3))
53
 
         (novax (find-nova-x-coord logo-layer (* width 0.2) (* width 0.8) novay))
54
 
         (novaradius (/ (min height width) 7.0))
55
 
         (cx (/ width 2.0))
56
 
         (cy (/ height 2.0))
57
 
         (bx (+ cx (car (find-blend-coords w h))))
58
 
         (by (+ cy (cdr (find-blend-coords w h))))
59
 
         (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
60
 
         (glow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Glow" 100 NORMAL-MODE)))
61
 
         (shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Drop Shadow" 100 NORMAL-MODE)))
62
 
         (bump-channel (car (gimp-channel-new img width height "Bump Map" 50 '(0 0 0)))))
 
4
(define (apply-starscape-logo-effect img logo-layer size glow-color)
 
5
 
 
6
  (define (find-blend-coords w h)
 
7
    (let* (
 
8
          (denom (+ (/ w h) (/ h w)))
 
9
          (bx    (/ (* -2 h) denom))
 
10
          (by    (/ (* -2 w) denom))
 
11
          )
 
12
      (cons bx by)
 
13
    )
 
14
  )
 
15
 
 
16
  (define (find-nova-x-coord drawable x1 x2 y)
 
17
    (let* (
 
18
          (x 0)
 
19
          (alpha 3)
 
20
          (range (- x2 x1))
 
21
          (min-clearance 5)
 
22
          (val '())
 
23
          (val-left '())
 
24
          (val-right '())
 
25
          (val-top '())
 
26
          (val-bottom '())
 
27
          (limit 100)
 
28
          (clearance 0)
 
29
          )
 
30
 
 
31
      (while (and (= clearance 0) (> limit 0))
 
32
         (set! x (+ (rand range) x1))
 
33
         (set! val (cadr (gimp-drawable-get-pixel drawable x y)))
 
34
         (set! val-left (cadr (gimp-drawable-get-pixel drawable (- x min-clearance) y)))
 
35
         (set! val-right (cadr (gimp-drawable-get-pixel drawable (+ x min-clearance) y)))
 
36
         (set! val-top (cadr (gimp-drawable-get-pixel drawable x (- y min-clearance))))
 
37
         (set! val-bottom (cadr (gimp-drawable-get-pixel drawable x (+ y min-clearance))))
 
38
         (if (and (= (aref val alpha) 0) (= (aref val-left alpha) 0)
 
39
                  (= (aref val-right alpha) 0) (= (aref val-top alpha) 0)
 
40
                  (= (aref val-bottom alpha) 0)
 
41
             )
 
42
             (set! clearance 1)
 
43
             (set! limit (- limit 1))
 
44
         )
 
45
      )
 
46
      x
 
47
    )
 
48
  )
 
49
 
 
50
  (let* (
 
51
        (border (/ size 4))
 
52
        (grow (/ size 30))
 
53
        (offx (* size 0.03))
 
54
        (offy (* size 0.02))
 
55
        (feather (/ size 4))
 
56
        (shadow-feather (/ size 25))
 
57
        (width (car (gimp-drawable-width logo-layer)))
 
58
        (height (car (gimp-drawable-height logo-layer)))
 
59
        (w (* (/ (- width (* border 2)) 2.0) 0.75))
 
60
        (h (* (/ (- height (* border 2)) 2.0) 0.75))
 
61
        (novay (* height 0.3))
 
62
        (novax (find-nova-x-coord logo-layer (* width 0.2) (* width 0.8) novay))
 
63
        (novaradius (/ (min height width) 7.0))
 
64
        (cx (/ width 2.0))
 
65
        (cy (/ height 2.0))
 
66
        (bx (+ cx (car (find-blend-coords w h))))
 
67
        (by (+ cy (cdr (find-blend-coords w h))))
 
68
        (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
 
69
        (glow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Glow" 100 NORMAL-MODE)))
 
70
        (shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Drop Shadow" 100 NORMAL-MODE)))
 
71
        (bump-channel (car (gimp-channel-new img width height "Bump Map" 50 '(0 0 0))))
 
72
        )
63
73
 
64
74
    (gimp-context-push)
65
75
 
69
79
    (gimp-image-add-layer img glow-layer 1)
70
80
    (gimp-image-add-layer img shadow-layer 1)
71
81
    (gimp-image-add-channel img bump-channel 0)
72
 
    (gimp-layer-set-preserve-trans logo-layer TRUE)
 
82
    (gimp-layer-set-lock-alpha logo-layer TRUE)
73
83
 
74
84
    (gimp-context-set-background '(0 0 0))
75
85
    (gimp-edit-fill bg-layer BACKGROUND-FILL)
94
104
    (gimp-context-set-foreground '(255 255 255))
95
105
 
96
106
    (gimp-edit-blend logo-layer FG-BG-RGB-MODE NORMAL-MODE
97
 
                     GRADIENT-BILINEAR 100 0 REPEAT-NONE FALSE
98
 
                     FALSE 0 0 TRUE
99
 
                     cx cy bx by)
 
107
             GRADIENT-BILINEAR 100 0 REPEAT-NONE FALSE
 
108
             FALSE 0 0 TRUE
 
109
             cx cy bx by)
100
110
 
101
111
    (plug-in-nova 1 img glow-layer novax novay glow-color novaradius 100 0)
102
112
 
104
114
    (gimp-context-set-pattern "Stone")
105
115
    (gimp-edit-bucket-fill bump-channel PATTERN-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
106
116
    (plug-in-bump-map 1 img logo-layer bump-channel
107
 
                      135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
 
117
              135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
108
118
    (gimp-image-remove-channel img bump-channel)
109
119
    (gimp-selection-none img)
110
120
 
111
 
    (gimp-context-pop)))
112
 
 
113
 
 
114
 
(define (script-fu-starscape-logo-alpha img
115
 
                                        logo-layer
116
 
                                        size
117
 
                                        glow-color)
 
121
    (gimp-context-pop)
 
122
  )
 
123
)
 
124
 
 
125
(define (script-fu-starscape-logo-alpha img logo-layer size glow-color)
118
126
  (begin
119
127
    (gimp-image-undo-group-start img)
120
128
    (apply-starscape-logo-effect img logo-layer size glow-color)
121
129
    (gimp-image-undo-group-end img)
122
 
    (gimp-displays-flush)))
 
130
    (gimp-displays-flush)
 
131
  )
 
132
)
123
133
 
124
134
(script-fu-register "script-fu-starscape-logo-alpha"
125
 
                    _"Sta_rscape..."
126
 
                    "Starscape using the Nova plug-in"
127
 
                    "Spencer Kimball"
128
 
                    "Spencer Kimball"
129
 
                    "1997"
130
 
                    "RGBA"
131
 
                    SF-IMAGE      "Image"                     0
132
 
                    SF-DRAWABLE   "Drawable"                  0
133
 
                    SF-ADJUSTMENT _"Effect size (pixels * 4)" '(150 1 1000 1 10 0 1)
134
 
                    SF-COLOR      _"Glow color"               '(28 65 188))
 
135
  _"Sta_rscape..."
 
136
  _"Fill the selected region (or alpha) with a rock-like texture, a nova glow, and shadow"
 
137
  "Spencer Kimball"
 
138
  "Spencer Kimball"
 
139
  "1997"
 
140
  "RGBA"
 
141
  SF-IMAGE       "Image"                    0
 
142
  SF-DRAWABLE    "Drawable"                 0
 
143
  SF-ADJUSTMENT _"Effect size (pixels * 4)" '(150 1 1000 1 10 0 1)
 
144
  SF-COLOR      _"Glow color"               '(28 65 188)
 
145
)
135
146
 
136
147
(script-fu-menu-register "script-fu-starscape-logo-alpha"
137
 
                         _"<Image>/Script-Fu/Alpha to Logo")
138
 
 
139
 
 
140
 
(define (script-fu-starscape-logo text
141
 
                                  size
142
 
                                  fontname
143
 
                                  glow-color)
144
 
  (let* ((img (car (gimp-image-new 256 256 RGB)))
145
 
         (border (/ size 4))
146
 
         (text-layer (car (gimp-text-fontname img -1 0 0 text border
147
 
                                              TRUE size PIXELS fontname))))
 
148
                         "<Image>/Filters/Alpha to Logo")
 
149
 
 
150
 
 
151
(define (script-fu-starscape-logo text size fontname glow-color)
 
152
  (let* (
 
153
        (img (car (gimp-image-new 256 256 RGB)))
 
154
        (border (/ size 4))
 
155
        (text-layer (car (gimp-text-fontname img -1 0 0 text border
 
156
                                             TRUE size PIXELS fontname)))
 
157
        )
148
158
    (gimp-image-undo-disable img)
149
 
    (gimp-drawable-set-name text-layer text)
150
159
    (apply-starscape-logo-effect img text-layer size glow-color)
151
160
    (gimp-image-undo-enable img)
152
 
    (gimp-display-new img)))
 
161
    (gimp-display-new img)
 
162
  )
 
163
)
153
164
 
154
165
(script-fu-register "script-fu-starscape-logo"
155
 
                    _"Sta_rscape..."
156
 
                    "Starscape using the Nova plug-in"
157
 
                    "Spencer Kimball"
158
 
                    "Spencer Kimball"
159
 
                    "1997"
160
 
                    ""
161
 
                    SF-STRING     _"Text"               "Nova"
162
 
                    SF-ADJUSTMENT _"Font size (pixels)" '(150 1 1000 1 10 0 1)
163
 
                    SF-FONT       _"Font"               "Engraver"
164
 
                    SF-COLOR      _"Glow color"         '(28 65 188))
 
166
  _"Sta_rscape..."
 
167
  _"Create a logo using a rock-like texture, a nova glow, and shadow"
 
168
  "Spencer Kimball"
 
169
  "Spencer Kimball"
 
170
  "1997"
 
171
  ""
 
172
  SF-STRING     _"Text"               "Nova"
 
173
  SF-ADJUSTMENT _"Font size (pixels)" '(150 1 1000 1 10 0 1)
 
174
  SF-FONT       _"Font"               "Engraver"
 
175
  SF-COLOR      _"Glow color"         '(28 65 188)
 
176
)
165
177
 
166
178
(script-fu-menu-register "script-fu-starscape-logo"
167
 
                         _"<Toolbox>/Xtns/Script-Fu/Logos")
 
179
                         "<Toolbox>/Xtns/Logos")