-
Notifications
You must be signed in to change notification settings - Fork 0
/
highlighted-logo.scm
183 lines (167 loc) · 7.34 KB
/
highlighted-logo.scm
1
2
3
4
5
6
7
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
(script-fu-register
"script-fu-highlighted-logo" ;function name
"HighLighted LOGO" ;menu label
"Creates a simple text box, sized to fit\
around the user's choice of text,\
font, font size, and color." ;description
"Michael Terry" ;author
"copyright 1997, Michael Terry;\
2009, the GIMP Documentation Team" ;copyright notice
"October 27, 1997" ;date created
"" ;image type that the script works on
SF-TEXT "Text" "HighLighted\nLogo" ;a string variable
SF-FONT "Font" "DejaVu Sans Bold" ;a font variable
SF-ADJUSTMENT "Font size" '(150 1 1000 1 10 0 0)
SF-COLOR "Color" '(255 0 0) ;color variable
SF-OPTION _"Text Justification" '("Centered" "Left" "Right" "Fill")
SF-ADJUSTMENT "Letter Spacing" '(0 -50 50 1 5 0 0)
SF-ADJUSTMENT "Line Spacing" '(-5 -300 300 1 10 0 0)
SF-ADJUSTMENT _"Shrink / Grow Text" '(0 -20 20 1 10 0 0)
SF-ADJUSTMENT _"Outline" '(0 0 20 1 10 0 0)
;a spin-button
SF-COLOR "BG Color" '(255 255 255) ;color variable
SF-ADJUSTMENT "Buffer amount" '(35 0 100 1 10 1 0)
;a slider
)
(script-fu-menu-register "script-fu-highlighted-logo" "<Image>/File/Create/Text")
(define (script-fu-highlighted-logo inText inFont inFontSize inTextColor
justification
letter-spacing
line-spacing
grow-text
outline
bgcolor
inBufferAmount)
(let*
(
; define our local variables
; create a new image:
(theImageWidth 10)
(theImageHeight 10)
(highlight-channel 0)
(theImage)
(theImage
(car
(gimp-image-new
theImageWidth
theImageHeight
RGB
)
)
)
(theText) ;a declaration for the text
(theBuffer) ;create a new layer for the image
(theLayer
(car
(gimp-layer-new
theImage
theImageWidth
theImageHeight
RGB-IMAGE
"layer 1"
100
LAYER-MODE-NORMAL
)
)
)
(highlight (car (gimp-layer-new theImage theImageWidth theImageHeight RGBA-IMAGE "Highlight" 100 LAYER-MODE-NORMAL-LEGACY)))
(highlight-channel (car (gimp-layer-new theImage theImageWidth theImageHeight RGBA-IMAGE "Highlight-chan" 100 LAYER-MODE-NORMAL-LEGACY)))
(justification (cond ((= justification 0) 2)
((= justification 1) 0)
((= justification 2) 1)
((= justification 3) 3)))
) ;end of our local variables
(gimp-image-insert-layer theImage theLayer 0 0)
(gimp-context-set-background bgcolor )
(gimp-context-set-foreground inTextColor)
(gimp-drawable-fill theLayer FILL-BACKGROUND)
(set! theText
(if (= (string->number (substring (car(gimp-version)) 0 3)) 2.10)
(car
(gimp-text-fontname
theImage theLayer
0 0
inText
0
TRUE
inFontSize PIXELS
inFont)
)
(car
(gimp-text-font
theImage theLayer
0 0
inText
0
TRUE
inFontSize
inFont)
))
)
;; text alignment
(gimp-text-layer-set-justification theText justification) ; Text Justification (Rev Value)
(gimp-text-layer-set-letter-spacing theText letter-spacing) ; Set Letter Spacing
(gimp-text-layer-set-line-spacing theText line-spacing) ; Set Line Spacing
(set! theImageWidth (car (gimp-drawable-get-width theText) ) )
(set! theImageHeight (car (gimp-drawable-get-height theText) ) )
(set! theBuffer (* theImageHeight (/ inBufferAmount 100) ) )
(set! theImageHeight (+ theImageHeight theBuffer theBuffer) )
(set! theImageWidth (+ theImageWidth theBuffer theBuffer) )
(gimp-image-resize theImage theImageWidth theImageHeight 0 0)
(gimp-layer-resize theLayer theImageWidth theImageHeight 0 0)
(gimp-layer-set-offsets theText theBuffer theBuffer)
(gimp-floating-sel-to-layer theText)
(gimp-layer-resize-to-image-size theText)
;;;; shrink grow text
(cond ((> grow-text 0)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-selection-grow theImage (round grow-text))
(gimp-context-set-foreground inTextColor)
(gimp-drawable-edit-fill theText FILL-FOREGROUND)
;(gimp-image-select-item theImage 2 theText)
)
((< grow-text 0)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-drawable-edit-clear theText)
(gimp-selection-shrink theImage (- grow-text))
(gimp-context-set-foreground inTextColor)
(gimp-drawable-edit-fill theText FILL-FOREGROUND)
))
;;; outline
(cond ((> outline 0)
(gimp-selection-none theImage)
(gimp-image-select-item theImage 2 theText)
(gimp-selection-shrink theImage (round outline))
(gimp-drawable-edit-clear theText)
(gimp-image-select-item theImage 2 theText)
))
; (gimp-image-resize-to-layers theImage)
;;;;create the highlight
(gimp-image-select-item theImage 2 theText)
(gimp-image-insert-layer theImage highlight 0 0)
(gimp-item-set-name highlight "ciccio")
(gimp-layer-resize-to-image-size highlight)
(gimp-selection-shrink theImage 5)
(gimp-selection-feather theImage 2)
(gimp-context-set-foreground '(128 128 128))
(gimp-drawable-edit-fill highlight FILL-FOREGROUND)
;;;;create highlight-channel (gimp-image-select-item image 2 highlight-channel)
;(set! highlight-channel (car (gimp-selection-save theImage)))
;(gimp-item-set-name highlight-channel "highlight-channel")
;(include-layer theImage highlight-channel theLayer 0) ;stack 0=above 1=below
(gimp-image-insert-layer theImage highlight-channel 0 0)
(gimp-layer-resize-to-image-size highlight-channel)
(set! highlight-channel (car (gimp-selection-save theImage)))
;(gimp-layer-resize-to-image-size highlight-channel)
(gimp-selection-none theImage)
(plug-in-gauss-rle2 RUN-NONINTERACTIVE theImage highlight 5 5)
;(gimp-image-set-active-layer image highlight)
(plug-in-bump-map RUN-NONINTERACTIVE theImage highlight highlight-channel 135 15 10 0 0 0 1 TRUE FALSE 0) ;{LINEAR(0),SPHERICAL(1),SINUSOIDAL(2)}
(plug-in-colortoalpha RUN-NONINTERACTIVE theImage highlight '(128 128 128))
(plug-in-gauss-rle2 RUN-NONINTERACTIVE theImage highlight 1.5 1.5)
(gimp-display-new theImage)
(list theImage theLayer theText)
)
)