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

  1. ;;; i26-gunya2.scm -*-scheme-*-
  2. ;;; Time-stamp: <1997/05/11 18:46:26 narazaki@InetQ.or.jp>
  3. ;;; Author: Shuji Narazaki (narazaki@InetQ.or.jp)
  4. ; ************************************************************************
  5. ; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
  6. ; For use with GIMP 1.1.
  7. ; All calls to gimp-text-* have been converted to use the *-fontname form.
  8. ; The corresponding parameters have been replaced by an SF-FONT parameter.
  9. ; ************************************************************************
  10.  
  11. ;;; Comment:
  12. ;;;  This is the first font decoration of Imigre-26 (i26)
  13. ;;; Code:
  14.  
  15. (define (script-fu-i26-gunya2 text text-color frame-color font font-size frame-size)
  16.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  17.      (border (/ font-size 10))
  18.      (text-layer (car (gimp-text-fontname img -1 0 0 text (* border 2)
  19.                           TRUE font-size PIXELS font))) 
  20.      (width (car (gimp-drawable-width text-layer)))
  21.      (height (car (gimp-drawable-height text-layer)))
  22.      (dist-text-layer (car (gimp-layer-new img width height RGBA_IMAGE
  23.                            "Distorted text" 100 NORMAL)))
  24.      (dist-frame-layer (car (gimp-layer-new img width height RGBA_IMAGE
  25.                         "Distorted text" 100 NORMAL)))
  26.      (distortion-img (car (gimp-image-new width height GRAY)))
  27.      (distortion-layer (car (gimp-layer-new distortion-img width height
  28.                         GRAY_IMAGE "temp" 100 NORMAL)))
  29.      (radius (/ font-size 10))
  30.      (prob 0.5)
  31.      (old-fg (car (gimp-palette-get-foreground)))
  32.      (old-bg (car (gimp-palette-get-background)))
  33.      (old-brush (car (gimp-brushes-get-brush)))
  34.      (old-paint-mode (car (gimp-brushes-get-paint-mode))))
  35.     (gimp-image-undo-disable img)
  36.     (gimp-image-undo-disable distortion-img)
  37.     (gimp-image-resize img width height 0 0)
  38.     (gimp-image-add-layer img dist-text-layer -1)
  39.     (gimp-image-add-layer img dist-frame-layer -1)
  40.     (gimp-image-add-layer distortion-img distortion-layer -1)
  41.     (gimp-selection-none img)
  42.     (gimp-edit-clear dist-text-layer)
  43.     (gimp-edit-clear dist-frame-layer)
  44.     ;; get the text shape
  45.     (gimp-selection-layer-alpha text-layer)
  46.     ;; fill it with the specified color
  47.     (gimp-palette-set-foreground text-color)
  48.     (gimp-edit-fill dist-text-layer FG-IMAGE-FILL)
  49.     ;; get the border shape
  50.     (gimp-selection-border img frame-size)
  51.     (gimp-palette-set-background frame-color)
  52.     (gimp-edit-fill dist-frame-layer BG-IMAGE-FILL)
  53.     (gimp-selection-none img)
  54.     ;; now make the distortion data
  55.     (gimp-palette-set-background '(255 255 255))
  56.     (gimp-edit-fill distortion-layer BG-IMAGE-FILL)
  57.     (plug-in-noisify 1 distortion-img distortion-layer FALSE prob prob prob 0.0)
  58.     (plug-in-gauss-rle 1 distortion-img distortion-layer radius 1 1)
  59.     (plug-in-c-astretch 1 distortion-img distortion-layer)
  60.     (plug-in-gauss-rle 1 distortion-img distortion-layer radius 1 1)
  61.     ;; OK, apply it to dist-text-layer
  62.     (plug-in-displace 1 img dist-text-layer radius radius 1 1
  63.               distortion-layer distortion-layer 0)
  64.     ;; make the distortion data once again fro the frame
  65.     (gimp-edit-fill distortion-layer BG-IMAGE-FILL)
  66.     (plug-in-noisify 1 distortion-img distortion-layer FALSE prob prob prob 0.0)
  67.     (plug-in-gauss-rle 1 distortion-img distortion-layer radius 1 1)
  68.     (plug-in-c-astretch 1 distortion-img distortion-layer)
  69.     (plug-in-gauss-rle 1 distortion-img distortion-layer radius 1 1)
  70.     ;; then, apply it to dist-frame-layer
  71.     (plug-in-displace 1 img dist-frame-layer radius radius 1 1
  72.               distortion-layer distortion-layer 0)
  73.     ;; Finally, clear the bottom layer (text-layer)
  74.     (gimp-selection-all img)
  75.     (gimp-palette-set-background '(255 255 255))
  76.     (gimp-edit-fill text-layer BG-IMAGE-FILL)
  77.     ;; post processing
  78.     (gimp-palette-set-foreground old-fg)
  79.     (gimp-palette-set-background old-bg)
  80.     (gimp-brushes-set-brush old-brush)
  81.     (gimp-brushes-set-paint-mode old-paint-mode)
  82.     (gimp-image-set-active-layer img dist-text-layer)
  83.     (gimp-selection-none img)
  84.     (gimp-image-undo-enable img)
  85.     (gimp-image-delete distortion-img)
  86.     (gimp-display-new img)))
  87.  
  88.  
  89. (script-fu-register "script-fu-i26-gunya2"
  90.             _"<Toolbox>/Xtns/Script-Fu/Logos/Imigre-26..."
  91.             "Two-colored text by hand"
  92.             "Shuji Narazaki"
  93.             "Shuji Narazaki"
  94.             "1997"
  95.             ""
  96.             SF-STRING     _"Text" "The GIMP"
  97.             SF-COLOR      _"Text Color" '(255 0 0)
  98.             SF-COLOR      _"Frame Color" '(0 34 255)
  99.             SF-FONT       _"Font" "-*-Becker-*-r-*-*-24-*-*-*-p-*-*-*"
  100.             SF-ADJUSTMENT _"Font Size (pixels)" '(100 2 1000 1 10 0 1)
  101.             SF-ADJUSTMENT _"Frame Size" '(2 1 20 1 5 0 1))
  102.  
  103. ;;; i26-gunya2.scm ends here
  104.