home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / chalk.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  4.3 KB  |  130 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 3 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, see <http://www.gnu.org/licenses/>.
  16. ;
  17. ; chalk.scm  version 0.11  10/10/97
  18. ;
  19. ; Copyright (C) 1997 Manish Singh <msingh@uclink4.berkeley.edu>
  20. ;
  21. ; Makes a logo with a chalk-like text effect.
  22.  
  23. (define (apply-chalk-logo-effect img
  24.                                  logo-layer
  25.                                  bg-color)
  26.   (let* (
  27.         (width (car (gimp-drawable-width logo-layer)))
  28.         (height (car (gimp-drawable-height logo-layer)))
  29.         (bg-layer (car (gimp-layer-new img
  30.                                        width height RGB-IMAGE
  31.                                        "Background" 100 NORMAL-MODE)))
  32.         )
  33.  
  34.     (gimp-context-push)
  35.  
  36.     (gimp-selection-none img)
  37.     (script-fu-util-image-resize-from-layer img logo-layer)
  38.     (script-fu-util-image-add-layers img bg-layer)
  39.     (gimp-context-set-background bg-color)
  40.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  41.  
  42.     ; the actual effect
  43.     (gimp-layer-set-lock-alpha logo-layer FALSE)
  44.     (plug-in-gauss-rle RUN-NONINTERACTIVE img logo-layer 2.0 1 1)
  45.     (plug-in-spread RUN-NONINTERACTIVE img logo-layer 5.0 5.0)
  46.     (plug-in-ripple RUN-NONINTERACTIVE img logo-layer 27 2 0 0 0 TRUE TRUE)
  47.     (plug-in-ripple RUN-NONINTERACTIVE img logo-layer 27 2 1 0 0 TRUE TRUE)
  48.     (plug-in-sobel RUN-NONINTERACTIVE img logo-layer TRUE TRUE TRUE)
  49.     (gimp-levels logo-layer 0 0 120 3.5 0 255)
  50.  
  51.     ; work-around for sobel edge detect screw-up (why does this happen?)
  52.     ; the top line of the image has some garbage instead of the bgcolor
  53.     (gimp-rect-select img 0 0 width 1 CHANNEL-OP-ADD FALSE 0)
  54.     (gimp-edit-clear logo-layer)
  55.     (gimp-selection-none img)
  56.  
  57.     (gimp-context-pop)
  58.   )
  59. )
  60.  
  61.  
  62. (define (script-fu-chalk-logo-alpha img
  63.                                     logo-layer
  64.                                     bg-color)
  65.   (begin
  66.     (gimp-image-undo-group-start img)
  67.     (apply-chalk-logo-effect img logo-layer bg-color)
  68.     (gimp-image-undo-group-end img)
  69.     (gimp-displays-flush)
  70.   )
  71. )
  72.  
  73. (script-fu-register "script-fu-chalk-logo-alpha"
  74.   _"_Chalk..."
  75.   _"Create a chalk drawing effect for the selected region (or alpha)"
  76.   "Manish Singh <msingh@uclink4.berkeley.edu>"
  77.   "Manish Singh"
  78.   "October 1997"
  79.   "RGBA"
  80.   SF-IMAGE     "Image"            0
  81.   SF-DRAWABLE  "Drawable"         0
  82.   SF-COLOR    _"Background color" "black"
  83. )
  84.  
  85. (script-fu-menu-register "script-fu-chalk-logo-alpha"
  86.                          "<Image>/Filters/Alpha to Logo")
  87.  
  88.  
  89. (define (script-fu-chalk-logo text
  90.                               size
  91.                               font
  92.                               bg-color
  93.                               chalk-color)
  94.   (let* (
  95.         (img (car (gimp-image-new 256 256 RGB)))
  96.         (border (/ size 4))
  97.         (text-layer (car (gimp-text-fontname img -1 0 0 text border TRUE size PIXELS font)))
  98.         )
  99.  
  100.     (gimp-context-push)
  101.  
  102.     (gimp-image-undo-disable img)
  103.     (gimp-context-set-foreground chalk-color)
  104.     (gimp-layer-set-lock-alpha text-layer TRUE)
  105.     (gimp-edit-fill text-layer FOREGROUND-FILL)
  106.     (apply-chalk-logo-effect img text-layer bg-color)
  107.     (gimp-image-undo-enable img)
  108.     (gimp-display-new img)
  109.  
  110.     (gimp-context-pop)
  111.   )
  112. )
  113.  
  114. (script-fu-register "script-fu-chalk-logo"
  115.   _"_Chalk..."
  116.   _"Create a logo resembling chalk scribbled on a blackboard"
  117.   "Manish Singh <msingh@uclink4.berkeley.edu>"
  118.   "Manish Singh"
  119.   "October 1997"
  120.   ""
  121.   SF-STRING     _"Text"               "CHALK"
  122.   SF-ADJUSTMENT _"Font size (pixels)" '(150 2 1000 1 10 0 1)
  123.   SF-FONT       _"Font"               "Cooper"
  124.   SF-COLOR      _"Background color"   "black"
  125.   SF-COLOR      _"Chalk color"        "white"
  126. )
  127.  
  128. (script-fu-menu-register "script-fu-chalk-logo"
  129.                          "<Image>/File/Create/Logos")
  130.