GIMP Script-fu

Check-in [672d94345c]
Login

Check-in [672d94345c]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Update
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 672d94345c2fa9ff192a7ac5587476487e6bcf6a
User & Date: saul 2013-06-22 23:59:02.037
Context
2014-02-18
04:54
Incorporated changes made in sg-channel-blend branch (updated to GIMP 2.8). check-in: 6c5b7e3494 user: saul tags: trunk
2013-06-22
23:59
Update check-in: 672d94345c user: saul tags: trunk
2013-06-21
15:07
Changed menu name. Removed some debug code. Leaf check-in: de389bc36a user: saul tags: LATEST, sg-arrow-stroke-path
03:11
Updated trunk. check-in: 33ef62f4a8 user: saul tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to sg-arrow-stroke-path.scm.
1
2
3
4
5
6
7
8
9
10
11
12
13

14
15
16
17
18
19
20
21
; 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 2 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.

(define (script-fu-sg-arrow-stroke-path image path)
  (define (dot x0 y0 x1 y1)
    (+ (* x0 x1) (* y0 y1)) )

  (let ((drawable (car (gimp-image-get-active-drawable image)))
        (brush (car (gimp-brush-new "temp-brush")))
        (paint-width 0.1)
        (arrow-head #f)
        (arrow-tail #f) )
    (gimp-image-undo-group-start image)
    (gimp-context-push)
    (gimp-context-set-paint-method "gimp-paintbrush")










|


>
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
; 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 2 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.

(define (script-fu-sg-arrow-stroke-path image)
  (define (dot x0 y0 x1 y1)
    (+ (* x0 x1) (* y0 y1)) )
  (let ((path (car (gimp-image-get-active-vectors image)))
        (drawable (car (gimp-image-get-active-drawable image)))
        (brush (car (gimp-brush-new "temp-brush")))
        (paint-width 0.1)
        (arrow-head #f)
        (arrow-tail #f) )
    (gimp-image-undo-group-start image)
    (gimp-context-push)
    (gimp-context-set-paint-method "gimp-paintbrush")
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
        (gimp-edit-stroke-vectors layer path)
        (when arrow-head
          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     8
                                     (cadr arrow-head) )
          (gimp-edit-clear layer)
;          (gimp-edit-fill layer BACKGROUND-FILL)        
          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     6
                                     (car arrow-head) )
          (gimp-edit-fill layer FOREGROUND-FILL) )
        (when arrow-tail
          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     8
                                     (cadr arrow-tail) )
          (gimp-edit-clear layer)
;          (gimp-edit-fill layer BACKGROUND-FILL)        
          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     6
                                     (car arrow-tail) )
          (gimp-edit-fill layer FOREGROUND-FILL) )
        (when (or (= (car (gimp-item-is-layer-mask drawable)) 1)
                  (= (car (gimp-item-is-channel drawable)) 1) )







<











<







129
130
131
132
133
134
135

136
137
138
139
140
141
142
143
144
145
146

147
148
149
150
151
152
153
        (gimp-edit-stroke-vectors layer path)
        (when arrow-head
          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     8
                                     (cadr arrow-head) )
          (gimp-edit-clear layer)

          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     6
                                     (car arrow-head) )
          (gimp-edit-fill layer FOREGROUND-FILL) )
        (when arrow-tail
          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     8
                                     (cadr arrow-tail) )
          (gimp-edit-clear layer)

          (gimp-image-select-polygon image
                                     CHANNEL-OP-REPLACE 
                                     6
                                     (car arrow-tail) )
          (gimp-edit-fill layer FOREGROUND-FILL) )
        (when (or (= (car (gimp-item-is-layer-mask drawable)) 1)
                  (= (car (gimp-item-is-channel drawable)) 1) )
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
    (gimp-brush-delete brush)
    (gimp-image-undo-group-end image)
    (gimp-context-pop)
    (gimp-displays-flush)
    )
  )

(define (script-fu-sg-arrow-stroke-path2 image)
  (script-fu-sg-arrow-stroke-path image (car (gimp-image-get-active-vectors image))) )
    
(script-fu-register "script-fu-sg-arrow-stroke-path"
  "Arrow Stroke"
  "Stroke path with arrowheads on new layer"
  "Saul Goode"
  "Saul Goode"
  "June 2013"
  "*"
  SF-IMAGE    "Image"    0
  SF-VECTORS  "Path"     0
  )

(script-fu-menu-register "script-fu-sg-arrow-stroke-path"
 "<Vectors>"
 )

(script-fu-register "script-fu-sg-arrow-stroke-path2"
  "Arrow Stroke"
  "Stroke path with arrowheads on new layer"
  "Saul Goode"
  "Saul Goode"
  "June 2013"
  "*"
  SF-IMAGE    "Image"    0
  )

(script-fu-menu-register "script-fu-sg-arrow-stroke-path2"
 "<Image>/Filters/Render"
 )

    
    
  







<
<
<

|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








|
|





161
162
163
164
165
166
167



168
169















170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
    (gimp-brush-delete brush)
    (gimp-image-undo-group-end image)
    (gimp-context-pop)
    (gimp-displays-flush)
    )
  )




(script-fu-register "script-fu-sg-arrow-stroke-path"
  "Arrow Stroke Path"















  "Stroke path with arrowheads on new layer"
  "Saul Goode"
  "Saul Goode"
  "June 2013"
  "*"
  SF-IMAGE    "Image"    0
  )

(script-fu-menu-register "script-fu-sg-arrow-stroke-path"
 "<Image>/Edit/Stroke"
 )