coolmetal-logo.scm 7.02 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1 2 3 4 5 6
;  COOL-METAL
;  Create a text effect that looks like metal with a reflection of
;  the horizon, a reflection of the text in the mirrored ground, and
;  an interesting dropshadow
;  This script was inspired by Rob Malda's 'coolmetal.gif' graphic

7
(define (apply-cool-metal-logo-effect img
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
                                      logo-layer
                                      size
                                      bg-color
                                      gradient
                                      gradient-reverse)
  (let* (
        (feather (/ size 5))
        (smear 7.5)
        (period (/ size 3))
        (amplitude (/ size 40))
        (shrink (+ 1 (/ size 30)))
        (depth (/ size 20))
        (width (car (gimp-drawable-width logo-layer)))
        (height (car (gimp-drawable-height logo-layer)))
        (posx (- (car (gimp-drawable-offsets logo-layer))))
        (posy (- (cadr (gimp-drawable-offsets logo-layer))))
        (img-width (+ width (* 0.15 height) 10))
        (img-height (+ (* 1.85 height) 10))
        (bg-layer (car (gimp-layer-new img img-width img-height RGB-IMAGE "Background" 100 NORMAL-MODE)))
        (shadow-layer (car (gimp-layer-new img img-width img-height RGBA-IMAGE "Shadow" 100 NORMAL-MODE)))
        (reflect-layer (car (gimp-layer-new img width height RGBA-IMAGE "Reflection" 100 NORMAL-MODE)))
        (channel 0)
        (fs 0)
        (layer-mask 0)
        )
33 34

    (gimp-context-push)
35

36 37
    (gimp-selection-none img)
    (gimp-image-resize img img-width img-height posx posy)
Elliot Lee's avatar
Elliot Lee committed
38 39 40
    (gimp-image-add-layer img bg-layer 1)
    (gimp-image-add-layer img reflect-layer 1)
    (gimp-image-add-layer img shadow-layer 1)
41
    (gimp-layer-set-lock-alpha logo-layer TRUE)
Elliot Lee's avatar
Elliot Lee committed
42

43
    (gimp-context-set-background bg-color)
44
    (gimp-edit-fill bg-layer BACKGROUND-FILL)
45
    (gimp-edit-clear reflect-layer)
46
    (gimp-context-set-background '(0 0 0))
47
    (gimp-edit-fill shadow-layer BACKGROUND-FILL)
Elliot Lee's avatar
Elliot Lee committed
48

49
    (gimp-context-set-gradient gradient)
50

51
    (gimp-edit-blend logo-layer CUSTOM-MODE NORMAL-MODE
52 53 54
                     GRADIENT-LINEAR 100 0 REPEAT-NONE gradient-reverse
                     FALSE 0 0 TRUE
                     0 0 0 (+ height 5))
55

56
    (gimp-rect-select img 0 (- (/ height 2) feather) img-width (* 2 feather) CHANNEL-OP-REPLACE 0 0)
57
    (plug-in-gauss-iir 1 img logo-layer smear TRUE TRUE)
Elliot Lee's avatar
Elliot Lee committed
58
    (gimp-selection-none img)
59 60 61
    (plug-in-ripple 1 img logo-layer period amplitude 1 0 1 TRUE FALSE)
    (gimp-layer-translate logo-layer 5 5)
    (gimp-layer-resize logo-layer img-width img-height 5 5)
Elliot Lee's avatar
Elliot Lee committed
62

63
    (gimp-selection-layer-alpha logo-layer)
Elliot Lee's avatar
Elliot Lee committed
64 65 66 67
    (set! channel (car (gimp-selection-save img)))
    (gimp-selection-shrink img shrink)
    (gimp-selection-invert img)
    (plug-in-gauss-rle 1 img channel feather TRUE TRUE)
68
    (gimp-selection-layer-alpha logo-layer)
Elliot Lee's avatar
Elliot Lee committed
69
    (gimp-selection-invert img)
70
    (gimp-context-set-background '(0 0 0))
71
    (gimp-edit-fill channel BACKGROUND-FILL)
Elliot Lee's avatar
Elliot Lee committed
72 73
    (gimp-selection-none img)

74
    (plug-in-bump-map 1 img logo-layer channel 135 45 depth 0 0 0 0 FALSE FALSE 0)
Elliot Lee's avatar
Elliot Lee committed
75

76
    (gimp-selection-layer-alpha logo-layer)
77 78
    (set! fs (car (gimp-selection-float shadow-layer 0 0)))
    (gimp-edit-clear shadow-layer)
79
    (gimp-drawable-transform-perspective-default fs
80 81 82 83 84
                      (+ 5 (* 0.15 height)) (- height (* 0.15 height))
                      (+ 5 width (* 0.15 height)) (- height (* 0.15 height))
                      5 height
                      (+ 5 width) height
                      FALSE FALSE)
Elliot Lee's avatar
Elliot Lee committed
85 86 87
    (gimp-floating-sel-anchor fs)
    (plug-in-gauss-rle 1 img shadow-layer smear TRUE TRUE)

88
    (gimp-rect-select img 5 5 width height CHANNEL-OP-REPLACE FALSE 0)
89
    (gimp-edit-copy logo-layer)
90
    (set! fs (car (gimp-edit-paste reflect-layer FALSE)))
Elliot Lee's avatar
Elliot Lee committed
91
    (gimp-floating-sel-anchor fs)
92
    (gimp-drawable-transform-scale-default reflect-layer
93 94 95
                                           0 0 width (* 0.85 height)
                                           FALSE FALSE)
    (gimp-drawable-transform-flip-simple reflect-layer ORIENTATION-VERTICAL
96
                                         TRUE 0 TRUE)
Elliot Lee's avatar
Elliot Lee committed
97 98
    (gimp-layer-set-offsets reflect-layer 5 (+ 3 height))

99
    (set! layer-mask (car (gimp-layer-create-mask reflect-layer ADD-WHITE-MASK)))
100
    (gimp-layer-add-mask reflect-layer layer-mask)
101 102
    (gimp-context-set-foreground '(255 255 255))
    (gimp-context-set-background '(0 0 0))
103
    (gimp-edit-blend layer-mask FG-BG-RGB-MODE NORMAL-MODE
104 105 106
                     GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
                     FALSE 0 0 TRUE
                     0 (- (/ height 2)) 0 height)
Elliot Lee's avatar
Elliot Lee committed
107 108 109

    (gimp-image-remove-channel img channel)

110 111 112
    (gimp-context-pop)
  )
)
113 114 115


(define (script-fu-cool-metal-logo-alpha img
116 117 118 119 120
                                         logo-layer
                                         size
                                         bg-color
                                         gradient
                                         gradient-reverse)
121
  (begin
122
    (gimp-image-undo-group-start img)
123
    (apply-cool-metal-logo-effect img logo-layer size bg-color
124
                                  gradient gradient-reverse)
125
    (gimp-image-undo-group-end img)
126 127 128
    (gimp-displays-flush)
  )
)
129 130

(script-fu-register "script-fu-cool-metal-logo-alpha"
131 132 133 134 135 136 137 138 139
  _"Cool _Metal..."
  _"Add a metallic effect to the selected region (or alpha) with reflections and perspective shadows"
  "Spencer Kimball & Rob Malda"
  "Spencer Kimball & Rob Malda"
  "1997"
  "RGBA"
  SF-IMAGE      "Image"                 0
  SF-DRAWABLE   "Drawable"              0
  SF-ADJUSTMENT _"Effect size (pixels)" '(100 2 1000 1 10 0 1)
Kevin Cozens's avatar
Kevin Cozens committed
140
  SF-COLOR      _"Background color"     "white"
141 142 143
  SF-GRADIENT   _"Gradient"             "Horizon 1"
  SF-TOGGLE     _"Gradient reverse"     FALSE
)
144

145
(script-fu-menu-register "script-fu-cool-metal-logo-alpha"
146
                         "<Image>/Filters/Alpha to Logo")
147

148 149

(define (script-fu-cool-metal-logo text
150 151 152 153 154 155 156 157 158 159
                                   size
                                   font
                                   bg-color
                                   gradient
                                   gradient-reverse)
  (let* (
        (img (car (gimp-image-new 256 256 RGB)))
        (text-layer (car (gimp-text-fontname img -1 0 0 text 0 TRUE
                                              size PIXELS font)))
        )
160
    (gimp-image-undo-disable img)
161
    (apply-cool-metal-logo-effect img text-layer size bg-color
162
                                  gradient gradient-reverse)
Marc Lehmann's avatar
Marc Lehmann committed
163
    (gimp-image-undo-enable img)
164 165 166
    (gimp-display-new img)
  )
)
Elliot Lee's avatar
Elliot Lee committed
167 168

(script-fu-register "script-fu-cool-metal-logo"
169 170 171 172 173 174 175 176 177
  _"Cool _Metal..."
  _"Create a metallic logo with reflections and perspective shadows"
  "Spencer Kimball & Rob Malda"
  "Spencer Kimball & Rob Malda"
  "1997"
  ""
  SF-STRING     _"Text"               "Cool Metal"
  SF-ADJUSTMENT _"Font size (pixels)" '(100 2 1000 1 10 0 1)
  SF-FONT       _"Font"               "Crillee"
Kevin Cozens's avatar
Kevin Cozens committed
178
  SF-COLOR      _"Background color"   "white"
179 180 181
  SF-GRADIENT   _"Gradient"           "Horizon 1"
  SF-TOGGLE     _"Gradient reverse"   FALSE
)
182 183

(script-fu-menu-register "script-fu-cool-metal-logo"
184
                         "<Toolbox>/Xtns/Logos")