home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 December / maximum-cd-2010-12.iso / DiscContents / gimp-2.6.10-i686-setup-1.exe / {app} / share / gimp / 2.0 / scripts / chalk.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2010-07-08  |  4.5 KB  |  137 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; This program is free software; you can redistribute it and/or modify
  5. ; it under the terms of the GNU General Public License as published by
  6. ; the Free Software Foundation; either version 2 of the License, or
  7. ; (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13. ;
  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. ; chalk.scm  version 0.11  10/10/97
  19. ;
  20. ; Copyright (C) 1997 Manish Singh <msingh@uclink4.berkeley.edu>
  21. ;
  22. ; Makes a logo with a chalk-like text effect.
  23.  
  24. (define (apply-chalk-logo-effect img
  25.                                  logo-layer
  26.                                  bg-color)
  27.   (let* (
  28.         (width (car (gimp-drawable-width logo-layer)))
  29.         (height (car (gimp-drawable-height logo-layer)))
  30.         (bg-layer (car (gimp-layer-new img
  31.                                        width height RGB-IMAGE
  32.                                        "Background" 100 NORMAL-MODE)))
  33.         )
  34.  
  35.     (gimp-context-push)
  36.  
  37.     (gimp-selection-none img)
  38.     (script-fu-util-image-resize-from-layer img logo-layer)
  39.     (script-fu-util-image-add-layers img bg-layer)
  40.     (gimp-context-set-background bg-color)
  41.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  42.  
  43.     ; the actual effect
  44.     (gimp-layer-set-lock-alpha logo-layer FALSE)
  45.     (plug-in-gauss-rle RUN-NONINTERACTIVE img logo-layer 2.0 1 1)
  46.     (plug-in-spread RUN-NONINTERACTIVE img logo-layer 5.0 5.0)
  47.     (plug-in-ripple RUN-NONINTERACTIVE img logo-layer 27 2 0 0 0 TRUE TRUE)
  48.     (plug-in-ripple RUN-NONINTERACTIVE img logo-layer 27 2 1 0 0 TRUE TRUE)
  49.  
  50.     ; sobel doesn't work on a layer with transparency, so merge layers:
  51.     (let ((logo-layer
  52.            (car (gimp-image-merge-down img logo-layer EXPAND-AS-NECESSARY))))
  53.       (plug-in-sobel RUN-NONINTERACTIVE img logo-layer TRUE TRUE TRUE)
  54.       (gimp-levels logo-layer 0 0 120 3.5 0 255)
  55.  
  56.       ; work-around for sobel edge detect screw-up (why does this happen?)
  57.       ; the top line of the image has some garbage instead of the bgcolor
  58.       (gimp-rect-select img 0 0 width 1 CHANNEL-OP-ADD FALSE 0)
  59.       (gimp-edit-clear logo-layer)
  60.       )
  61.  
  62.     (gimp-selection-none img)
  63.  
  64.     (gimp-context-pop)
  65.   )
  66. )
  67.  
  68.  
  69. (define (script-fu-chalk-logo-alpha img
  70.                                     logo-layer
  71.                                     bg-color)
  72.   (begin
  73.     (gimp-image-undo-group-start img)
  74.     (apply-chalk-logo-effect img logo-layer bg-color)
  75.     (gimp-image-undo-group-end img)
  76.     (gimp-displays-flush)
  77.   )
  78. )
  79.  
  80. (script-fu-register "script-fu-chalk-logo-alpha"
  81.   _"_Chalk..."
  82.   _"Create a chalk drawing effect for the selected region (or alpha)"
  83.   "Manish Singh <msingh@uclink4.berkeley.edu>"
  84.   "Manish Singh"
  85.   "October 1997"
  86.   "RGBA"
  87.   SF-IMAGE     "Image"            0
  88.   SF-DRAWABLE  "Drawable"         0
  89.   SF-COLOR    _"Background color" "black"
  90. )
  91.  
  92. (script-fu-menu-register "script-fu-chalk-logo-alpha"
  93.                          "<Image>/Filters/Alpha to Logo")
  94.  
  95.  
  96. (define (script-fu-chalk-logo text
  97.                               size
  98.                               font
  99.                               bg-color
  100.                               chalk-color)
  101.   (let* (
  102.         (img (car (gimp-image-new 256 256 RGB)))
  103.         (border (/ size 4))
  104.         (text-layer (car (gimp-text-fontname img -1 0 0 text border TRUE size PIXELS font)))
  105.         )
  106.  
  107.     (gimp-context-push)
  108.  
  109.     (gimp-image-undo-disable img)
  110.     (gimp-context-set-foreground chalk-color)
  111.     (gimp-layer-set-lock-alpha text-layer TRUE)
  112.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  113.     (apply-chalk-logo-effect img text-layer bg-color)
  114.     (gimp-image-undo-enable img)
  115.     (gimp-display-new img)
  116.  
  117.     (gimp-context-pop)
  118.   )
  119. )
  120.  
  121. (script-fu-register "script-fu-chalk-logo"
  122.   _"_Chalk..."
  123.   _"Create a logo resembling chalk scribbled on a blackboard"
  124.   "Manish Singh <msingh@uclink4.berkeley.edu>"
  125.   "Manish Singh"
  126.   "October 1997"
  127.   ""
  128.   SF-STRING     _"Text"               "CHALK"
  129.   SF-ADJUSTMENT _"Font size (pixels)" '(150 2 1000 1 10 0 1)
  130.   SF-FONT       _"Font"               "Sans"
  131.   SF-COLOR      _"Background color"   "black"
  132.   SF-COLOR      _"Chalk color"        "white"
  133. )
  134.  
  135. (script-fu-menu-register "script-fu-chalk-logo"
  136.                          "<Image>/File/Create/Logos")
  137.