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

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Gradient example script --- create an example image of a custom gradient
  5. ; Copyright (C) 1997 Federico Mena Quintero
  6. ; federico@nuclecu.unam.mx
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 2 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22. (define (script-fu-gradient-example width height)
  23.   (let* ((img (car (gimp-image-new width height RGB)))
  24.      (drawable (car (gimp-layer-new img width height RGB "Gradient example" 100 NORMAL)))
  25.  
  26.      ; Save old foreground and background colors
  27.  
  28.      (old-fg-color (car (gimp-palette-get-foreground)))
  29.      (old-bg-color (car (gimp-palette-get-background)))
  30.  
  31.      ; Calculate colors for checkerboard... just like in the gradient editor
  32.  
  33.      (fg-color (* 255 (/ 2 3)))
  34.      (bg-color (* 255 (/ 1 3))))
  35.  
  36.     (gimp-image-undo-disable img)
  37.     (gimp-image-add-layer img drawable 0)
  38.  
  39.     ; Render background checkerboard
  40.  
  41.     (gimp-palette-set-foreground (list fg-color fg-color fg-color))
  42.     (gimp-palette-set-background (list bg-color bg-color bg-color))
  43.     (plug-in-checkerboard 1 img drawable 0 8)
  44.  
  45.     ; Render gradient
  46.  
  47.     (gimp-blend drawable CUSTOM NORMAL LINEAR 100 0 REPEAT-NONE FALSE 0 0 0 0 (- width 1) 0)
  48.  
  49.     ; Terminate
  50.  
  51.     (gimp-palette-set-foreground old-fg-color)
  52.     (gimp-palette-set-background old-bg-color)
  53.     (gimp-image-undo-enable img)
  54.     (gimp-display-new img)))
  55.  
  56. (script-fu-register "script-fu-gradient-example"
  57.             _"<Toolbox>/Xtns/Script-Fu/Utils/Custom Gradient..."
  58.             "Create an example image of a custom gradient"
  59.             "Federico Mena Quintero"
  60.             "Federico Mena Quintero"
  61.             "June 1997"
  62.             ""
  63.             SF-ADJUSTMENT _"Width" '(400 1 2000 1 10 0 1)
  64.             SF-ADJUSTMENT _"Height" '(30 1 2000 1 10 0 1))
  65.