-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2028_nuit.scm
318 lines (274 loc) · 11.2 KB
/
2028_nuit.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
;Modernized with ModernizeMatic7 for Gimp 2.10.22 by vitforlinux.wordpress.com - dont remove
; Night Sky (image/alpha/logo)
; Version 2.2 (for Gimp 2.2) - 16 Sep. 2007
;
;
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; Render night skies with figurative stars
; Copyright (C) 2003-2007 Eric Lamarque
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
(define (real-night img star-color sky-color do-merge)
(define (randots img layer number tileable)
(let* ((remaining-points number)
(width (if (= tileable FALSE) (car (gimp-image-width img))
(- (car (gimp-image-width img))
(cadr (gimp-brushes-get-brush)))))
(height (if (= tileable FALSE) (car (gimp-image-height img))
(- (car (gimp-image-height img))
(caddr (gimp-brushes-get-brush)))))
)
(while (> remaining-points 0)
(let* ((point (cons-array 2 'double)))
(if (= tileable FALSE)
(begin
(aset point 0 (rand width))
(aset point 1 (rand height)))
(begin
(aset point 0 (+ (rand width)
(/ (cadr (gimp-brushes-get-brush)) 2)))
(aset point 1 (+ (rand height)
(/ (caddr (gimp-brushes-get-brush)) 2)))))
(gimp-paintbrush-default layer 2 point)
(set! remaining-points (- remaining-points 1))
)
)
)
)
(let* ((width (car (gimp-image-width img)))
(height (car (gimp-image-height img)))
(black-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Black" 100 LAYER-MODE-NORMAL-LEGACY)))
(star-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Stars" 100 LAYER-MODE-NORMAL-LEGACY)))
(glowleft-layer 0)
(glowright-layer 0)
(glowup-layer 0)
(glowdown-layer 0)
(n-little-stars (/ width 4)) ; little tip to adapt number of stars
(n-mean-stars (/ n-little-stars 2))
(n-big-stars (/ n-mean-stars 4))
(sky-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Sky" 100 LAYER-MODE-NORMAL-LEGACY)))
(skymask-layer (car (gimp-layer-create-mask sky-layer ADD-MASK-WHITE)))
(old-fg (car (gimp-palette-get-foreground)))
(old-bg (car (gimp-palette-get-background)))
(old-brush (car (gimp-brushes-get-brush))))
; add new layers to image
(gimp-image-insert-layer img black-layer 0 -1)
(gimp-image-insert-layer img star-layer 0 -1)
(gimp-image-insert-layer img sky-layer 0 -1)
; clear all layer
(gimp-selection-invert img)
(gimp-drawable-edit-clear black-layer)
(gimp-drawable-edit-clear star-layer)
(gimp-drawable-edit-clear sky-layer)
(gimp-selection-invert img)
(gimp-drawable-edit-clear black-layer)
(gimp-drawable-edit-clear star-layer)
(gimp-drawable-edit-clear sky-layer)
; black background
(gimp-palette-set-foreground '(0 0 0))
(gimp-drawable-edit-fill black-layer FOREGROUND-FILL)
; stars
(gimp-palette-set-foreground star-color)
(gimp-brushes-set-brush "Circle (01)")
(randots img star-layer n-little-stars FALSE)
(gimp-brushes-set-brush "Circle (03)")
(randots img star-layer n-mean-stars FALSE)
(gimp-brushes-set-brush "Circle (05)")
(randots img star-layer n-big-stars FALSE)
; glowing
(set! glowleft-layer (car (gimp-layer-copy star-layer FALSE)))
(gimp-image-insert-layer img glowleft-layer 0 -1)
(plug-in-mblur 1 img glowleft-layer 0 10 0 0 0)
(set! glowright-layer (car (gimp-layer-copy star-layer FALSE)))
(gimp-image-insert-layer img glowright-layer 0 -1)
(plug-in-mblur 1 img glowright-layer 0 10 180 0 0)
(set! glowup-layer (car (gimp-layer-copy star-layer FALSE)))
(gimp-image-insert-layer img glowup-layer 0 -1)
(plug-in-mblur 1 img glowup-layer 0 10 90 0 0)
(set! glowdown-layer (car (gimp-layer-copy star-layer FALSE)))
(gimp-image-insert-layer img glowdown-layer 0 -1)
(plug-in-mblur 1 img glowdown-layer 0 10 270 0 0)
(gimp-image-raise-layer-to-top img star-layer)
; blue atmosphere
(gimp-palette-set-foreground sky-color)
(gimp-drawable-edit-fill sky-layer FOREGROUND-FILL)
; atmosphere dim with height
(gimp-palette-set-default-colors) ; generate segfault
(gimp-image-add-layer-mask img sky-layer skymask-layer)
(gimp-edit-blend skymask-layer BLEND-FG-BG-RGB NORMAL-MODE
GRADIENT-LINEAR 100 0 REPEAT-NONE
FALSE FALSE 3 0.20 TRUE 1 1 1 height)
(gimp-image-raise-layer-to-top img sky-layer)
(if (= do-merge TRUE)
(let* ((merged-layer 0))
(set! merged-layer (car (gimp-image-merge-down img sky-layer
CLIP-TO-IMAGE)))
(set! merged-layer (car (gimp-image-merge-down img merged-layer
CLIP-TO-IMAGE)))
(set! merged-layer (car (gimp-image-merge-down img merged-layer
CLIP-TO-IMAGE)))
(set! merged-layer (car (gimp-image-merge-down img merged-layer
CLIP-TO-IMAGE)))
(set! merged-layer (car (gimp-image-merge-down img merged-layer
CLIP-TO-IMAGE)))
(set! merged-layer (car (gimp-image-merge-down img merged-layer
CLIP-TO-IMAGE)))
(gimp-item-set-name merged-layer "Night sky")
)
)
(gimp-brushes-set-brush old-brush)
(gimp-palette-set-foreground old-fg)
(gimp-palette-set-background old-bg)
(gimp-displays-flush)
)
)
(define (script-fu-nuit width height star-color sky-color do-merge)
(let* ((img (car (gimp-image-new width height RGB))))
(gimp-image-undo-disable img)
(gimp-selection-all img)
(real-night img star-color sky-color do-merge)
(gimp-selection-none img)
(gimp-image-clean-all img)
(gimp-image-undo-enable img)
(gimp-display-new img)
))
(define (script-fu-context-night img layer star-color sky-color do-merge)
(gimp-undo-push-group-start img)
(real-night img star-color sky-color do-merge)
(gimp-image-undo-group-end img)
)
(script-fu-register "script-fu-context-night"
_"<Image>/Script-Fu/Render/Night sky"
"Night Sky"
"Eric Lamarque <eric_lamarque(a)yahoo.fr>"
"Eric Lamarque"
"October 2003"
"RGB*"
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-COLOR _"Star color" '(255 255 255)
SF-COLOR _"Sky color" '(31 17 221)
SF-TOGGLE _"Merge layer?" TRUE
)
(script-fu-register "script-fu-nuit"
"<Toolbox>/Xtns/Script-Fu/Misc/Night sky"
"Night Sky"
"Eric Lamarque <eric_lamarque(a)yahoo.fr>"
"Eric Lamarque"
"October 2003"
""
SF-ADJUSTMENT _"Width" '(400 1 2048 1 10 0 1)
SF-ADJUSTMENT _"Height" '(400 1 2048 1 10 0 1)
SF-COLOR _"Star color" '(255 255 255)
SF-COLOR _"Sky color" '(31 17 221)
SF-TOGGLE _"Merge layer?" TRUE
)
(define (script-fu-nightsky-logo text size font star-color sky-color bgcolor scolor sblur soff transparent)
(let* ((img (car (gimp-image-new 256 256 RGB)))
(text-layer (car (gimp-text-fontname img -1 0 0 text (+ (/ size 12) 4) TRUE size PIXELS font)))
(width (+ 20 (car (gimp-drawable-get-width text-layer))))
(height (+ 20 (car (gimp-drawable-get-height text-layer))))
(bg-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Background" 100 LAYER-MODE-NORMAL-LEGACY)))
(s-layer (car (gimp-layer-new img width height RGBA-IMAGE
"Shadow" 100 LAYER-MODE-NORMAL-LEGACY)))
(old-fg (car (gimp-palette-get-foreground)))
(old-bg (car (gimp-palette-get-background)))
(shou)
(f-layer)
)
(gimp-image-undo-disable img)
(gimp-image-resize img width height 0 0)
(set! width (car (gimp-image-width img))) ;add
(set! height (car (gimp-image-height img))) ;add
; add layer to image
(gimp-image-insert-layer img bg-layer 0 -1)
;;(if (= FALSE transparent)
;;(begin
(gimp-image-resize img (+ (+ width soff) (* sblur 1.1)) (+ (+ height soff) (* sblur 1.1)) (/ (* sblur 1.1) 2) (/ (* sblur 1.1) 2))
(gimp-layer-resize text-layer (+ (+ width soff) (* sblur 1.1)) (+ (+ height soff) (* sblur 1.1)) (/ (* sblur 1.1) 2) (/ (* sblur 1.1) 2))
(gimp-layer-resize bg-layer (+ (+ width soff) (* sblur 1.1)) (+ (+ height soff) (* sblur 1.1)) (/ (* sblur 1.1) 2) (/ (* sblur 1.1) 2))
;;))
; fill background with active background color or clear it
(gimp-selection-all img)
(if (= transparent FALSE)
(begin
(gimp-palette-set-background bgcolor)
(gimp-drawable-edit-fill bg-layer FILL-BACKGROUND)
)
(gimp-drawable-edit-clear bg-layer)
)
(gimp-layer-translate text-layer 10 10) ;moved(NO CHANGE!)
(gimp-selection-layer-alpha text-layer) ;moved
(real-night img star-color sky-color TRUE) ;moved
(gimp-selection-none img)
;; (if (= transparent FALSE)
;; (begin
(gimp-image-insert-layer img s-layer 0 1) ;add
(gimp-layer-resize s-layer (+ (+ width soff) (* sblur 1.1)) (+ (+ height soff) (* sblur 1.1)) 0 0)
(gimp-drawable-edit-clear s-layer) ;add
(gimp-selection-layer-alpha text-layer)
(gimp-palette-set-foreground scolor)
; (gimp-drawable-edit-fill bg-layer FOREGROUND-FILL) ;none
(gimp-drawable-edit-fill s-layer FOREGROUND-FILL) ;add
(gimp-selection-none img)
(if (>= sblur 1) (plug-in-gauss-rle2 1 img s-layer sblur sblur)) ;changed
(gimp-layer-translate s-layer soff soff) ;add
(gimp-selection-none img)
;; ))
; (gimp-layer-set-name (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)) "Night sky text")
(set! f-layer (car (gimp-image-merge-visible-layers img CLIP-TO-IMAGE)))
(gimp-layer-set-name f-layer "Night sky text")
;; (if (= transparent FALSE)
;; (begin
(set! width (car (gimp-image-width img))) ;add
(set! height (car (gimp-image-height img))) ;add
(if (>= soff sblur ) (set! shou sblur) ;add
(set! shou soff) ;add
) ;add
(gimp-image-resize img (- width (/ shou 2)) (- height (/ shou 2)) (- 0 (/ shou 2)) (- 0 (/ shou 2))) ;add
(gimp-layer-resize f-layer (- width (/ shou 2)) (- height (/ shou 2)) (- 0 (/ shou 2)) (- 0 (/ shou 2))) ;add
;; ))
(gimp-image-undo-enable img)
(gimp-palette-set-foreground old-fg)
(gimp-palette-set-background old-bg)
(gimp-image-clean-all img)
(gimp-displays-flush)
(gimp-display-new img)
)
)
(script-fu-register "script-fu-nightsky-logo"
"<Toolbox>/Xtns/Script-Fu/Logos/Night sky"
"Render a night sky in a logo"
"Eric Lamarque <eric_lamarque(a)yahoo.fr>"
"Eric Lamarque"
"October 2003"
""
SF-TEXT _"Text" "NIGHT SKY"
SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 1000 1 10 0 1)
SF-FONT _"Font" "RoostHeavy"
SF-COLOR _"Star color" '(255 255 255)
SF-COLOR _"Sky color" '(38 63 127)
SF-COLOR _"Background color" '(255 255 255)
SF-COLOR _"Shadow color" '(0 0 0)
SF-ADJUSTMENT _"Shadow blur" '(10 0 100 1 10 0 1)
SF-ADJUSTMENT _"Shadow offset" '(3 0 100 1 10 0 1)
SF-TOGGLE "Transparent?" FALSE
)