logo Debian Debian Debian-France Debian-Facile Debian-fr.org Forum-Debian.fr Debian ? Communautés logo inclusivité

Debian-facile

Bienvenue sur Debian-Facile, site d'aide pour les nouveaux utilisateurs de Debian.

Vous n'êtes pas identifié(e).

Raw Paste Créer un nouveau Paste

GIMP Animated Snowfall Script - #F102DC2392

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ;
  18. ;
  19. ; Create an animated snowfall effect over an existing background image (must be RGB type)
  20. ;
  21. ;
  22. ; Script can be found under Filters > Animation > Animated Snow...
  23.  
  24.  
  25.  
  26. ; Define the Function
  27.  
  28. (define (script-fu-snow-anim img
  29. drawable
  30. addWhere
  31. counter
  32. snowType
  33. snowAmount
  34. speed
  35. flakeSize1
  36. flakeSize2
  37. useBlur1
  38. blurLayer1
  39. useBlur2
  40. blurLayer2
  41. selection
  42. addBorder
  43. borderWidth
  44. borderColor
  45. )
  46.  
  47. ; Declare the Variables
  48.  
  49. (let* (
  50. (theSelection 0)
  51. (theSelection2 0)
  52. (backgroundLayerCopy 0)
  53. (origSnowLayer1 0)
  54. (origSnowLayer2 0)
  55. (origSnowLayer3 0)
  56. (origSnowLayer4 0)
  57. (mergeSnowLayer 0)
  58. (copyOrigSnowLayer1 0)
  59. (copyOrigSnowLayer2 0)
  60. (copyOrigSnowLayer3 0)
  61. (copyOrigSnowLayer4 0)
  62. (step 0)
  63. (borderLayer 0)
  64. (frameNum 1)
  65. (height 0)
  66. (activeLayer 0)
  67. (layerName 0)
  68. (layerName2 0)
  69. (x-offset1 0)
  70. (x-offset2 0)
  71. (y-offset 0)
  72. (allLayersRef 0)
  73. (newImage1 0)
  74. (newImage2 0)
  75. )
  76. (if (= addWhere 0)
  77. (begin
  78.  
  79. (gimp-context-push)
  80. (gimp-image-undo-group-start img)
  81. (set! theSelection (car (gimp-selection-save img)))
  82. (gimp-selection-none img)
  83.  
  84. (gimp-context-set-background '(255 255 255))
  85.  
  86.  
  87. (set! origSnowLayer1 (car (gimp-layer-copy drawable TRUE)))
  88. (gimp-drawable-fill origSnowLayer1 FILL-WHITE)
  89. (gimp-image-add-layer img origSnowLayer1 -1)
  90. (plug-in-randomize-hurl RUN-NONINTERACTIVE img origSnowLayer1 snowAmount 1.0 FALSE FALSE)
  91. (plug-in-colortoalpha 0 img origSnowLayer1 '(255 255 255))
  92. (gimp-drawable-threshold origSnowLayer1 HISTOGRAM-VALUE 0 1)
  93. ;(gimp-threshold origSnowLayer1 0 255)
  94. ;(plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer1 flakeSize1 0.7 1)
  95. (plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer1 flakeSize1 2.0 0)
  96.  
  97.  
  98. (set! origSnowLayer2 (car (gimp-layer-copy drawable TRUE)))
  99. (gimp-drawable-fill origSnowLayer2 FILL-WHITE)
  100. (gimp-image-add-layer img origSnowLayer2 -1)
  101. (plug-in-randomize-hurl RUN-NONINTERACTIVE img origSnowLayer2 snowAmount 1.0 FALSE FALSE)
  102. (gimp-drawable-threshold origSnowLayer2 HISTOGRAM-VALUE 0 1)
  103. ;(gimp-threshold origSnowLayer2 0 255)
  104. ;(plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer2 flakeSize2 0.7 1)
  105. (plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer2 flakeSize2 2.0 0)
  106.  
  107. (set! height (car (gimp-drawable-height drawable)))
  108. (set! step (/ height counter))
  109.  
  110.  
  111. (while (> counter 0)
  112.  
  113. (if (= snowType 0)
  114. (begin
  115. (set! x-offset1 (- (random 10) 5))
  116. (set! x-offset2 (- (random 10) 5))
  117. )
  118. )
  119.  
  120. (if (= snowType 2)
  121. (begin
  122. (set! x-offset1 0)
  123. (set! x-offset2 (- (random 10) 5))
  124. )
  125. )
  126.  
  127. (set! backgroundLayerCopy (car (gimp-layer-copy drawable TRUE)))
  128. (gimp-image-add-layer img backgroundLayerCopy -1)
  129.  
  130. (set! copyOrigSnowLayer1 (car (gimp-layer-copy origSnowLayer1 TRUE)))
  131. (gimp-image-add-layer img copyOrigSnowLayer1 -1)
  132. (gimp-drawable-offset copyOrigSnowLayer1 TRUE 1 x-offset1 y-offset)
  133.  
  134. (if (= useBlur1 TRUE)
  135. (begin
  136. (plug-in-gauss-rle2 RUN-NONINTERACTIVE img copyOrigSnowLayer1 blurLayer1 blurLayer1)
  137. )
  138. )
  139.  
  140. (set! copyOrigSnowLayer2 (car (gimp-layer-copy origSnowLayer2 TRUE)))
  141. (gimp-image-add-layer img copyOrigSnowLayer2 -1)
  142. (gimp-drawable-offset copyOrigSnowLayer2 TRUE 1 (* -1 x-offset2) y-offset)
  143.  
  144. (if (= useBlur2 TRUE)
  145. (begin
  146. (plug-in-gauss-rle2 RUN-NONINTERACTIVE img copyOrigSnowLayer2 blurLayer2 blurLayer2)
  147. )
  148. )
  149.  
  150. (set! copyOrigSnowLayer2 (car (gimp-image-get-active-layer img)))
  151. (gimp-image-merge-down img copyOrigSnowLayer2 CLIP-TO-IMAGE)
  152.  
  153. (set! mergeSnowLayer (car (gimp-image-get-active-layer img)))
  154.  
  155.  
  156. (if (= selection TRUE)
  157. (begin
  158. (gimp-selection-load theSelection)
  159. (gimp-selection-invert img)
  160. (gimp-edit-clear mergeSnowLayer)
  161. (gimp-selection-none img)
  162. )
  163. )
  164.  
  165. (set! activeLayer (car (gimp-image-merge-down img mergeSnowLayer CLIP-TO-IMAGE)))
  166.  
  167.  
  168. (set! activeLayer (car (gimp-image-get-active-layer img)))
  169. (set! layerName (string-append "Frame " (number->string frameNum) " (" (number->string speed) "ms)" " (replace)"))
  170. (gimp-drawable-set-name activeLayer layerName)
  171.  
  172. (if (= addBorder TRUE)
  173. (begin
  174. (set! borderLayer (car (gimp-layer-copy activeLayer TRUE)))
  175. (gimp-image-add-layer img borderLayer -1)
  176. (gimp-selection-all img)
  177. (gimp-context-set-foreground borderColor)
  178. (gimp-drawable-fill borderLayer FOREGROUND-FILL)
  179. (gimp-selection-shrink img borderWidth)
  180. (gimp-edit-clear borderLayer)
  181. (gimp-selection-none img)
  182. (gimp-image-merge-down img borderLayer CLIP-TO-IMAGE)
  183. )
  184. )
  185.  
  186.  
  187. (set! y-offset (+ y-offset step))
  188. (set! frameNum (+ frameNum 1))
  189. (set! counter (- counter 1))
  190.  
  191. ) ; goes with while
  192.  
  193. ; Removes the original layer from the stack because it's no longer needed
  194.  
  195. (gimp-image-remove-layer img drawable)
  196. (gimp-image-remove-layer img origSnowLayer1)
  197. (gimp-image-remove-layer img origSnowLayer2)
  198.  
  199. (gimp-selection-load theSelection)
  200. (gimp-image-remove-channel img theSelection)
  201.  
  202. (gimp-image-undo-group-end img)
  203.  
  204. (gimp-context-pop)
  205.  
  206. (gimp-displays-flush)
  207.  
  208. ); goes with begin
  209. ); goes with main 'if' = "0"
  210.  
  211.  
  212.  
  213.  
  214. (if (= addWhere 1)
  215. (begin
  216.  
  217. (gimp-context-push)
  218. (gimp-image-undo-group-start img)
  219. (set! theSelection (car (gimp-selection-save img)))
  220. (gimp-selection-none img)
  221.  
  222. (gimp-context-set-background '(255 255 255))
  223. (set! counter (car (gimp-image-get-layers img)))
  224. (set! allLayersRef (cadr (gimp-image-get-layers img)))
  225.  
  226. (set! origSnowLayer1 (car (gimp-layer-copy drawable TRUE)))
  227. (gimp-drawable-fill origSnowLayer1 FILL-WHITE)
  228.  
  229. (gimp-image-add-layer img origSnowLayer1 -1)
  230. (plug-in-randomize-hurl RUN-NONINTERACTIVE img origSnowLayer1 snowAmount 1.0 TRUE TRUE)
  231. (plug-in-colortoalpha 0 img origSnowLayer1 '(255 255 255))
  232. (gimp-drawable-threshold origSnowLayer1 HISTOGRAM-VALUE 0 1)
  233. (plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer1 flakeSize1 2.0 0)
  234.  
  235. ;(gimp-image-add-layer img origSnowLayer1 -1)
  236. ;(plug-in-randomize-hurl RUN-NONINTERACTIVE img origSnowLayer1 snowAmount 1.0 TRUE TRUE)
  237. ;(gimp-threshold origSnowLayer1 0 255)
  238. ;(plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer1 flakeSize1 0.7 1)
  239.  
  240. (set! origSnowLayer2 (car (gimp-layer-copy drawable TRUE)))
  241. (gimp-drawable-fill origSnowLayer2 FILL-WHITE)
  242.  
  243. (gimp-image-add-layer img origSnowLayer2 -1)
  244. (plug-in-randomize-hurl RUN-NONINTERACTIVE img origSnowLayer2 snowAmount 1.0 TRUE TRUE)
  245. (gimp-drawable-threshold origSnowLayer2 HISTOGRAM-VALUE 0 1)
  246. (plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer2 flakeSize2 2.0 0)
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256. ;(gimp-image-add-layer img origSnowLayer2 -1)
  257. ;(plug-in-randomize-hurl RUN-NONINTERACTIVE img origSnowLayer2 snowAmount 1.0 TRUE TRUE)
  258. ;(gimp-threshold origSnowLayer2 0 255)
  259. ;(plug-in-cubism RUN-NONINTERACTIVE img origSnowLayer2 flakeSize2 0.7 1)
  260.  
  261. (set! height (car (gimp-drawable-height drawable)))
  262. (set! step (/ height counter))
  263.  
  264.  
  265. (while (> counter 0)
  266.  
  267. (if (= snowType 0)
  268. (begin
  269. (set! x-offset1 (- (random 10) 5))
  270. (set! x-offset2 (- (random 10) 5))
  271. )
  272. )
  273.  
  274. (if (= snowType 2)
  275. (begin
  276. (set! x-offset1 0)
  277. (set! x-offset2 (- (random 10) 5))
  278. )
  279. )
  280.  
  281. (set! backgroundLayerCopy (car (gimp-image-set-active-layer img (aref allLayersRef (- counter 1)))))
  282. (set! activeLayer (car (gimp-image-get-active-layer img)))
  283.  
  284. (set! copyOrigSnowLayer1 (car (gimp-layer-copy origSnowLayer1 TRUE)))
  285. (gimp-image-add-layer img copyOrigSnowLayer1 -1)
  286. (gimp-drawable-offset copyOrigSnowLayer1 TRUE 1 x-offset1 y-offset)
  287.  
  288. (if (= useBlur1 TRUE)
  289. (begin
  290. (plug-in-gauss-rle2 RUN-NONINTERACTIVE img copyOrigSnowLayer1 blurLayer1 blurLayer1)
  291. )
  292. )
  293.  
  294. (set! copyOrigSnowLayer2 (car (gimp-layer-copy origSnowLayer2 TRUE)))
  295. (gimp-image-add-layer img copyOrigSnowLayer2 -1)
  296. (gimp-drawable-offset copyOrigSnowLayer2 TRUE 1 (* -1 x-offset2) y-offset)
  297.  
  298. (if (= useBlur2 TRUE)
  299. (begin
  300. (plug-in-gauss-rle2 RUN-NONINTERACTIVE img copyOrigSnowLayer2 blurLayer2 blurLayer2)
  301. )
  302. )
  303.  
  304.  
  305. (set! copyOrigSnowLayer2 (car (gimp-image-get-active-layer img)))
  306. (gimp-image-merge-down img copyOrigSnowLayer2 CLIP-TO-IMAGE)
  307.  
  308. (set! mergeSnowLayer (car (gimp-image-get-active-layer img)))
  309.  
  310.  
  311. (if (= selection TRUE)
  312. (begin
  313. (gimp-selection-load theSelection)
  314. (gimp-selection-invert img)
  315. (gimp-edit-clear mergeSnowLayer)
  316. (gimp-selection-none img)
  317. )
  318. )
  319.  
  320. (set! activeLayer (car (gimp-image-merge-down img mergeSnowLayer CLIP-TO-IMAGE)))
  321.  
  322. (set! activeLayer (car (gimp-image-get-active-layer img)))
  323.  
  324. (if (= addBorder TRUE)
  325. (begin
  326. (set! borderLayer (car (gimp-layer-copy activeLayer TRUE)))
  327. (gimp-image-add-layer img borderLayer -1)
  328. (gimp-selection-all img)
  329. (gimp-context-set-foreground borderColor)
  330. (gimp-drawable-fill borderLayer FOREGROUND-FILL)
  331. (gimp-selection-shrink img borderWidth)
  332. (gimp-edit-clear borderLayer)
  333. (gimp-selection-none img)
  334. (gimp-image-merge-down img borderLayer CLIP-TO-IMAGE)
  335. )
  336. )
  337.  
  338.  
  339. (set! y-offset (+ y-offset step))
  340. (set! counter (- counter 1))
  341.  
  342. ) ; goes with while
  343.  
  344. ; Removes the original layer from the stack because it's no longer needed
  345.  
  346. (gimp-image-remove-layer img origSnowLayer1)
  347. (gimp-image-remove-layer img origSnowLayer2)
  348.  
  349. (gimp-selection-load theSelection)
  350. (gimp-image-remove-channel img theSelection)
  351.  
  352. (gimp-image-undo-group-end img)
  353.  
  354. (gimp-context-pop)
  355.  
  356. (gimp-displays-flush)
  357.  
  358. ); goes with begin
  359. ); goes with main 'if' = "1"
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370. )
  371. )
  372.  
  373. (script-fu-register "script-fu-snow-anim"
  374. "<Image>/Filters/Animation/Animators/Animated Snow..."
  375. "Create an animated snow effect"
  376. "Art Wade"
  377. "Art Wade"
  378. "November 23, 2019"
  379. "RGB*"
  380. SF-IMAGE "Image" 0
  381. SF-DRAWABLE "Drawable" 0
  382. SF-OPTION "Add Snowfall to:" '("Single Image"
  383. "Existing Animation (must be RGB format)")
  384. SF-ADJUSTMENT "Number of Frames (not used if adding snow to an existing animation)" '(15 1 50 1 10 0 1)
  385. SF-OPTION "Snowfall Type" '("Random"
  386. "Straight Down"
  387. "Combined Random and Straight Down")
  388. SF-ADJUSTMENT "Snow Amount" '(10.00 1.00 100.00 0.5 1 2 1)
  389. SF-ADJUSTMENT "Snowfall Speed (in ms) (Not used when adding snow to existing animation)" '(150 10 500 1 1 0 1)
  390. SF-ADJUSTMENT "Snowflake Size Layer 1" '(2.15 0.10 5.00 0.50 1 2 1)
  391. SF-ADJUSTMENT "Snowflake Size Layer 2" '(0.50 0.10 5.000 0.50 1 2 1)
  392. SF-TOGGLE "Blur Snowflake Layer 1?" TRUE
  393. SF-ADJUSTMENT "Blur Amount Snowflake Layer 1" '(0.50 0.10 20.0 0.05 1 2 1)
  394. SF-TOGGLE "Blur Snowflake Layer 2?" TRUE
  395. SF-ADJUSTMENT "Blur Amount Snowflake Layer 2" '(0.50 0.10 20.0 0.05 1 2 1)
  396. SF-TOGGLE "Keep selection? (Limits snow to selection)" FALSE
  397. SF-TOGGLE "Add Border?" FALSE
  398. SF-ADJUSTMENT "Border Width" '(1 1 10 1 1 0 1)
  399. SF-COLOR "Border Color" '(255 255 255)
  400. )

Pied de page des forums

Propulsé par FluxBB