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

  1. ;  BLENDED-DROP-SHADOW-LOGO
  2. ;  draw the specified text over a blended background using current gimp fg
  3. ;   and bg colors.  The finished blend has a drop shadow underneath that blends
  4. ;   to the specified bg-color
  5. ;  if the blend colors are specified as high intensity, the sharp option
  6. ;   should be enabled or the logo will come out blurry
  7.  
  8. (define (scale size percent) (* size percent))
  9.  
  10. (define (apply-textured-logo-effect img
  11.                     logo-layer
  12.                     b-size
  13.                     text-pattern
  14.                     tile-type
  15.                     bg-color
  16.                     blend-fg
  17.                     blend-bg)
  18.   (let* ((b-size-2 (scale b-size 0.5))
  19.      (f-size (scale b-size 0.75))
  20.      (ds-size (scale b-size 0.5))
  21.      (ts-size (- b-size-2 3))
  22.      (width (car (gimp-drawable-width logo-layer)))
  23.      (height (car (gimp-drawable-height logo-layer)))
  24.      (blend-layer (car (gimp-layer-new img width height RGBA_IMAGE "Blend" 100 NORMAL)))
  25.      (shadow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Shadow" 100 NORMAL)))
  26.      (text-shadow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Text Shadow" 100 MULTIPLY)))
  27.      (tsl-layer-mask (car (gimp-layer-create-mask text-shadow-layer BLACK-MASK)))
  28.      (drop-shadow-layer (car (gimp-layer-new img width height RGBA_IMAGE "Drop Shadow" 100 MULTIPLY)))
  29.      (dsl-layer-mask (car (gimp-layer-create-mask drop-shadow-layer BLACK-MASK)))
  30.      (old-fg (car (gimp-palette-get-foreground)))
  31.      (old-bg (car (gimp-palette-get-background)))
  32.      (old-pattern (car (gimp-patterns-get-pattern))))    
  33.     (gimp-image-resize img width height 0 0)
  34.     (gimp-image-add-layer img shadow-layer 1)
  35.     (gimp-image-add-layer img blend-layer 1)
  36.     (gimp-image-add-layer img drop-shadow-layer 1)
  37.     (gimp-image-add-layer img text-shadow-layer 0)
  38.     (gimp-selection-all img)
  39.     (gimp-patterns-set-pattern text-pattern)
  40.     (gimp-layer-set-preserve-trans logo-layer TRUE)
  41.     (gimp-bucket-fill logo-layer PATTERN-BUCKET-FILL NORMAL 100 0 FALSE 0 0)
  42.     (gimp-selection-none img)
  43.     (gimp-edit-clear text-shadow-layer)
  44.     (gimp-edit-clear drop-shadow-layer)
  45.     (gimp-palette-set-background bg-color)
  46.     (gimp-drawable-fill shadow-layer BG-IMAGE-FILL)
  47.     (gimp-rect-select img b-size-2 b-size-2 (- width b-size) (- height b-size) REPLACE TRUE b-size-2)
  48.     (gimp-palette-set-background '(0 0 0))
  49.     (gimp-edit-fill shadow-layer BG-IMAGE-FILL)
  50.     (gimp-selection-layer-alpha logo-layer)
  51.     (gimp-image-add-layer-mask img text-shadow-layer tsl-layer-mask)
  52.     (gimp-palette-set-background '(255 255 255))
  53.     (gimp-edit-fill tsl-layer-mask BG-IMAGE-FILL)
  54.     (gimp-selection-feather img f-size)
  55.     (gimp-palette-set-background '(63 63 63))
  56.     (gimp-edit-fill drop-shadow-layer BG-IMAGE-FILL)
  57.     (gimp-palette-set-background '(0 0 0))
  58.     (gimp-edit-fill text-shadow-layer BG-IMAGE-FILL)
  59.     (gimp-palette-set-foreground '(255 255 255))
  60.     (gimp-blend text-shadow-layer FG-BG-RGB NORMAL SHAPEBURST-ANGULAR 100 0 REPEAT-NONE FALSE 0 0 0 0 1 1)
  61.     (gimp-selection-none img)
  62.     (gimp-palette-set-foreground blend-fg)
  63.     (gimp-palette-set-background blend-bg)
  64.     (gimp-blend blend-layer FG-BG-RGB NORMAL LINEAR 100 0 REPEAT-NONE FALSE 0 0 0 0 width 0)
  65.     (plug-in-mosaic 1 img blend-layer 12 1 1 0.7 135 0.2 TRUE FALSE tile-type 1 0)
  66.     (gimp-layer-translate logo-layer (- b-size-2) (- b-size-2))
  67.     (gimp-layer-translate blend-layer (- b-size) (- b-size))
  68.     (gimp-layer-translate text-shadow-layer (- ts-size) (- ts-size))
  69.     (gimp-layer-translate drop-shadow-layer ds-size ds-size)
  70.     (gimp-selection-layer-alpha blend-layer)
  71.     (gimp-image-add-layer-mask img drop-shadow-layer dsl-layer-mask)
  72.     (gimp-palette-set-background '(255 255 255))
  73.     (gimp-edit-fill dsl-layer-mask BG-IMAGE-FILL)
  74.     (gimp-image-remove-layer-mask img drop-shadow-layer APPLY)
  75.     (gimp-selection-none img)
  76.     (gimp-patterns-set-pattern old-pattern)
  77.     (gimp-palette-set-foreground old-fg)
  78.     (gimp-palette-set-background old-bg)))
  79.  
  80. (define (script-fu-textured-logo-alpha img
  81.                        logo-layer
  82.                        b-size
  83.                        text-pattern
  84.                        tile-type
  85.                        bg-color
  86.                        blend-fg
  87.                        blend-bg)
  88.   (begin
  89.     (gimp-undo-push-group-start img)
  90.     (apply-textured-logo-effect img logo-layer b-size text-pattern tile-type
  91.                 bg-color blend-fg blend-bg)
  92.     (gimp-undo-push-group-end img)
  93.     (gimp-displays-flush)))
  94.  
  95. (script-fu-register "script-fu-textured-logo-alpha"
  96.             _"<Image>/Script-Fu/Alpha to Logo/Textured..."
  97.             "Creates textured logos with blended backgrounds, highlights, and shadows"
  98.             "Spencer Kimball"
  99.             "Spencer Kimball"
  100.             "1996"
  101.             "RGBA"
  102.                     SF-IMAGE      "Image" 0
  103.                     SF-DRAWABLE   "Drawable" 0
  104.             SF-ADJUSTMENT _"Border Size (pixels)" '(20 1 100 1 10 0 1)
  105.             SF-PATTERN    _"Pattern" "Fibers"
  106.             SF-OPTION     _"Mosaic Tile Type" '(_"Squares" "Hexagons" "Octagons")
  107.             SF-COLOR      _"Background Color" '(255 255 255)
  108.             SF-COLOR      _"Starting Blend" '(32 106 0)
  109.             SF-COLOR      _"Ending Blend" '(0 0 106)
  110.             )
  111.  
  112. (define (script-fu-textured-logo text
  113.                  size
  114.                  fontname
  115.                  text-pattern
  116.                  tile-type
  117.                  bg-color
  118.                  blend-fg
  119.                  blend-bg)
  120.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  121.      (b-size (scale size 0.1))
  122.      (text-layer (car (gimp-text-fontname img -1 0 0 text b-size TRUE size PIXELS fontname))))
  123.     (gimp-image-undo-disable img)
  124.     (gimp-layer-set-name text-layer text)
  125.     (apply-textured-logo-effect img text-layer b-size text-pattern tile-type
  126.                 bg-color blend-fg blend-bg)
  127.     (gimp-image-undo-enable img)
  128.     (gimp-display-new img)))
  129.  
  130. (script-fu-register "script-fu-textured-logo"
  131.             _"<Toolbox>/Xtns/Script-Fu/Logos/Textured..."
  132.             "Creates textured logos with blended backgrounds, highlights, and shadows"
  133.             "Spencer Kimball"
  134.             "Spencer Kimball"
  135.             "1996"
  136.             ""
  137.             SF-STRING     _"Text" "The GIMP"
  138.             SF-ADJUSTMENT _"Font Size (pixels)" '(200 1 1000 1 10 0 1)
  139.             SF-FONT       _"Font" "-*-cuneifontlight-*-r-*-*-24-*-*-*-p-*-*-*"
  140.             SF-PATTERN    _"Text Pattern" "Fibers"
  141.             SF-OPTION     _"Mosaic Tile Type" '(_"Squares" "Hexagons" "Octagons")
  142.             SF-COLOR      _"Background Color" '(255 255 255)
  143.             SF-COLOR      _"Starting Blend" '(32 106 0)
  144.             SF-COLOR      _"Ending Blend" '(0 0 106)
  145.             )
  146.