coolmetal-logo.scm 6.11 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 8 9 10
(define (apply-cool-metal-logo-effect img
				      logo-layer
				      size
				      bg-color
11 12
				      gradient
				      gradient-reverse)
13
  (let* ((feather (/ size 5))
Elliot Lee's avatar
Elliot Lee committed
14 15 16 17 18
	 (smear 7.5)
	 (period (/ size 3))
	 (amplitude (/ size 40))
	 (shrink (+ 1 (/ size 30)))
	 (depth (/ size 20))
19 20
	 (width (car (gimp-drawable-width logo-layer)))
	 (height (car (gimp-drawable-height logo-layer)))
21 22
	 (posx (- (car (gimp-drawable-offsets logo-layer))))
	 (posy (- (cadr (gimp-drawable-offsets logo-layer))))
Elliot Lee's avatar
Elliot Lee committed
23 24
	 (img-width (+ width (* 0.15 height) 10))
	 (img-height (+ (* 1.85 height) 10))
25 26 27
	 (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)))
Elliot Lee's avatar
Elliot Lee committed
28 29
	 (channel 0)
	 (fs 0)
30 31 32
	 (layer-mask 0))

    (gimp-context-push)
33

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

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

47
    (gimp-context-set-gradient gradient)
48

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

54
    (gimp-rect-select img 0 (- (/ height 2) feather) img-width (* 2 feather) CHANNEL-OP-REPLACE 0 0)
55
    (plug-in-gauss-iir 1 img logo-layer smear TRUE TRUE)
Elliot Lee's avatar
Elliot Lee committed
56
    (gimp-selection-none img)
57 58 59
    (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
60

61
    (gimp-selection-layer-alpha logo-layer)
Elliot Lee's avatar
Elliot Lee committed
62 63 64 65
    (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)
66
    (gimp-selection-layer-alpha logo-layer)
Elliot Lee's avatar
Elliot Lee committed
67
    (gimp-selection-invert img)
68
    (gimp-context-set-background '(0 0 0))
69
    (gimp-edit-fill channel BACKGROUND-FILL)
Elliot Lee's avatar
Elliot Lee committed
70 71
    (gimp-selection-none img)

72
    (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
73

74
    (gimp-selection-layer-alpha logo-layer)
75 76
    (set! fs (car (gimp-selection-float shadow-layer 0 0)))
    (gimp-edit-clear shadow-layer)
77 78 79 80 81 82
    (gimp-drawable-transform-perspective-default fs
						 (+ 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
83 84 85
    (gimp-floating-sel-anchor fs)
    (plug-in-gauss-rle 1 img shadow-layer smear TRUE TRUE)

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

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

    (gimp-image-remove-channel img channel)

108
    (gimp-context-pop)))
109 110 111 112 113 114


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

(script-fu-register "script-fu-cool-metal-logo-alpha"
125
		    _"Cool _Metal..."
126 127 128 129 130
		    "Metallic logos with reflections and perspective shadows"
		    "Spencer Kimball & Rob Malda"
		    "Spencer Kimball & Rob Malda"
		    "1997"
		    "RGBA"
131 132
                    SF-IMAGE       "Image"                0
                    SF-DRAWABLE    "Drawable"             0
133
		    SF-ADJUSTMENT _"Effect size (pixels)" '(100 2 1000 1 10 0 1)
134
		    SF-COLOR      _"Background color"     "white"
135
		    SF-GRADIENT   _"Gradient"             "Horizon 1"
136
		    SF-TOGGLE     _"Gradient reverse"     FALSE)
137

138
(script-fu-menu-register "script-fu-cool-metal-logo-alpha"
139
			 "<Image>/Filters/Alpha to Logo")
140

141 142 143 144 145

(define (script-fu-cool-metal-logo text
				   size
				   font
				   bg-color
146 147
				   gradient
				   gradient-reverse)
148
  (let* ((img (car (gimp-image-new 256 256 RGB)))
149 150
	 (text-layer (car (gimp-text-fontname img -1 0 0 text 0 TRUE
					      size PIXELS font))))
151
    (gimp-image-undo-disable img)
152 153
    (apply-cool-metal-logo-effect img text-layer size bg-color
				  gradient gradient-reverse)
Marc Lehmann's avatar
Marc Lehmann committed
154
    (gimp-image-undo-enable img)
Elliot Lee's avatar
Elliot Lee committed
155 156 157
    (gimp-display-new img)))

(script-fu-register "script-fu-cool-metal-logo"
158
		    _"Cool _Metal..."
Elliot Lee's avatar
Elliot Lee committed
159 160 161 162 163
		    "Metallic logos with reflections and perspective shadows"
		    "Spencer Kimball & Rob Malda"
		    "Spencer Kimball & Rob Malda"
		    "1997"
		    ""
164
		    SF-STRING     _"Text"               "Cool Metal"
165
		    SF-ADJUSTMENT _"Font size (pixels)" '(100 2 1000 1 10 0 1)
166
		    SF-FONT       _"Font"               "Crillee"
167
		    SF-COLOR      _"Background color"   "white"
168
		    SF-GRADIENT   _"Gradient"           "Horizon 1"
169
		    SF-TOGGLE     _"Gradient reverse"   FALSE)
170 171

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