-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFU_sketch_line-sketch.scm
151 lines (141 loc) · 5.42 KB
/
FU_sketch_line-sketch.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
; FU_sketch_line-sketch.scm
; version 2.8 [gimphelp.org]
; last modified/tested by Paul Sherman
; 02/04/2014 on GIMP-2.8.10
;
; 11/22/2007 - modified by Paul Sherman for GIMP 2.4
; 05/22/2020 - modified for Gimp 2.10.18
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, you can view the GNU General Public
; License version 3 at the web site http://www.gnu.org/licenses/gpl-3.0.html
; Alternatively you can write to the Free Software Foundation, Inc., 675 Mass
; Ave, Cambridge, MA 02139, USA.
;
;==============================================================
;
; Installation:
; This script should be placed in the user or system-wide script folder.
;
; Windows Vista/7/8)
; C:\Program Files\GIMP 2\share\gimp\2.0\scripts
; or
; C:\Users\YOUR-NAME\.gimp-2.8\scripts
;
; Windows XP
; C:\Program Files\GIMP 2\share\gimp\2.0\scripts
; or
; C:\Documents and Settings\yourname\.gimp-2.8\scripts
;
; Linux
; /home/yourname/.gimp-2.8/scripts
;
; Linux system-wide
; /usr/share/gimp/2.0/scripts
;
;==============================================================
;
; LICENSE
;
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;
;==============================================================
; Original information
;
; Line Sketch script by kward1979uk
;==============================================================
(define (set-pt a index x y)
(begin
(aset a (* index 2) x)
(aset a (+ (* index 2) 1) y)
)
)
(define (spline-sketch)
(let* (
(a (cons-array 18 'double)) ; was make-vector
)
(set-pt a 0 0.0 0.0)
(set-pt a 1 0.745098 0.001) ; 0.745098 190 0
(set-pt a 2 0.749019 0.005) ; 0.749019 191 1
(set-pt a 3 0.832 0.832) ; 0.823529 210
(set-pt a 4 0.862 0.862) ; 0.862745 220
(set-pt a 5 0.9019 0.9019) ; 0.901960 230
(set-pt a 6 0.9411 0.9411) ; 0.941176 240
(set-pt a 7 0.9039 0.9039) ; 0.903921 250
(set-pt a 8 1.0000 1.0000) ; 0.999989 255
a
)
)
(define (FU-line-sketch inimage indraw bg-colour)
(let* (
(theImage 0)
(theDraw 0)
(height 1)
(width 0)
(highpass 0)
(imagemask 0)
(copy-paste 0)
(background 0)
)
(set! theImage inimage)
(set! theDraw indraw)
(gimp-image-undo-group-start theImage)
(set! height (car (gimp-drawable-height theDraw)))
(set! width (car (gimp-drawable-width theDraw)))
(plug-in-edge 1 theImage theDraw 2 1 0)
(gimp-drawable-equalize theDraw 0)
(gimp-drawable-desaturate theDraw DESATURATE-LIGHTNESS)
(set! highpass (car (gimp-layer-copy theDraw 1)))
(gimp-image-insert-layer theImage highpass 0 1)
(gimp-drawable-curves-spline highpass 0 18 (spline-sketch))
(gimp-drawable-invert theDraw FALSE)
(gimp-layer-add-alpha theDraw)
(set! imagemask (car (gimp-layer-create-mask theDraw 0)))
(gimp-layer-add-mask theDraw imagemask)
(gimp-edit-copy highpass)
(set! copy-paste (car (gimp-edit-paste imagemask 0)))
(gimp-floating-sel-anchor copy-paste)
(gimp-context-set-background bg-colour)
(set! background (car (gimp-layer-new theImage width height 1 "background" 100 0)))
(gimp-drawable-fill background FILL-BACKGROUND)
(gimp-image-insert-layer theImage background 0 0)
(gimp-image-remove-layer theImage highpass)
(gimp-image-lower-item theImage background)
(gimp-image-undo-group-end theImage)
(gimp-displays-flush)
(gc) ; garbage collection because an array was used
)
)
(script-fu-register "FU-line-sketch"
"<Toolbox>/Script-Fu/Artist/Line Sketch"
"Turns a image into a sketch. If the image is a alpha layer it will be flattened first, background color is selectable. \nfile:FU_sketch_line-sketch.scm"
"Karl Ward"
"Karl Ward"
"Feb 2006"
"RGB*"
SF-IMAGE "SF-IMAGE" 0
SF-DRAWABLE "SF-DRAWABLE" 0
SF-COLOR "Background Colour" '(255 255 255)
)
; end of script