home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 February / PCWorld_2001-02_cd.bin / Software / Topware / gimp / gimp-setup-20001226.exe / Main / spinning_globe.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2000-12-27  |  3.5 KB  |  119 lines

  1. ;
  2. ; anim_sphere
  3. ;
  4. ;
  5. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  6. ; At ECS Dept, University of Southampton, England.
  7. ; This program is free software; you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 2 of the License, or
  10. ; (at your option) any later version.
  11. ; This program is distributed in the hope that it will be useful,
  12. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ; GNU General Public License for more details.
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program; if not, write to the Free Software
  17. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.  
  20. ; Define the function:
  21.  
  22. (define (script-fu-spinning-globe inImage 
  23.                   inLayer 
  24.                   inFrames 
  25.                   inFromLeft 
  26.                   inTransparent 
  27.                   inIndex 
  28.                   inCopy)
  29.   (set! theImage (if (= inCopy TRUE)
  30.              (car (gimp-channel-ops-duplicate inImage))
  31.              inImage))
  32.   (set! theLayer (car (gimp-image-get-active-layer theImage)))
  33.   (gimp-layer-add-alpha theLayer)
  34.   
  35.   (set! n 0)
  36.   (set! ang (* (/ 360 inFrames) 
  37.            (if (= inFromLeft TRUE) 1 -1) ))
  38.   (while (> inFrames n)
  39.      (set! n (+ n 1))
  40.      (set! theFrame (car (gimp-layer-copy theLayer FALSE)))
  41.      (gimp-image-add-layer theImage theFrame 0)
  42.      (gimp-layer-set-name theFrame 
  43.                   (string-append "Anim Frame: " 
  44.                          (number->string (- inFrames n) 10)
  45.                          " (replace)"))
  46.      (plug-in-map-object RUN-NONINTERACTIVE
  47.                  theImage theFrame 
  48.                             ; mapping
  49.                  1
  50.                     ; viewpoint
  51.                  0.5 0.5 2.0
  52.                     ; object pos 
  53.                  0.5 0.5 0.0
  54.                     ; first axis
  55.                  1.0 0.0 0.0
  56.                     ; 2nd axis
  57.                  0.0 1.0 0.0
  58.                     ; axis rotation
  59.                  0.0 (* n ang) 0.0
  60.                     ; light (type, color)
  61.                  0 '(255 255 255)
  62.                     ; light position
  63.                  -0.5 -0.5 2.0
  64.                     ; light direction
  65.                  -1.0 -1.0 1.0
  66.                     ; material (amb, diff, refl, spec, high)
  67.                  0.3 1.0 0.5 0.0 27.0
  68.                            ; antialias 
  69.                  TRUE 
  70.                            ; tile
  71.                  FALSE
  72.                            ; new image 
  73.                  FALSE 
  74.                            ; transparency
  75.                  inTransparent 
  76.                            ; radius
  77.                  0.25
  78.                            ; unused parameters
  79.                  1.0 1.0 1.0 1.0
  80.                  0 0 0 0 0 0 0 0)
  81.      ; end while: 
  82.      )
  83.   (gimp-image-remove-layer theImage theLayer)
  84.   (plug-in-autocrop RUN-NONINTERACTIVE theImage theFrame)
  85.   
  86.   (if (= inIndex 0)
  87.       ()
  88.       (gimp-convert-indexed theImage FS-DITHER MAKE-PALETTE inIndex FALSE FALSE ""))
  89.  
  90.   (if (= inCopy TRUE)
  91.       (begin  
  92.     (gimp-image-clean-all theImage)
  93.     (gimp-display-new theImage))
  94.       ())
  95.  
  96.   (gimp-displays-flush)
  97. )
  98.  
  99. ; Register the function with the GIMP:
  100.  
  101. (script-fu-register
  102.     "script-fu-spinning-globe"
  103.     _"<Image>/Script-Fu/Animators/Spinning Globe..."
  104.     "Maps the image on an animated spinning globe"
  105.     "Chris Gutteridge"
  106.     "1998, Chris Gutteridge / ECS dept, University of Southampton, England."
  107.     "16th April 1998"
  108.     "RGB* GRAY*"
  109.     SF-IMAGE    "The Image" 0
  110.     SF-DRAWABLE "The Layer" 0
  111.     SF-ADJUSTMENT _"Frames" '(10 1 360 1 10 0 1)
  112.     SF-TOGGLE     _"Turn from Left to Right" FALSE
  113.     SF-TOGGLE     _"Transparent Background" TRUE
  114.     SF-ADJUSTMENT _"Index to n Colors (0 = Remain RGB)" '(63 0 256 1 10 0 1)
  115.     SF-TOGGLE     _"Work on Copy" TRUE
  116. )
  117.