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

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ;  Supposed to look vaguely like roughly carved wood. Chipped away if you will.
  5. ;
  6. ;  Options: Text String -  the string to make the logo from
  7. ;           Font        -  which font to use
  8. ;           Font Size   -  how big
  9. ;           Chip Amount - how rought he chipping is (how spread the bump map is)
  10. ;           Blur Amount - the bump layer is blurred slighty by this amount
  11. ;           Invert      - whether or not to invert the bumpmap (gives a carved in feel)
  12. ;           Drop Shadow - whether or not to draw a drop shadow
  13. ;           Keep bump layer? - whether to keep the layer used as the bump map
  14. ;           fill bg with pattern? - whether to fill the background with the pattern or leave it white
  15. ;           Keep Backgroun - whether or not to remove the background layer
  16. ;  Adrian Likins  (Adrian@gimp.org)
  17. ;  Jan 11, 1998 v1
  18. ;
  19. ;  see http://www.gimp.org/~adrian/script.html
  20. ;
  21. ; This program is free software; you can redistribute it and/or modify
  22. ; it under the terms of the GNU General Public License as published by
  23. ; the Free Software Foundation; either version 2 of the License, or
  24. ; (at your option) any later version.
  25. ; This program is distributed in the hope that it will be useful,
  26. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  28. ; GNU General Public License for more details.
  29. ; You should have received a copy of the GNU General Public License
  30. ; along with this program; if not, write to the Free Software
  31. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32. ;
  33. ;  Some suggested patterns: Dried mud, 3D green, Slate
  34. ;
  35.  
  36. (define (apply-chip-away-logo-effect img
  37.                      logo-layer
  38.                      spread-amount
  39.                      blur-amount
  40.                      invert
  41.                      drop-shadow
  42.                      keep-bump
  43.                      bg-fill
  44.                      keep-back
  45.                      pattern)
  46.   (let* ((width (car (gimp-drawable-width logo-layer)))
  47.      (height (car (gimp-drawable-height logo-layer)))
  48.      (bg-layer (car (gimp-layer-new img width height RGB_IMAGE "Background" 100 NORMAL)))
  49.      (bump-layer (car (gimp-layer-new img width height RGBA_IMAGE "Bump Layer" 100 NORMAL)))
  50.      (old-fg (car (gimp-palette-get-foreground)))
  51.      (old-bg (car (gimp-palette-get-background)))
  52.      (old-pattern (car (gimp-patterns-get-pattern))))   
  53.     (gimp-image-resize img width height 0 0)
  54.     (gimp-image-add-layer img bg-layer 1)
  55.     (gimp-layer-set-preserve-trans logo-layer TRUE)
  56.     (gimp-patterns-set-pattern pattern)
  57.  
  58.     (gimp-palette-set-background '(255 255 255))
  59.     (gimp-selection-all img)
  60.  
  61.     (if (= bg-fill TRUE)
  62.     (gimp-bucket-fill bg-layer 2 NORMAL 100 255 FALSE 1 1)
  63.     (gimp-edit-fill bg-layer BG-IMAGE-FILL))
  64.  
  65.     (gimp-selection-all img)
  66.     (gimp-edit-clear bump-layer)
  67.     (gimp-selection-none img)
  68.     (gimp-selection-layer-alpha logo-layer)
  69.     (gimp-edit-fill bump-layer BG-IMAGE-FILL)
  70.     (gimp-bucket-fill logo-layer 2 NORMAL 100 255 FALSE 1 1)
  71.     (gimp-selection-none img)
  72.     
  73.     (gimp-image-add-layer img bump-layer 1)
  74.  
  75.     (gimp-layer-set-preserve-trans bump-layer FALSE)
  76.     (plug-in-spread 1 img bump-layer spread-amount spread-amount)
  77.     (gimp-selection-layer-alpha bump-layer)
  78.     (plug-in-gauss-rle 1 img bump-layer blur-amount TRUE TRUE)
  79.    
  80.     (gimp-selection-none img)
  81.     
  82.     (plug-in-bump-map 1 img logo-layer bump-layer 135.00 25.0 60 0 0 0 0 TRUE invert 1)
  83.  
  84.     (gimp-layer-set-visible bump-layer FALSE)
  85.  
  86.      (if (= drop-shadow TRUE)
  87.     (begin
  88.       (let* ((shadow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Shadow layer" 100 NORMAL))))
  89.         (gimp-selection-all img)
  90.         (gimp-edit-clear shadow-layer)
  91.         (gimp-selection-none img)
  92.         (gimp-selection-layer-alpha logo-layer)
  93.         (gimp-palette-set-background '(0 0 0))
  94.         (gimp-edit-fill shadow-layer BG-IMAGE-FILL)
  95.         (gimp-selection-none img)
  96.         (plug-in-gauss-rle 1 img shadow-layer 5 TRUE TRUE)
  97.         (gimp-image-add-layer img shadow-layer 1)
  98.         (gimp-layer-translate shadow-layer 6 6))))
  99.  
  100.      (if (= keep-bump FALSE)
  101.      (gimp-image-remove-layer img bump-layer))
  102.  
  103.      (if (= keep-back FALSE)
  104.      (gimp-image-remove-layer img bg-layer))
  105.     
  106.     (gimp-patterns-set-pattern old-pattern)
  107.     (gimp-palette-set-foreground old-fg)
  108.     (gimp-palette-set-background old-bg)
  109.     ))
  110.  
  111. (define (script-fu-chip-away-logo-alpha img
  112.                     logo-layer
  113.                     spread-amount
  114.                     blur-amount
  115.                     invert
  116.                     drop-shadow
  117.                     keep-bump
  118.                     bg-fill
  119.                     keep-back
  120.                     pattern)
  121.   (begin
  122.     (gimp-undo-push-group-start img)
  123.     (apply-chip-away-logo-effect img logo-layer spread-amount blur-amount
  124.                  invert drop-shadow keep-bump bg-fill
  125.                  keep-back pattern)
  126.     (gimp-undo-push-group-end img)
  127.     (gimp-displays-flush)))
  128.  
  129. (script-fu-register "script-fu-chip-away-logo-alpha"
  130.             _"<Image>/Script-Fu/Alpha to Logo/Chip Away..."
  131.             "Chip away effect"
  132.             "Adrian Likins <adrian@gimp.org>"
  133.             "Adrian Likins <adrian@gimp.org>"
  134.             "1997"
  135.             "RGBA"
  136.                     SF-IMAGE      "Image" 0
  137.                     SF-DRAWABLE   "Drawable" 0
  138.             SF-ADJUSTMENT _"Chip Amount" '(30 0 250 1 10 0 1)
  139.             SF-ADJUSTMENT _"Blur Amount" '(3 1 100 1 10 1 0)
  140.             SF-TOGGLE     _"Invert" FALSE
  141.             SF-TOGGLE     _"Drop Shadow" TRUE
  142.             SF-TOGGLE     _"Keep Bump Layer" FALSE
  143.             SF-TOGGLE     _"Fill BG with Pattern" TRUE
  144.             SF-TOGGLE     _"Keep Background" TRUE
  145.             SF-PATTERN    _"Pattern" "Burlwood"
  146.             )
  147.  
  148.  
  149. (define (script-fu-chip-away-logo text
  150.                   font
  151.                   font-size
  152.                   spread-amount
  153.                   blur-amount
  154.                   invert
  155.                   drop-shadow
  156.                   keep-bump
  157.                   bg-fill
  158.                   keep-back
  159.                   pattern)
  160.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  161.      (text-layer (car (gimp-text-fontname img -1 0 0
  162.                      text 30 TRUE font-size PIXELS font))))
  163.     (gimp-image-undo-disable img)
  164.     (gimp-layer-set-name text-layer text)
  165.     (apply-chip-away-logo-effect img text-layer spread-amount blur-amount
  166.                  invert drop-shadow keep-bump bg-fill
  167.                  keep-back pattern)
  168.     (gimp-image-undo-enable img)
  169.     (gimp-display-new img)))
  170.  
  171. (script-fu-register "script-fu-chip-away-logo"
  172.             _"<Toolbox>/Xtns/Script-Fu/Logos/Chip Away..."
  173.             "Chip away effect"
  174.             "Adrian Likins <adrian@gimp.org>"
  175.             "Adrian Likins <adrian@gimp.org>"
  176.             "1997"
  177.             ""
  178.             SF-STRING _"Text" "Sloth"
  179.             SF-FONT   _"Font" "-*-roostheavy-*-r-*-*-24-*-*-*-p-*-*-*"
  180.             SF-ADJUSTMENT _"Font Size (pixels)" '(200 2 1000 1 10 0 1)
  181.             SF-ADJUSTMENT _"Chip Amount" '(30 0 250 1 10 0 1)
  182.             SF-ADJUSTMENT _"Blur Amount" '(3 1 100 1 10 1 0)
  183.             SF-TOGGLE     _"Invert" FALSE
  184.             SF-TOGGLE     _"Drop Shadow" TRUE
  185.             SF-TOGGLE     _"Keep Bump Layer" FALSE
  186.             SF-TOGGLE     _"Fill BG with Pattern" TRUE
  187.             SF-TOGGLE     _"Keep Background" TRUE
  188.             SF-PATTERN    _"Pattern" "Burlwood"
  189.             )
  190.  
  191.