|
| 1 | +; FU_sketch_sketch-drawing.scm |
| 2 | +; version 2.9 [gimphelp.org] |
| 3 | +; last modified/tested by Paul Sherman |
| 4 | +; 02/15/2014 on GIMP-2.8.10 |
| 5 | +; |
| 6 | +; 02/15/2014 - accommodated indexed images, option tyo flatten upon completion |
| 7 | +; (and made flatten default) |
| 8 | +;============================================================== |
| 9 | +; |
| 10 | +; Installation: |
| 11 | +; This script should be placed in the user or system-wide script folder. |
| 12 | +; |
| 13 | +; Windows Vista/7/8) |
| 14 | +; C:\Program Files\GIMP 2\share\gimp\2.0\scripts |
| 15 | +; or |
| 16 | +; C:\Users\YOUR-NAME\.gimp-2.8\scripts |
| 17 | +; |
| 18 | +; Windows XP |
| 19 | +; C:\Program Files\GIMP 2\share\gimp\2.0\scripts |
| 20 | +; or |
| 21 | +; C:\Documents and Settings\yourname\.gimp-2.8\scripts |
| 22 | +; |
| 23 | +; Linux |
| 24 | +; /home/yourname/.gimp-2.8/scripts |
| 25 | +; or |
| 26 | +; Linux system-wide |
| 27 | +; /usr/share/gimp/2.0/scripts |
| 28 | +; |
| 29 | +;============================================================== |
| 30 | +; |
| 31 | +; LICENSE |
| 32 | +; |
| 33 | +; This program is free software: you can redistribute it and/or modify |
| 34 | +; it under the terms of the GNU General Public License as published by |
| 35 | +; the Free Software Foundation, either version 3 of the License, or |
| 36 | +; (at your option) any later version. |
| 37 | +; |
| 38 | +; This program is distributed in the hope that it will be useful, |
| 39 | +; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 40 | +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 41 | +; GNU General Public License for more details. |
| 42 | +; |
| 43 | +; You should have received a copy of the GNU General Public License |
| 44 | +; along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 45 | +; |
| 46 | +;============================================================== |
| 47 | +; Original information |
| 48 | +; |
| 49 | +; Drawing script for GIMP 2.2 |
| 50 | +; Copyright (C) 2007 Eddy Verlinden <[email protected]> |
| 51 | +;============================================================== |
| 52 | + |
| 53 | + |
| 54 | +(define (FU-sketch-drawing |
| 55 | + img |
| 56 | + drawable |
| 57 | + thickness |
| 58 | + inFlatten |
| 59 | + ) |
| 60 | + |
| 61 | + (gimp-image-undo-group-start img) |
| 62 | + (define indexed (car (gimp-drawable-is-indexed drawable))) |
| 63 | + (if (= indexed TRUE)(gimp-image-convert-rgb img)) |
| 64 | + |
| 65 | + (let* ( |
| 66 | + (width (car (gimp-drawable-width drawable))) |
| 67 | + (height (car (gimp-drawable-height drawable))) |
| 68 | + (old-selection (car (gimp-selection-save img))) |
| 69 | + (thf (* height 0.005 thickness )) |
| 70 | + (image-type (car (gimp-image-base-type img))) |
| 71 | + (layer-type (car (gimp-drawable-type drawable))) |
| 72 | + (layer-temp1 (car (gimp-layer-new img width height layer-type "temp1" 100 NORMAL-MODE))) |
| 73 | + (layer-temp2 (car (gimp-layer-new img width height layer-type "temp2" 100 NORMAL-MODE))) |
| 74 | + ) |
| 75 | + |
| 76 | + (if (eqv? (car (gimp-selection-is-empty img)) TRUE) |
| 77 | + (gimp-drawable-fill old-selection FILL-WHITE)) ; so Empty and All are the same. |
| 78 | + (gimp-selection-none img) |
| 79 | + (gimp-image-insert-layer img layer-temp1 0 -1) |
| 80 | + (gimp-image-insert-layer img layer-temp2 0 -1) |
| 81 | + (gimp-edit-copy drawable) |
| 82 | + (gimp-floating-sel-anchor (car (gimp-edit-paste layer-temp1 0))) |
| 83 | + |
| 84 | + (if (eqv? (car (gimp-drawable-is-gray drawable)) FALSE) |
| 85 | + (gimp-desaturate layer-temp1)) |
| 86 | + (gimp-edit-copy layer-temp1) |
| 87 | + (gimp-floating-sel-anchor (car (gimp-edit-paste layer-temp2 0))) |
| 88 | + (gimp-invert layer-temp2) |
| 89 | + (plug-in-gauss 1 img layer-temp2 thf thf 0) |
| 90 | + (gimp-layer-set-mode layer-temp2 16) |
| 91 | + (gimp-image-merge-down img layer-temp2 0) |
| 92 | + (set! layer-temp1 (car (gimp-image-get-active-layer img))) |
| 93 | + (gimp-levels layer-temp1 0 215 235 1.0 0 255) |
| 94 | + |
| 95 | + (gimp-image-select-item img CHANNEL-OP-REPLACE old-selection) |
| 96 | + (gimp-selection-invert img) |
| 97 | + (if (eqv? (car (gimp-selection-is-empty img)) FALSE) ; both Empty and All are denied |
| 98 | + (begin |
| 99 | + (gimp-edit-clear layer-temp1) |
| 100 | + )) |
| 101 | + |
| 102 | + (gimp-item-set-name layer-temp1 "Drawing") |
| 103 | + (gimp-image-select-item img CHANNEL-OP-REPLACE old-selection) |
| 104 | + (gimp-image-remove-channel img old-selection) |
| 105 | + |
| 106 | + (if (= inFlatten TRUE)(gimp-image-flatten img)) |
| 107 | + (gimp-image-undo-group-end img) |
| 108 | + (gimp-displays-flush) |
| 109 | + ) |
| 110 | +) |
| 111 | + |
| 112 | +(script-fu-register |
| 113 | + "FU-sketch-drawing" |
| 114 | + "<Image>/Script-Fu/Artist/Sketch Drawing 2" |
| 115 | + "Creates a drawing.\n\nThis version lets you adjust the line thickness." |
| 116 | + "Eddy Verlinden <[email protected]>" |
| 117 | + "Eddy Verlinden" |
| 118 | + "2007, juli" |
| 119 | + "*" |
| 120 | + SF-IMAGE "Image" 0 |
| 121 | + SF-DRAWABLE "Drawable" 0 |
| 122 | + SF-ADJUSTMENT "thickness" '(2 1 5 1 1 0 0) |
| 123 | + SF-TOGGLE "Flatten image when complete?" TRUE |
| 124 | +) |
0 commit comments