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 / title-header.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2004-09-26  |  5.5 KB  |  174 lines

  1. ; The GIMP -- an image manipulation program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ; Bump-mapped title script --- create a bump-mapped title image for web pages
  4. ; Copyright (C) 1997 Federico Mena Quintero
  5. ; federico@nuclecu.unam.mx
  6. ; ************************************************************************
  7. ; Changed on Feb 4, 1999 by Piet van Oostrum <piet@cs.uu.nl>
  8. ; For use with GIMP 1.1.
  9. ;
  10. ; The corresponding parameters have been replaced by an SF-FONT parameter.
  11. ; The call to gimp-palette-set-background has been given a real layer
  12. ; (although it is not used) otherwise gimp 1.1 crashed.
  13. ; ************************************************************************
  14. ; This program is free software; you can redistribute it and/or modify
  15. ; it under the terms of the GNU General Public License as published by
  16. ; the Free Software Foundation; either version 2 of the License, or
  17. ; (at your option) any later version.
  18. ; This program is distributed in the hope that it will be useful,
  19. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. ; GNU General Public License for more details.
  22. ; You should have received a copy of the GNU General Public License
  23. ; along with this program; if not, write to the Free Software
  24. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25.  
  26.  
  27. (define (script-fu-title-header text
  28.                 size
  29.                 fontname
  30.                 gradient-reverse)
  31.   (let* (; Parameters
  32.      
  33.      (padding 8)
  34.      (fade-width 64)
  35.  
  36.      ; Save foreground and background colors
  37.  
  38.      (old-fg-color (car (gimp-palette-get-foreground)))
  39.      (old-bg-color (car (gimp-palette-get-background)))
  40.  
  41.      ; Image 
  42.  
  43.      (img (car (gimp-image-new 256 256 RGB)))
  44.  
  45.      ; Text layer
  46.  
  47.      (text-layer (car (gimp-text-fontname
  48.                img
  49.                -1
  50.                0
  51.                0
  52.                text
  53.                padding
  54.                TRUE
  55.                size
  56.                PIXELS
  57.                fontname)))
  58.      (text-width (car (gimp-drawable-width text-layer)))
  59.      (text-height (car (gimp-drawable-height text-layer)))
  60.  
  61.      ; Sizes
  62.  
  63.      (text-layers-offset (/ text-height 2))
  64.  
  65.      (img-width (+ text-layers-offset text-width fade-width))
  66.      (img-height text-height)
  67.  
  68.      ; Additional layers
  69.      
  70.      (bg-layer (car (gimp-layer-new img img-width img-height RGBA-IMAGE
  71.                     "bg-layer" 100 NORMAL-MODE)))
  72.      (bumpmap-layer (car (gimp-layer-new img
  73.                          text-width
  74.                          text-height
  75.                          RGBA-IMAGE
  76.                          "bumpmap-layer"
  77.                          100
  78.                          NORMAL-MODE)))
  79.      (fore-layer (car (gimp-layer-new img text-width text-height RGBA-IMAGE
  80.                       "fore-layer" 100 NORMAL-MODE))))
  81.  
  82.     ; Create image
  83.  
  84.     (gimp-image-undo-disable img)
  85.     (gimp-image-resize img img-width img-height 0 0)
  86.  
  87.     (gimp-image-add-layer img bg-layer -1)
  88.     (gimp-image-add-layer img bumpmap-layer -1)
  89.     (gimp-image-add-layer img fore-layer -1)
  90. ;    (gimp-image-add-layer img text-layer -1)
  91.     (gimp-image-raise-layer img text-layer)
  92.     (gimp-image-raise-layer img text-layer)
  93.     (gimp-image-raise-layer img text-layer)
  94.     (gimp-layer-set-offsets bg-layer 0 0)
  95.     (gimp-layer-set-offsets text-layer text-layers-offset 0)
  96.     (gimp-layer-set-offsets bumpmap-layer text-layers-offset 0)
  97.     (gimp-layer-set-offsets fore-layer text-layers-offset 0)
  98.  
  99.     ; Create bumpmap layer
  100.  
  101.     (gimp-palette-set-background '(0 0 0))
  102.     (gimp-edit-fill bumpmap-layer BACKGROUND-FILL)
  103.     (gimp-selection-layer-alpha text-layer)
  104.     (gimp-palette-set-background '(255 255 255))
  105.     (gimp-edit-fill bumpmap-layer BACKGROUND-FILL)
  106.     (gimp-selection-none img)
  107.     (plug-in-gauss-rle 1 img bumpmap-layer 4.0 TRUE TRUE)
  108.  
  109.     ; Fore layer, bumpmap
  110.  
  111.     (gimp-palette-set-background '(255 255 255))
  112.     (gimp-edit-fill fore-layer BACKGROUND-FILL)
  113.     (plug-in-bump-map 1 img fore-layer bumpmap-layer 135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
  114.  
  115.     ; Text layer
  116.  
  117.     (gimp-drawable-set-visible text-layer TRUE)
  118.     (gimp-layer-set-preserve-trans text-layer TRUE)
  119.  
  120.     (gimp-edit-blend text-layer CUSTOM-MODE NORMAL-MODE
  121.              GRADIENT-LINEAR 100 0 REPEAT-NONE gradient-reverse
  122.              FALSE 0.2 3 TRUE
  123.              padding padding
  124.              (- text-width padding 1) (- text-height padding 1))
  125.  
  126.     ; Semicircle at the left
  127.  
  128.     (gimp-palette-set-background '(0 0 0))
  129.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  130.  
  131.     (gimp-ellipse-select img 0 0 text-height text-height CHANNEL-OP-REPLACE TRUE FALSE 0)
  132.     (gimp-palette-set-background (car (gimp-image-pick-color img text-layer
  133.                                  text-layers-offset 0
  134.                                  TRUE FALSE 0)))
  135.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  136.  
  137.     ; Fade-out gradient at the right
  138.  
  139.     (gimp-rect-select img (- img-width fade-width) 0 fade-width text-height
  140.               CHANNEL-OP-REPLACE FALSE 0)
  141.     (gimp-palette-set-foreground (car (gimp-palette-get-background)))
  142.     (gimp-palette-set-background '(0 0 0))
  143.  
  144.     (gimp-edit-blend bg-layer FG-BG-RGB-MODE NORMAL-MODE
  145.              GRADIENT-LINEAR 100 0 REPEAT-NONE FALSE
  146.              FALSE 0.2 3 TRUE
  147.              (- img-width fade-width) 0 (- img-width 1) 0)
  148.  
  149.     (gimp-selection-none img)
  150.  
  151.     ; Done
  152.     
  153. ;    (gimp-image-flatten img)
  154.     (gimp-palette-set-foreground old-fg-color)
  155.     (gimp-palette-set-background old-bg-color)
  156.     (gimp-image-undo-enable img)
  157.     (gimp-display-new img)))
  158.  
  159. (script-fu-register "script-fu-title-header"
  160.             _"<Toolbox>/Xtns/Script-Fu/Logos/Web Title Header..."
  161.             "Web title header"
  162.             "Federico Mena Quintero"
  163.             "Federico Mena Quintero"
  164.             "June 1997"
  165.             ""
  166.             SF-STRING     _"Text"               "Hello world!"
  167.             SF-ADJUSTMENT _"Font Size (pixels)" '(32 2 256 1 10 0 0)
  168.             SF-FONT       _"Font"               "Sans"
  169.             SF-TOGGLE     _"Gradient Reverse"   FALSE)
  170.