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

  1. ; Newsprint text
  2. ; Copyright (c) 1998 Austin Donnelly <austin@greenend.org.uk>
  3. ;
  4. ;
  5. ; Based on alien glow code from Adrian Likins
  6. ; This program is free software; you can redistribute it and/or modify
  7. ; it under the terms of the GNU General Public License as published by
  8. ; the Free Software Foundation; either version 2 of the License, or
  9. ; (at your option) any later version.
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ; GNU General Public License for more details.
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.  
  19. (define (script-fu-newsprint-text string font font-size cell-size density blur-radius text-color bg-color)
  20.   (let* ((text-ext (gimp-text-get-extents-fontname string font-size PIXELS font))
  21.      (width (+ (car text-ext) 20 blur-radius))
  22.      (height  (+ (nth 1 text-ext) 20 blur-radius))
  23.      (img (car (gimp-image-new width height RGB)))
  24.      (bg-layer (car (gimp-layer-new img width height  RGB_IMAGE "Background" 100 NORMAL)))
  25.      (text-layer (car (gimp-layer-new img width height  RGBA_IMAGE "Text layer" 100 NORMAL)))
  26.      (text-mask 0)
  27.      (grey (/ (* density 255) 100))
  28.      (old-fg (car (gimp-palette-get-foreground)))
  29.      (old-bg (car (gimp-palette-get-background))))
  30.  
  31.     (gimp-image-undo-disable img)
  32.     (gimp-image-add-layer img bg-layer 1)
  33.     (gimp-image-add-layer img text-layer -1)
  34.  
  35.     (gimp-palette-set-background bg-color)
  36.     (gimp-edit-clear bg-layer)
  37.     (gimp-edit-clear text-layer)
  38.  
  39.     (gimp-palette-set-foreground text-color)
  40.     (gimp-floating-sel-anchor (car (gimp-text-fontname img text-layer (/ (+ 20 blur-radius) 2) (/ (+ 20 blur-radius) 2) string 0 TRUE font-size PIXELS font)))
  41.  
  42.     (set! text-mask (car (gimp-layer-create-mask text-layer ALPHA-MASK)))
  43.     (gimp-image-add-layer-mask img text-layer text-mask)
  44.  
  45.     (gimp-selection-layer-alpha text-layer)
  46.     (gimp-palette-set-background (list grey grey grey))
  47.     (gimp-edit-fill text-mask BG-IMAGE-FILL)
  48.     (gimp-selection-clear img)
  49.     (if (> blur-radius 0)
  50.         (plug-in-gauss-iir 1 img text-mask blur-radius 1 1)
  51.     )
  52.  
  53.     (plug-in-newsprint 1 img text-mask cell-size 0 0 45.0 3 45.0 0 45.0 0 45.0 0 3)
  54.  
  55.     (gimp-edit-fill text-layer FG-IMAGE-FILL)
  56.     (gimp-image-remove-layer-mask img text-layer APPLY)
  57.  
  58.     (gimp-palette-set-foreground old-fg)
  59.     (gimp-palette-set-background old-bg)
  60.  
  61.     (gimp-image-undo-enable img)
  62.     (gimp-display-new img)))
  63.  
  64. (script-fu-register "script-fu-newsprint-text"
  65.         _"<Toolbox>/Xtns/Script-Fu/Logos/Newsprint Text..."
  66.         "Apply a screen to text"
  67.             "Austin Donnelly"
  68.             "Austin Donnelly"
  69.             "1998"
  70.             ""
  71.             SF-STRING     _"Text" "Newsprint"
  72.             SF-FONT       _"Font" "-*-Helvetica-*-r-*-*-24-*-*-*-p-*-*-*"
  73.             SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 1000 1 10 0 1)
  74.             SF-ADJUSTMENT _"Cell Size (pixels)" '(7 1 100 1 10 0 1)
  75.             SF-ADJUSTMENT _"Density (%)" '(60 0 100 1 10 0 0)
  76.             SF-ADJUSTMENT _"Blur Radius" '(0 0 100 1 5 0 0)
  77.                     SF-COLOR      _"Text Color" '(0 0 0)
  78.             SF-COLOR      _"Background Color" '(255 255 255))
  79.