home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp.exe / Main / color-cycling.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2002-01-17  |  9.9 KB  |  254 lines

  1. ; **********************************************************************
  2. ; *  Color cycling animation script
  3. ; *  Daniel Cotting (cotting@mygale.org)
  4. ; **********************************************************************
  5. ; *  Official homepages: http://www.mygale.org/~cotting
  6. ; *                      http://cotting.citeweb.net
  7. ; *                      http://village.cyberbrain.com/cotting
  8. ; **********************************************************************    
  9. ; Makes a copy of your image and creates an animation of the active layer
  10. ; with the help of the alienmap plug-in. The animation may be saved with 
  11. ; the gif-plug-in. 
  12. ; **********************************************************************
  13. ; It is recommended to start the alienmap plug-in, to fiddle about with
  14. ; the parameters until you have found optimal start va lues. Then put 
  15. ; these values in the appropriate edit fields in the animation dialog.
  16. ; Now you can change the values in the alienmap plug-in to find interes-
  17. ; ting end values. After you have inserted these new values in the cor-
  18. ; responding fields of the animation script, you can start the calcula-
  19. ; tion of the animation. The script will create a new picture with a la-
  20. ; yer for each animation frame.    With each new frame the start values 
  21. ; will gradually turn into the specified end values, creating an amazing
  22. ; effect of color cycling.
  23. ; **********************************************************************
  24.  
  25.  
  26. ; The GIMP -- an image manipulation program
  27. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  28. ; This program is free software; you can redistribute it and/or modify
  29. ; it under the terms of the GNU General Public License as published by
  30. ; the Free Software Foundation; either version 2 of the License, or
  31. ; (at your option) any later version.  
  32. ; This program is distributed in the hope that it will be useful,
  33. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  35. ; GNU General Public License for more details.
  36. ; You should have received a copy of the GNU General Public License
  37. ; along with this program; if not, write to the Free Software
  38. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  39. ;
  40. ;
  41. ; **********************************************************************
  42. ; Original file:
  43. ; waves-anim.scm   version 1.00   09/04/97
  44. ; Copyright (C) 1997 Sven Neumann (neumanns@uni-duesseldorf.de)
  45. ; **********************************************************************
  46. ;  
  47.  
  48. (define (script-fu-colorcycling-anim img
  49.                    drawable
  50.          num-frames
  51.          startredstretch
  52.          startgreenstretch
  53.          startbluestretch
  54.          endredstretch
  55.          endgreenstretch
  56.          endbluestretch
  57.          redmode
  58.          greenmode
  59.          bluemode
  60.          redinvert
  61.          greeninvert
  62.          blueinvert
  63.          startredphase
  64.          startgreenphase
  65.          startbluephase
  66.          endredphase
  67.          endgreenphase
  68.          endbluephase
  69.          startredfrequency
  70.          startgreenfrequency
  71.          startbluefrequency
  72.          endredfrequency
  73.          endgreenfrequency
  74.          endbluefrequency
  75.          redinvert2
  76.          greeninvert2
  77.          blueinvert2)
  78.   (let* ((startredstretch (max 0 startredstretch))
  79.          (startgreenstretch (max 0 startgreenstretch))
  80.      (startbluestretch (max 0 startbluestretch))
  81.      (startredstretch (min 128 startredstretch))
  82.          (startgreenstretch (min 128 startgreenstretch))
  83.      (startbluestretch (min 128 startbluestretch))
  84.      (endredstretch (max 0 endredstretch))
  85.          (endgreenstretch (max 0 endgreenstretch))
  86.      (endbluestretch (max 0 endbluestretch))
  87.      (endredstretch (min 128 endredstretch))
  88.          (endgreenstretch (min 128 endgreenstretch))
  89.       (endbluestretch (min 128 endbluestretch))
  90.      
  91.      (redmode (max 0 redmode))
  92.      (redmode (min 2 redmode))
  93.      (greenmode (max 0 greenmode))
  94.      (greenmode (min 2 greenmode))
  95.      (bluemode (max 0 bluemode))
  96.      (bluemode (min 2 bluemode))
  97.  
  98.      (startredfrequency (max 0 startredfrequency))
  99.          (startgreenfrequency (max 0 startgreenfrequency))
  100.      (startbluefrequency (max 0 startbluefrequency))
  101.  
  102.      (endredfrequency (max 0 endredfrequency))
  103.          (endgreenfrequency (max 0 endgreenfrequency))
  104.      (endbluefrequency (max 0 endbluefrequency))
  105.           
  106.      (num-frames (max 1 num-frames))
  107.      (remaining-frames num-frames)
  108.      
  109.      (redstretch startredstretch)
  110.      (greenstretch startgreenstretch)
  111.      (bluestretch startbluestretch)
  112.      (redphase startredphase)
  113.      (greenphase startgreenphase)
  114.      (bluephase startbluephase)
  115.      (redfrequency startredfrequency)
  116.      (greenfrequency startgreenfrequency)
  117.      (bluefrequency startbluefrequency)
  118.      
  119.      (redstretchshift (/ (- endredstretch startredstretch) num-frames))
  120.      (greenstretchshift (/ (- endgreenstretch startgreenstretch) num-frames))
  121.      (bluestretchshift (/ (- endbluestretch startbluestretch) num-frames))
  122.      (redphaseshift (/ (- endredphase startredphase) num-frames))
  123.      (greenphaseshift (/ (- endgreenphase startgreenphase) num-frames))
  124.      (bluephaseshift (/ (- endbluephase startbluephase) num-frames))
  125.      (redfrequencyshift (/ (- endredfrequency startredfrequency) num-frames))
  126.      (greenfrequencyshift (/ (- endgreenfrequency startgreenfrequency) num-frames))
  127.      (bluefrequencyshift (/ (- endbluefrequency startbluefrequency) num-frames))
  128.  
  129.          (image (car (gimp-channel-ops-duplicate img))))
  130.    
  131.   (gimp-image-undo-disable image)
  132.  
  133. ;  (if (= invert TRUE)
  134. ;      (set! phaseshift (- 0 phaseshift)))
  135.  
  136.   (set! source-layer (car (gimp-image-get-active-layer image)))
  137.   
  138.   (while (> remaining-frames 1)
  139.          (set! alienmap-layer (car (gimp-layer-copy source-layer TRUE)))
  140.          (gimp-layer-set-preserve-trans alienmap-layer FALSE)
  141.      (gimp-image-add-layer image alienmap-layer -1)
  142.      (set! layer-name (string-append "Frame "
  143.                      (number->string
  144.                       (- (+ num-frames 2)
  145.                          remaining-frames) 10)))
  146.      (gimp-layer-set-name alienmap-layer layer-name)
  147.      
  148.      (plug-in-alienmap 1
  149.          image
  150.          alienmap-layer
  151.          redstretch
  152.          greenstretch
  153.          bluestretch
  154.          redmode
  155.          greenmode
  156.          bluemode
  157.          redinvert
  158.          greeninvert
  159.          blueinvert
  160.          redphase
  161.          greenphase
  162.          bluephase
  163.          redfrequency
  164.          greenfrequency
  165.          bluefrequency
  166.          redinvert2
  167.          greeninvert2
  168.          blueinvert2)
  169.  
  170.     ; Huh ? way too much arguments???
  171.     ; Why does no STATUS_CALLING_ERROR occur?
  172.       
  173.      (set! remaining-frames (- remaining-frames 1))
  174.      (set! redphase (+ redphase redphaseshift))
  175.      (set! greenphase (+ greenphase greenphaseshift))
  176.      (set! bluephase (+ bluephase bluephaseshift))
  177.      (set! redfrequency (+ redfrequency redfrequencyshift))
  178.      (set! greenfrequency (+ greenfrequency greenfrequencyshift))
  179.      (set! bluefrequency (+ bluefrequency bluefrequencyshift))
  180.      (set! redstretch (+ redstretch redstretchshift))
  181.      (set! greenstretch (+ greenstretch greenstretchshift))
  182.      (set! bluestretch (+ bluestretch bluestretchshift))
  183.      
  184.   )
  185.  
  186.   (gimp-layer-set-name source-layer "Frame 1")
  187.   (plug-in-alienmap 1
  188.          image
  189.          source-layer
  190.          redstretch
  191.          greenstretch
  192.          bluestretch
  193.          redmode
  194.          greenmode
  195.          bluemode
  196.          redinvert
  197.          greeninvert
  198.          blueinvert
  199.          redphase
  200.          greenphase
  201.          bluephase
  202.          redfrequency
  203.          greenfrequency
  204.          bluefrequency
  205.          redinvert2
  206.          greeninvert2
  207.          blueinvert2)
  208.  
  209.   (gimp-image-undo-enable image)
  210.   (gimp-display-new image)))
  211.  
  212. (script-fu-register "script-fu-colorcycling-anim"
  213.             _"<Image>/Script-Fu/Animators/Color Cycling..."
  214.             "Creates an animation with the help of the alienmap plug-in"
  215.             "Daniel Cotting (cotting@mygale.org)"
  216.             "Daniel Cotting"
  217.             "December 1997"
  218.             "RGB*"
  219.             SF-IMAGE "Image" 0
  220.             SF-DRAWABLE "Drawable" 0
  221.             SF-ADJUSTMENT _"Number of Frames" '(10 2 100 1 10 0 1)
  222.                     SF-ADJUSTMENT _"Start: Red Intensity Factor" '(128 0 128 1 10 0 1)
  223.                     SF-ADJUSTMENT _"Start: Green Intensity Factor" '(128 0 128 1 10 0 1)
  224.                     SF-ADJUSTMENT _"Start: Blue Intensity Factor" '(128 0 128 1 10 0 1)
  225.                     SF-ADJUSTMENT _"End: Red Intensity Factor" '(128 0 128 1 10 0 1)
  226.                     SF-ADJUSTMENT _"End: Green Intensity Factor" '(128 0 128 1 10 0 1)
  227.                     SF-ADJUSTMENT _"End: Blue Intensity Factor" '(128 0 128 1 10 0 1)
  228.                     SF-ADJUSTMENT _"Red Color Mode (sin:0/cos:1/none:2)" '(0 0 2 1 1 0 1)
  229.                     SF-ADJUSTMENT _"Green Color Mode (sin:0/cos:1/none:2)" '(0 0 2 1 1 0 1)
  230.                     SF-ADJUSTMENT _"Blue Color Mode (sin:0/cos:1/none:2)" '(0 0 2 1 1 0 1)
  231.                     SF-TOGGLE _"Red Inversion before Transformation" FALSE
  232.                     SF-TOGGLE _"Green Inversion before Transformation" FALSE
  233.                     SF-TOGGLE _"Blue Inversion before Transformation" FALSE
  234.                     SF-ADJUSTMENT _"Start: Red Phase Displacement (RAD)" '(0 0 6.28 0.05 1 2 1)
  235.                     SF-ADJUSTMENT _"Start: Green Phase Displacement (RAD)" '(0 0 6.28 0.05 1 2 1)
  236.                     SF-ADJUSTMENT _"Start: Blue Phase Displacement (RAD)" '(0 0 6.28 0.05 1 2 1)
  237.                     SF-ADJUSTMENT _"End: Red Phase Displacement (RAD)" '(0 0 6.28 0.05 1 2 1)
  238.                     SF-ADJUSTMENT _"End: Green Phase Displacement (RAD)" '(0 0 6.28 0.05 1 2 1)
  239.                     SF-ADJUSTMENT _"End: Blue Phase Displacement (RAD)" '(0 0 6.28 0.05 1 2 1)
  240.                     SF-ADJUSTMENT _"Start: Red Frequency (> 0)" '(1 0.01 5 0.05 1 2 1)
  241.                     SF-ADJUSTMENT _"Start: Green Frequency (> 0)" '(1 0.01 5 0.05 1 2 1)
  242.                     SF-ADJUSTMENT _"Start: Blue Frequency (> 0)" '(1 0.01 5 0.05 1 2 1)
  243.                     SF-ADJUSTMENT _"End: Red Frequency (> 0)" '(1 0.01 5 0.05 1 2 1)
  244.                     SF-ADJUSTMENT _"End: Green Frequency (> 0)" '(1 0.01 5 0.05 1 2 1)
  245.                     SF-ADJUSTMENT _"End: Blue Frequency (> 0)" '(1 0.01 5 0.05 1 2 1)
  246.                     SF-TOGGLE _"Red Inversion after Transformation" FALSE
  247.                     SF-TOGGLE _"Green Inversion after Transformation" FALSE
  248.                     SF-TOGGLE _"Blue Inversion after Transformation" FALSE)
  249.  
  250.