home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / Topware / gimp / gimp-setup-20001226.exe / Main / swirly-pattern.scm < prev    next >
Encoding:
Text File  |  2000-12-27  |  2.9 KB  |  90 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Pattern00 --- create a swirly tileable pattern
  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.  
  23. (define (script-fu-swirly-pattern qsize angle times)
  24.   (define (whirl-it img drawable angle times)
  25.     (if (> times 0)
  26.     (begin
  27.       (plug-in-whirl-pinch 1 img drawable angle 0.0 1.0)
  28.       (whirl-it img drawable angle (- times 1)))))
  29.  
  30.   (let* ((hsize (* qsize 2))
  31.      (img-size (* qsize 4))
  32.      (img (car (gimp-image-new img-size img-size RGB)))
  33.      (drawable (car (gimp-layer-new img img-size img-size RGB "Swirly pattern" 100 NORMAL)))
  34.  
  35.      ; Save old foregound and background colors
  36.  
  37.      (old-fg-color (car (gimp-palette-get-foreground)))
  38.      (old-bg-color (car (gimp-palette-get-background))))
  39.  
  40.     (gimp-image-undo-disable img)
  41.     (gimp-image-add-layer img drawable 0)
  42.  
  43.     ; Render checkerboard
  44.  
  45.     (gimp-palette-set-foreground '(0 0 0))
  46.     (gimp-palette-set-background '(255 255 255))
  47.  
  48.     (plug-in-checkerboard 1 img drawable 0 qsize)
  49.  
  50.     ; Whirl upper left
  51.  
  52.     (gimp-rect-select img 0 0 hsize hsize REPLACE 0 0)
  53.     (whirl-it img drawable angle times)
  54.     (gimp-invert drawable)
  55.  
  56.     ; Whirl upper right
  57.  
  58.     (gimp-rect-select img hsize 0 hsize hsize REPLACE 0 0)
  59.     (whirl-it img drawable (- angle) times)
  60.  
  61.     ; Whirl lower left
  62.  
  63.     (gimp-rect-select img 0 hsize hsize hsize REPLACE 0 0)
  64.     (whirl-it img drawable (- angle) times)
  65.  
  66.     ; Whirl lower right
  67.  
  68.     (gimp-rect-select img hsize hsize hsize hsize REPLACE 0 0)
  69.     (whirl-it img drawable angle times)
  70.     (gimp-invert drawable)
  71.  
  72.     ; Terminate
  73.  
  74.     (gimp-selection-none img)
  75.     (gimp-palette-set-foreground old-fg-color)
  76.     (gimp-palette-set-background old-bg-color)
  77.     (gimp-image-undo-enable img)
  78.     (gimp-display-new img)))
  79.  
  80. (script-fu-register "script-fu-swirly-pattern"
  81.             _"<Toolbox>/Xtns/Script-Fu/Patterns/Swirly (tileable)..."
  82.             "Create a swirly pattern"
  83.             "Federico Mena Quintero"
  84.             "Federico Mena Quintero"
  85.             "June 1997"
  86.             ""
  87.             SF-ADJUSTMENT _"Quarter Size" '(20 0 2048 1 10 0 1)
  88.             SF-ADJUSTMENT _"Whirl Angle" '(90 0 360 1 1 0 0)
  89.             SF-ADJUSTMENT _"Number of Times to Whirl" '(4 0 128 1 1 0 1))
  90.