1 |
(define (script-fu-3d-screenshot inLayer inShinyness inColorTop inColorBottom inShadowBlur inShadowOpacity inShadowColor inLumIntensity inFinalDimension) |
2 |
|
3 |
(let* |
4 |
( |
5 |
(theLayer 0) |
6 |
(theShinyness 0) |
7 |
(theColorTop 0) |
8 |
(theColorBottom 0) |
9 |
(theShadowBlur 0) |
10 |
(theShadowOpacity 0) |
11 |
(theShadowColor 0) |
12 |
(theLumIntensity 0) |
13 |
(theFinalDimension 0) |
14 |
(theImage 0) |
15 |
(theHeight 0) |
16 |
(theWidth 0) |
17 |
(theImageHeight 0) |
18 |
(theImageWidth 0) |
19 |
(theBackground 0) |
20 |
(theBackgroundGradient 0) |
21 |
(theReflection 0) |
22 |
(theShadow 0) |
23 |
(theLuminosityOne 0) |
24 |
(theLuminosityTwo 0) |
25 |
) |
26 |
|
27 |
(set! theLayer inLayer) |
28 |
(set! theShinyness inShinyness) |
29 |
(set! theColorTop inColorTop) |
30 |
(set! theColorBottom inColorBottom) |
31 |
(set! theShadowBlur inShadowBlur) |
32 |
(set! theShadowOpacity inShadowOpacity) |
33 |
(set! theShadowColor inShadowColor) |
34 |
(set! theLumIntensity inLumIntensity) |
35 |
(set! theFinalDimension inFinalDimension) |
36 |
|
37 |
;On définit une variable theImage qui contient l'image |
38 |
(set! theImage (car (gimp-drawable-get-image theLayer))) |
39 |
|
40 |
;On définit deux variables contenant les dimensions du screenshot |
41 |
(set! theHeight (car (gimp-image-height theImage))) |
42 |
(set! theWidth (car (gimp-image-width theImage))) |
43 |
|
44 |
;;;;; Redimensionnement de l'image |
45 |
(gimp-image-resize theImage |
46 |
(* 2 theWidth) |
47 |
(* 2 theWidth) |
48 |
(/ theWidth 2) |
49 |
(/ theHeight 2)) |
50 |
;Dimensions de l'image |
51 |
(set! theImageHeight (car (gimp-image-height theImage))) |
52 |
(set! theImageWidth (car (gimp-image-width theImage))) |
53 |
|
54 |
;;;;; Ajout du fond |
55 |
;On crée un nouveau calque |
56 |
(set! theBackground (car (gimp-layer-new theImage theImageWidth theImageHeight RGB-IMAGE "Fond" 100 0))) |
57 |
;On ajoute le nouveau calque à l'image |
58 |
(gimp-image-add-layer theImage theBackground 1) |
59 |
;On crée un dégradé |
60 |
(set! theBackgroundGradient (gimp-gradient-new "Fond-screenshot-with-style")) |
61 |
;On le met en tant que dégradé actif |
62 |
(gimp-context-set-gradient "Fond-screenshot-with-style") |
63 |
;On définit sa première couleur |
64 |
(gimp-gradient-segment-set-left-color "Fond-screenshot-with-style" 0 theColorTop 100) |
65 |
;On définit sa deuxième couleur |
66 |
(gimp-gradient-segment-set-right-color "Fond-screenshot-with-style" 0 theColorBottom 100) |
67 |
;On peint avec le dégradé |
68 |
(gimp-edit-blend theBackground ;drawable |
69 |
CUSTOM-MODE ;blend_mode (normal) |
70 |
NORMAL-MODE ;paint_mode (normal) |
71 |
GRADIENT-LINEAR ;gradient_type (linéaire) |
72 |
100 ;opacity |
73 |
0 ;offset (?) |
74 |
REPEAT-NONE ;repeat (none) |
75 |
FALSE ;reverse |
76 |
FALSE ;supersample (?) |
77 |
0 ;max_depth |
78 |
0 ;threshold |
79 |
TRUE ;dither (?) |
80 |
0 0 0 theImageHeight) ;coordonnées |
81 |
|
82 |
;;;;; Ajout du reflet |
83 |
;On crée un nouveau calque |
84 |
(set! theReflection |
85 |
(car |
86 |
(gimp-layer-copy |
87 |
theLayer |
88 |
1) |
89 |
) |
90 |
) |
91 |
;On nomme le calque |
92 |
(gimp-layer-set-name theReflection "Reflet") |
93 |
;On ajoute le nouveau calque à l'image |
94 |
(gimp-image-add-layer theImage theReflection -1) |
95 |
;On le retourne |
96 |
(gimp-drawable-transform-flip-simple theReflection 1 1 0 1) |
97 |
;On le descend pour que son bord supérieur corresponde |
98 |
;au bord inférieur de l'autre calque |
99 |
(gimp-layer-translate theReflection 0 theHeight) |
100 |
;On diminue son opacité |
101 |
(gimp-layer-set-opacity theReflection theShinyness) |
102 |
|
103 |
;;;;; Fusion des deux calques |
104 |
(gimp-drawable-set-visible theBackground FALSE) |
105 |
(set! theLayer (car (gimp-image-merge-visible-layers theImage 1))) |
106 |
(gimp-drawable-set-visible theBackground TRUE) |
107 |
|
108 |
;;;;; Perspective |
109 |
;D'abord on agrandit le calque à la taille de l'image |
110 |
(gimp-layer-resize-to-image-size theLayer) |
111 |
; Et on applique la transformation |
112 |
(set! theLayer (car (gimp-drawable-transform-perspective-default theLayer |
113 |
(- (/ theWidth 5.3)) |
114 |
(- (/ theHeight 4)) |
115 |
(* theWidth 3.7) |
116 |
(- (* theHeight 1.7)) |
117 |
0 |
118 |
(* theHeight 3.5) |
119 |
(* theWidth 2.1) |
120 |
(* theHeight 5.3) |
121 |
TRUE TRUE))) |
122 |
|
123 |
;;;;; Ajout de l'ombre |
124 |
;On crée un nouveau calque |
125 |
(set! theShadow |
126 |
(car |
127 |
(gimp-layer-new |
128 |
theImage |
129 |
theImageWidth |
130 |
theImageHeight |
131 |
0 ;RGB |
132 |
"Ombre" |
133 |
theShadowOpacity |
134 |
9) ;Assombrir |
135 |
) |
136 |
) |
137 |
;On ajoute le nouveau calque à l'image |
138 |
(gimp-image-add-layer theImage theShadow 1) |
139 |
;On sélectionne tout |
140 |
(gimp-selection-all theImage) |
141 |
;pour pouvoir peindre en blanc |
142 |
(gimp-context-set-foreground '(255 255 255)) |
143 |
(gimp-edit-bucket-fill theShadow 0 0 100 0 0 0 0) |
144 |
;On sélectionne un rectangle |
145 |
(gimp-rect-select theImage (/ theWidth 2) (/ theHeight 2) theWidth theHeight 2 0 0) |
146 |
;On crée un dégradé |
147 |
(set! theBackgroundGradient (gimp-gradient-new "Ombre-screenshot-with-style")) |
148 |
;On le met en tant que dégradé actif |
149 |
(gimp-context-set-gradient "Ombre-screenshot-with-style") |
150 |
;On définit sa première couleur |
151 |
(gimp-gradient-segment-set-left-color "Ombre-screenshot-with-style" 0 '(255 255 255) 100) |
152 |
;On définit sa deuxième couleur |
153 |
(gimp-gradient-segment-set-right-color "Ombre-screenshot-with-style" 0 theShadowColor 100) |
154 |
;On peint avec le dégradé (dans la sélection) |
155 |
(gimp-edit-blend theShadow ;drawable |
156 |
CUSTOM-MODE ;blend_mode (normal) |
157 |
NORMAL-MODE ;paint_mode (normal) |
158 |
GRADIENT-LINEAR ;gradient_type (linéaire) |
159 |
100 ;opacity |
160 |
0 ;offset (?) |
161 |
REPEAT-NONE ;repeat (none) |
162 |
FALSE ;reverse |
163 |
FALSE ;supersample (?) |
164 |
0 ;max_depth |
165 |
0 ;threshold |
166 |
TRUE ;dither (?) |
167 |
0 (/ theHeight 2) 0 (* theHeight 1.5)) ;coordonnées |
168 |
;On vire la sélection |
169 |
(gimp-selection-none theImage) |
170 |
;On floute l'ombre |
171 |
(plug-in-gauss 1 theImage theShadow theShadowBlur theShadowBlur 0) |
172 |
;On la déforme |
173 |
(set! theShadow (car (gimp-drawable-transform-perspective-default theShadow |
174 |
(/ theWidth 1.6) |
175 |
(* theHeight 1.44) |
176 |
(* theWidth 3) |
177 |
(* theHeight 2) |
178 |
(- (* theWidth 1.375)) |
179 |
(* theHeight 2.45) |
180 |
(* theWidth 1.375) |
181 |
(* theHeight 4) |
182 |
TRUE TRUE))) |
183 |
|
184 |
;;;;; Ajout de l'effet de luminosité |
185 |
;On crée deux nouveaux calques |
186 |
(set! theLuminosityOne |
187 |
(car |
188 |
(gimp-layer-copy |
189 |
theLayer |
190 |
1) |
191 |
) |
192 |
) |
193 |
(set! theLuminosityTwo |
194 |
(car |
195 |
(gimp-layer-copy |
196 |
theLayer |
197 |
1) |
198 |
) |
199 |
) |
200 |
;On nomme les calques |
201 |
(gimp-layer-set-name theLuminosityOne "Effet de lumière (détails)") |
202 |
(gimp-layer-set-name theLuminosityTwo "Effet de lumière (diffuse)") |
203 |
;On ajoute les nouveaux calques à l'image |
204 |
(gimp-image-add-layer theImage theLuminosityOne 0) |
205 |
(gimp-image-add-layer theImage theLuminosityTwo 0) |
206 |
;On ajoute un max de contraste |
207 |
(gimp-brightness-contrast theLuminosityOne 0 100) |
208 |
(gimp-brightness-contrast theLuminosityTwo 0 100) |
209 |
;On le floute |
210 |
(plug-in-gauss 1 theImage theLuminosityOne 5 5 0) |
211 |
(plug-in-gauss 1 theImage theLuminosityTwo 20 20 0) |
212 |
(gimp-layer-set-opacity theLuminosityOne theLumIntensity) |
213 |
(gimp-layer-set-opacity theLuminosityTwo theLumIntensity) |
214 |
(gimp-layer-set-mode theLuminosityOne 4) |
215 |
(gimp-layer-set-mode theLuminosityTwo 4) |
216 |
|
217 |
;On met le calque et l'image aux bonnes dimensions/proportions |
218 |
(gimp-image-scale theImage |
219 |
theFinalDimension |
220 |
theFinalDimension) |
221 |
|
222 |
;Suppression des dégradés |
223 |
(gimp-gradient-delete "Fond-screenshot-with-style") |
224 |
(gimp-gradient-delete "Ombre-screenshot-with-style") |
225 |
|
226 |
;Rafraichissement de l'image |
227 |
(gimp-displays-flush) |
228 |
) |
229 |
) |
230 |
|
231 |
(script-fu-register "script-fu-3d-screenshot" |
232 |
_"3D Screenshot" |
233 |
"Creates a stylish decoration for a screenshot" |
234 |
"Mathieu Piette (mathieu.piette@gmail.com)" |
235 |
"Mathieu Piette" |
236 |
"08 June, 2006" |
237 |
"" |
238 |
SF-LAYER "Layer" 0 |
239 |
SF-ADJUSTMENT "Brillance" '(30 0 100 1 10 1 0) |
240 |
SF-COLOR "Gradient (Top)" '(255 255 255) |
241 |
SF-COLOR "Gradient (Bottom)" '(230 230 230) |
242 |
SF-ADJUSTMENT "Shadow Blur" '(40 0 100 1 10 1 0) |
243 |
SF-ADJUSTMENT "Shadow Opacity" '(20 0 100 1 10 1 0) |
244 |
SF-COLOR "Shadow Colour" '(0 0 0) |
245 |
SF-ADJUSTMENT "Light Effect" '(20 0 100 1 10 1 0) |
246 |
SF-ADJUSTMENT "Image Size" '(800 0 10000 1 10 1 0) |
247 |
) |
248 |
|
249 |
(script-fu-menu-register "script-fu-3d-screenshot" |
250 |
_"<Toolbox>/Xtns/Script-Fu") |
251 |
|