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 / circuit.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  5.2 KB  |  158 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Circuit board effect
  5. ; Copyright (c) 1997 Adrian Likins
  6. ; aklikins@eos.ncsu.ed
  7. ;
  8. ;  Genrates what looks a little like the back of an old circuit board.
  9. ;  Looks even better when gradmapped with a suitable gradient.
  10. ;
  11. ; This script doesnt handle or color combos well. ie, black/black
  12. ;  doesnt work..
  13. ;  The effect seems to work best on odd shaped selections because of some
  14. ; limitations in the maze codes selection handling ablity
  15. ;
  16. ;
  17. ; This program is free software: you can redistribute it and/or modify
  18. ; it under the terms of the GNU General Public License as published by
  19. ; the Free Software Foundation; either version 3 of the License, or
  20. ; (at your option) any later version.
  21. ;
  22. ; This program is distributed in the hope that it will be useful,
  23. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25. ; GNU General Public License for more details.
  26. ;
  27. ; You should have received a copy of the GNU General Public License
  28. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  29.  
  30.  
  31. (define (script-fu-circuit image
  32.                            drawable
  33.                            mask-size
  34.                            seed
  35.                            remove-bg
  36.                            keep-selection
  37.                            separate-layer)
  38.   (let* (
  39.         (type (car (gimp-drawable-type-with-alpha drawable)))
  40.         (image-width (car (gimp-image-width image)))
  41.         (image-height (car (gimp-image-height image)))
  42.         (active-selection 0)
  43.         (from-selection 0)
  44.         (selection-bounds 0)
  45.         (select-offset-x 0)
  46.         (select-offset-y 0)
  47.         (select-width 0)
  48.         (select-height 0)
  49.         (effect-layer 0)
  50.         (active-layer 0)
  51.         )
  52.  
  53.     (gimp-context-push)
  54.  
  55.     (gimp-image-undo-group-start image)
  56.  
  57.     (gimp-layer-add-alpha drawable)
  58.  
  59.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  60.         (begin
  61.           (gimp-selection-layer-alpha drawable)
  62.           (set! active-selection (car (gimp-selection-save image)))
  63.           (set! from-selection FALSE))
  64.         (begin
  65.           (set! from-selection TRUE)
  66.           (set! active-selection (car (gimp-selection-save image)))))
  67.  
  68.     (set! selection-bounds (gimp-selection-bounds image))
  69.     (set! select-offset-x (cadr selection-bounds))
  70.     (set! select-offset-y (caddr selection-bounds))
  71.     (set! select-width (- (cadr (cddr selection-bounds)) select-offset-x))
  72.     (set! select-height (- (caddr (cddr selection-bounds)) select-offset-y))
  73.  
  74.     (if (= separate-layer TRUE)
  75.         (begin
  76.           (set! effect-layer (car (gimp-layer-new image
  77.                                                   select-width
  78.                                                   select-height
  79.                                                   type
  80.                                                   "effect layer"
  81.                                                   100
  82.                                                   NORMAL-MODE)))
  83.  
  84.           (gimp-image-add-layer image effect-layer -1)
  85.           (gimp-layer-set-offsets effect-layer select-offset-x select-offset-y)
  86.           (gimp-selection-none image)
  87.           (gimp-edit-clear effect-layer)
  88.           (gimp-selection-load active-selection)
  89.           (gimp-edit-copy drawable)
  90.  
  91.           (let ((floating-sel (car (gimp-edit-paste effect-layer FALSE))))
  92.             (gimp-floating-sel-anchor floating-sel)
  93.             )
  94.           (gimp-image-set-active-layer image effect-layer ))
  95.           (set! effect-layer drawable)
  96.     )
  97.     (set! active-layer effect-layer)
  98.  
  99.     (if (= remove-bg TRUE)
  100.         (gimp-context-set-foreground '(0 0 0))
  101.         (gimp-context-set-foreground '(14 14 14))
  102.     )
  103.  
  104.     (gimp-selection-load active-selection)
  105.     (plug-in-maze RUN-NONINTERACTIVE image active-layer 5 5 TRUE 0 seed 57 1)
  106.     (plug-in-oilify RUN-NONINTERACTIVE image active-layer mask-size 0)
  107.     (plug-in-edge RUN-NONINTERACTIVE image active-layer 2 1 0)
  108.     (if (= type RGBA-IMAGE)
  109.       (gimp-desaturate active-layer))
  110.  
  111.     (if (and
  112.          (= remove-bg TRUE)
  113.          (= separate-layer TRUE))
  114.         (begin
  115.           (gimp-by-color-select
  116.            active-layer
  117.            '(0 0 0)
  118.            15
  119.            2
  120.            TRUE
  121.            FALSE
  122.            10
  123.            FALSE)
  124.           (gimp-edit-clear active-layer)))
  125.  
  126.     (if (= keep-selection FALSE)
  127.         (gimp-selection-none image))
  128.  
  129.     (gimp-image-remove-channel image active-selection)
  130.     (gimp-image-set-active-layer image drawable)
  131.  
  132.     (gimp-image-undo-group-end image)
  133.  
  134.     (gimp-displays-flush)
  135.  
  136.     (gimp-context-pop)
  137.   )
  138. )
  139.  
  140. (script-fu-register "script-fu-circuit"
  141.   _"_Circuit..."
  142.   _"Fill the selected region (or alpha) with traces like those on a circuit board"
  143.   "Adrian Likins <adrian@gimp.org>"
  144.   "Adrian Likins"
  145.   "10/17/97"
  146.   "RGB* GRAY*"
  147.   SF-IMAGE      "Image"             0
  148.   SF-DRAWABLE   "Drawable"          0
  149.   SF-ADJUSTMENT _"Oilify mask size" '(17 3 50 1 10 0 1)
  150.   SF-ADJUSTMENT _"Circuit seed"     '(3 1 3000000 1 10 0 1)
  151.   SF-TOGGLE     _"No background (only for separate layer)" FALSE
  152.   SF-TOGGLE     _"Keep selection"   TRUE
  153.   SF-TOGGLE     _"Separate layer"   TRUE
  154. )
  155.  
  156. (script-fu-menu-register "script-fu-circuit"
  157.                          "<Image>/Filters/Render")
  158.