home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 August / ENTER.ISO / files / gimp-2.0.5-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / chalk.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2004-09-26  |  4.2 KB  |  112 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-MODE)))
  27.      (old-fg (car (gimp-palette-get-foreground)))
  28.      (old-bg (car (gimp-palette-get-background))))
  29.  
  30.     (gimp-selection-none img)
  31.     (script-fu-util-image-resize-from-layer img logo-layer)
  32.     (gimp-image-add-layer img bg-layer 1)
  33.     (gimp-palette-set-background bg-color)
  34.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  35.  
  36.     ; the actual effect
  37.     (gimp-layer-set-preserve-trans logo-layer FALSE)
  38.     (plug-in-gauss-rle 1 img logo-layer 2.0 1 1)
  39.     (plug-in-spread 1 img logo-layer 5.0 5.0)
  40.     (plug-in-ripple 1 img logo-layer 27 2 0 0 0 TRUE TRUE)
  41.     (plug-in-ripple 1 img logo-layer 27 2 1 0 0 TRUE TRUE)
  42.     (plug-in-sobel 1 img logo-layer TRUE TRUE TRUE)
  43.     (gimp-levels logo-layer 0 0 120 3.5 0 255)
  44.  
  45.     ; work-around for sobel edge detect screw-up (why does this happen?)
  46.     ; the top line of the image has some garbage instead of the bgcolor
  47.     (gimp-rect-select img 0 0 width 1 CHANNEL-OP-ADD FALSE 0)
  48.     (gimp-edit-clear logo-layer)
  49.     (gimp-selection-none img)
  50.  
  51.     (gimp-palette-set-background old-bg)
  52.     (gimp-palette-set-foreground old-fg)))
  53.  
  54.  
  55. (define (script-fu-chalk-logo-alpha img
  56.                   logo-layer
  57.                   bg-color)
  58.   (begin
  59.     (gimp-image-undo-group-start img)
  60.     (apply-chalk-logo-effect img logo-layer bg-color)
  61.     (gimp-image-undo-group-end img)
  62.     (gimp-displays-flush)))
  63.  
  64. (script-fu-register "script-fu-chalk-logo-alpha"
  65.                     _"<Image>/Script-Fu/Alpha to Logo/_Chalk..."
  66.                     "Chalk scribbled logos"
  67.                     "Manish Singh <msingh@uclink4.berkeley.edu>"
  68.                     "Manish Singh"
  69.                     "October 1997"
  70.                     "RGBA"
  71.                     SF-IMAGE      "Image" 0
  72.                     SF-DRAWABLE   "Drawable" 0
  73.                     SF-COLOR      _"Background Color" '(0 0 0)
  74.             )
  75.  
  76.  
  77. (define (script-fu-chalk-logo text
  78.                   size
  79.                   font
  80.                   bg-color
  81.                   chalk-color)
  82.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  83.      (border (/ size 4))
  84.      (text-layer (car (gimp-text-fontname img -1 0 0 text border TRUE size PIXELS font)))
  85.      (old-fg (car (gimp-palette-get-foreground))))
  86.     (gimp-image-undo-disable img)
  87.     (gimp-drawable-set-name text-layer text)
  88.     (gimp-palette-set-foreground chalk-color)
  89.     (gimp-layer-set-preserve-trans text-layer TRUE)
  90.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  91.     (gimp-palette-set-foreground old-fg)
  92.     (apply-chalk-logo-effect img text-layer bg-color)
  93.     (gimp-image-undo-enable img)
  94.     (gimp-display-new img)))
  95.  
  96. (script-fu-register "script-fu-chalk-logo"
  97.                     _"<Toolbox>/Xtns/Script-Fu/Logos/_Chalk..."
  98.                     "Chalk scribbled logos"
  99.                     "Manish Singh <msingh@uclink4.berkeley.edu>"
  100.                     "Manish Singh"
  101.                     "October 1997"
  102.                     ""
  103.                     SF-STRING     _"Text" "CHALK"
  104.                     SF-ADJUSTMENT _"Font Size (pixels)" '(150 2 1000 1 10 0 1)
  105.                     SF-FONT       _"Font" "Cooper"
  106.                     SF-COLOR      _"Background Color" '(0 0 0)
  107.                     SF-COLOR      _"Chalk Color" '(255 255 255)
  108.             )
  109.