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

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; This program is free software; you can redistribute it and/or modify
  4. ; it under the terms of the GNU General Public License as published by
  5. ; the Free Software Foundation; either version 2 of the License, or
  6. ; (at your option) any later version.
  7. ; This program is distributed in the hope that it will be useful,
  8. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10. ; GNU General Public License for more details.
  11. ; You should have received a copy of the GNU General Public License
  12. ; along with this program; if not, write to the Free Software
  13. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. ;
  15. ; chalk.scm  version 0.11  10/10/97
  16. ;
  17. ; Copyright (C) 1997 Manish Singh <msingh@uclink4.berkeley.edu>
  18. ;  
  19. ; Makes a logo with a chalk-like text effect.
  20.  
  21. (define (apply-chalk-logo-effect img
  22.                  logo-layer
  23.                  bg-color)
  24.   (let* ((width (car (gimp-drawable-width logo-layer)))
  25.      (height (car (gimp-drawable-height logo-layer)))
  26.      (bg-layer (car (gimp-layer-new img width height RGB_IMAGE "Background" 100 NORMAL)))
  27.      (old-fg (car (gimp-palette-get-foreground)))
  28.      (old-bg (car (gimp-palette-get-background))))
  29.  
  30.     (gimp-image-resize img width height 0 0)
  31.     (gimp-image-add-layer img bg-layer 1)
  32.     (gimp-palette-set-background bg-color)
  33.     (gimp-edit-fill bg-layer BG-IMAGE-FILL)
  34.  
  35.     ; the actual effect
  36.     (gimp-layer-set-preserve-trans logo-layer FALSE)
  37.     (plug-in-gauss-rle 1 img logo-layer 2.0 1 1)
  38.     (plug-in-spread 1 img logo-layer 5.0 5.0)
  39.     (plug-in-ripple 1 img logo-layer 27 2 0 0 0 TRUE TRUE)
  40.     (plug-in-ripple 1 img logo-layer 27 2 1 0 0 TRUE TRUE)
  41.     (plug-in-sobel 1 img logo-layer TRUE TRUE TRUE)
  42.     (gimp-levels logo-layer 0 0 120 3.5 0 255)
  43.  
  44.     ; work-around for sobel edge detect screw-up (why does this happen?)
  45.     ; the top line of the image has some garbage instead of the bgcolor
  46.     (gimp-rect-select img 0 0 width 1 ADD FALSE 0)
  47.     (gimp-edit-clear logo-layer)
  48.     (gimp-selection-none img)
  49.  
  50.     (gimp-palette-set-background old-bg)
  51.     (gimp-palette-set-foreground old-fg)))
  52.  
  53.  
  54. (define (script-fu-chalk-logo-alpha img
  55.                   logo-layer
  56.                   bg-color)
  57.   (begin
  58.     (gimp-undo-push-group-start img)
  59.     (apply-chalk-logo-effect img logo-layer bg-color)
  60.     (gimp-undo-push-group-end img)
  61.     (gimp-displays-flush)))
  62.  
  63. (script-fu-register "script-fu-chalk-logo-alpha"
  64.                     _"<Image>/Script-Fu/Alpha to Logo/Chalk..."
  65.                     "Chalk scribbled logos"
  66.                     "Manish Singh <msingh@uclink4.berkeley.edu>"
  67.                     "Manish Singh"
  68.                     "October 1997"
  69.                     "RGBA"
  70.                     SF-IMAGE      "Image" 0
  71.                     SF-DRAWABLE   "Drawable" 0
  72.                     SF-COLOR      _"Background Color" '(0 0 0)
  73.             )
  74.  
  75.  
  76. (define (script-fu-chalk-logo text
  77.                   size
  78.                   font
  79.                   bg-color
  80.                   chalk-color)
  81.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  82.      (border (/ size 4))
  83.      (text-layer (car (gimp-text-fontname img -1 0 0 text border TRUE size PIXELS font)))
  84.      (old-fg (car (gimp-palette-get-foreground))))
  85.     (gimp-image-undo-disable img)
  86.     (gimp-layer-set-name text-layer text)
  87.     (gimp-palette-set-foreground chalk-color)
  88.     (gimp-layer-set-preserve-trans text-layer TRUE)
  89.     (gimp-edit-fill text-layer FG-IMAGE-FILL)
  90.     (gimp-palette-set-foreground old-fg)
  91.     (apply-chalk-logo-effect img text-layer bg-color)
  92.     (gimp-image-undo-enable img)
  93.     (gimp-display-new img)))
  94.  
  95. (script-fu-register "script-fu-chalk-logo"
  96.                     _"<Toolbox>/Xtns/Script-Fu/Logos/Chalk..."
  97.                     "Chalk scribbled logos"
  98.                     "Manish Singh <msingh@uclink4.berkeley.edu>"
  99.                     "Manish Singh"
  100.                     "October 1997"
  101.                     ""
  102.                     SF-STRING     _"Text" "CHALK"
  103.                     SF-ADJUSTMENT _"Font Size (pixels)" '(150 2 1000 1 10 0 1)
  104.                     SF-FONT       _"Font" "-*-Cooper-*-r-*-*-24-*-*-*-p-*-*-*"
  105.                     SF-COLOR      _"Background Color" '(0 0 0)
  106.                     SF-COLOR      _"Chalk Color" '(255 255 255)
  107.             )
  108.