home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 February / PCWorld_2001-02_cd.bin / Software / Topware / gimp / gimp-setup-20001226.exe / Main / alien-glow-arrow.scm < prev    next >
Encoding:
Text File  |  2000-12-27  |  4.4 KB  |  138 lines

  1.  
  2.  
  3. ; The GIMP -- an image manipulation program
  4. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  5. ; Alien Glow themed arrows for web pages
  6. ; Copyright (c) 1997 Adrian Likins
  7. ; aklikins@eos.ncsu.edu
  8. ;
  9. ;
  10. ; Based on code from
  11. ; Federico Mena Quintero
  12. ; federico@nuclecu.unam.mx
  13. ; This program is free software; you can redistribute it and/or modify
  14. ; it under the terms of the GNU General Public License as published by
  15. ; the Free Software Foundation; either version 2 of the License, or
  16. ; (at your option) any later version.
  17. ; This program is distributed in the hope that it will be useful,
  18. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ; GNU General Public License for more details.
  21. ; You should have received a copy of the GNU General Public License
  22. ; along with this program; if not, write to the Free Software
  23. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25.  
  26.  
  27.  
  28.  
  29. (define (make-point x y)
  30.   (cons x y))
  31.  
  32. (define (point-x p)
  33.   (car p))
  34.  
  35. (define (point-y p)
  36.   (cdr p))
  37.  
  38. (define (point-list->double-array point-list)
  39.   (define (convert points array pos)
  40.     (if (not (null? points))
  41.     (begin
  42.       (aset array (* 2 pos) (point-x (car points)))
  43.       (aset array (+ 1 (* 2 pos)) (point-y (car points)))
  44.       (convert (cdr points) array (+ pos 1)))))
  45.  
  46.   (let* ((how-many (length point-list))
  47.      (a (cons-array (* 2 how-many) 'double)))
  48.     (convert point-list a 0)
  49.     a))
  50.  
  51. (define (make-arrow size offset)
  52.   (list (make-point offset offset)
  53.     (make-point (- size offset) (/ size 2))
  54.     (make-point offset (- size offset))))
  55.  
  56.  
  57. (define (rotate-points points size orientation)
  58.   (if (null? points)
  59.       '()
  60.       (let* ((p (car points))
  61.          (px (point-x p))
  62.          (py (point-y p)))
  63.     (cons (cond (= orientation 0) (make-point px py))           ; right
  64.           (= orientation 1) (make-point (- size px) py))  ; left
  65.             (= orientation 2) (make-point py (- size px)))  ; up
  66.             (= orientation 3) (make-point py px))           ; down
  67.   (rotate-points (cdr points) size orientation))
  68.  
  69.  
  70. (define (script-fu-alien-glow-right-arrow size orientation glow-color bg-color flatten)
  71.   (let* ((img (car (gimp-image-new size size RGB)))
  72.      (grow-amount (/ size 12))
  73.      (blur-radius (/ size 3))
  74.      (offset (/ size 6))
  75.      (ruler-layer (car (gimp-layer-new img size size  RGBA_IMAGE "Ruler" 100 NORMAL)))
  76.      (glow-layer (car (gimp-layer-new img size size  RGBA_IMAGE "Alien Glow" 100 NORMAL)))
  77.      (bg-layer (car (gimp-layer-new img size size  RGB_IMAGE "Back" 100 NORMAL)))
  78.      (big-arrow (point-list->double-array (rotate-points (make-arrow size offset) size orientation)))
  79.      (old-fg (car (gimp-palette-get-foreground)))
  80.      (old-bg (car (gimp-palette-get-background))))
  81.     
  82.     
  83.     (gimp-image-undo-disable img)
  84.     ;(gimp-image-resize img (+ length height) (+ height height) 0 0)
  85.     (gimp-image-add-layer img bg-layer 1)
  86.     (gimp-image-add-layer img glow-layer -1)
  87.     (gimp-image-add-layer img ruler-layer -1)
  88.     
  89.     (gimp-edit-clear glow-layer)
  90.     (gimp-edit-clear ruler-layer)
  91.  
  92.  
  93.     (gimp-free-select img 6 big-arrow REPLACE TRUE FALSE 0)
  94.  
  95.     (gimp-palette-set-foreground '(103 103 103))
  96.     (gimp-palette-set-background '(0 0 0))
  97.     (gimp-blend ruler-layer FG-BG-RGB NORMAL SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE 0 0 0 0 size size)
  98.     
  99.     (gimp-selection-grow img grow-amount)
  100.     (gimp-palette-set-foreground glow-color)
  101.     (gimp-edit-fill glow-layer FG-IMAGE-FILL)
  102.  
  103.     (gimp-selection-none img)
  104.  
  105.  
  106.     (plug-in-gauss-rle 1 img glow-layer blur-radius TRUE TRUE)
  107.  
  108.     (gimp-palette-set-background bg-color)
  109.     (gimp-edit-fill bg-layer BG-IMAGE-FILL)
  110.     
  111.     (gimp-palette-set-background old-bg)
  112.     (gimp-palette-set-foreground old-fg)
  113.  
  114.     (if (= flatten TRUE)
  115.     (gimp-image-flatten img))
  116.     (gimp-image-undo-enable img)
  117.     (gimp-display-new img)))
  118.  
  119. (script-fu-register "script-fu-alien-glow-right-arrow"
  120.             _"<Toolbox>/Xtns/Script-Fu/Web Page Themes/Alien Glow/Arrow..."
  121.             "Create an X-file deal"
  122.             "Adrian Likins"
  123.             "Adrian Likins"
  124.             "1997"
  125.             ""
  126.             SF-ADJUSTMENT _"Size" '(32 5 150 1 10 0 1)
  127.             SF-OPTION     _"Orientation" '(_"Right" 
  128.                            _"Left" 
  129.                            _"Up" 
  130.                            _"Down")
  131.             SF-COLOR      _"Glow Color" '(63 252 0)
  132.             SF-COLOR      _"Background Color" '(0 0 0)
  133.             SF-TOGGLE     _"Flatten Image" TRUE)
  134.