GIMP Script-fu

Check-in [fd3793f503]
Login

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

Overview
Comment:Update get-layers to support modes 0, 1, and 2.
Timelines: family | ancestors | descendants | both | schemey-fu
Files: files | file ages | folders
SHA1:fd3793f503db38c35de67e085d3b9f5ecc3d8c44
User & Date: saul 2015-05-24 16:29:06
Context
2015-05-26
06:40
Updated docs. Leaf check-in: 1d3eeebbcb user: saul tags: schemey-fu
2015-05-24
16:29
Update get-layers to support modes 0, 1, and 2. check-in: fd3793f503 user: saul tags: schemey-fu
2015-04-05
05:03
Substituted an optimized merge sort, replacing sort. check-in: 3ff6a97002 user: saul tags: schemey-fu
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to schemey-fu.scm.

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
...
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
    (pdb-pass  2 gimp-image-undo-group-end)
    (pdb-pass  2 gimp-image-undo-group-start)
    (pdb-bool  2 gimp-image-undo-is-enabled)
    (pdb-decar 2 gimp-image-undo-thaw)
    (pdb-pass  2 gimp-image-unset-active-channel)
    (pdb-decar 2 gimp-image-width)

    ; get-layers will return just the top-level layers and fundaments
    ; if 'mode' is either #f or omitted altogether (the latter for 
    ; compatibility with the PDB version)
    ; If 'mode' is #t then a nested list of all real layers (no
    ; fundaments) is returned.
    ;
    (define (get-layers image . mode)
      (let ((top-layers (vector->list (cadr (gimp-image-get-layers image)))))
        (if (or (null? mode) (not (car mode)))
          top-layers
          (let loop ((top-layers top-layers)
                     (layers '()))
            (if (null? top-layers)
              (reverse layers)
              (loop (cdr top-layers)
                    (cons (if (zero? (car (gimp-item-is-group (car top-layers))))
                            (car top-layers)
                            (Item::get-children (car top-layers) (car mode)))
                          layers)))))))

    ; Image::get-layers takes an option 'mode' argument (that is not
    ; available with the 'gimp-image-get-layers' procedure).
    ; if 'mode' is either 0 or omitted altogether return just the 
    ;   top-level layers and fundaments
    ; If 'mode' is 1 then a nested list of all real layers (no
    ;   fundaments) is returned.
    ; If 'mode' is 2 then a nested list is returned, where the first
................................................................................
            (if (null? top-layers)
              (reverse layers)
              (loop (cdr top-layers)
                    (cons (if (zero? (car (gimp-item-is-group (car top-layers))))
                            (car top-layers)
                            (if (= (car mode) 2)
                              (cons (car top-layers)
                                    (get-children (car top-layers) (car mode)))
                              (get-children (car top-layers) (car mode))))
                          layers)))))))
    (define (list)
      (vector->list (cadr (gimp-image-list))))
    ))
    
(define Layer
  (make-environment 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
|







207
208
209
210
211
212
213




















214
215
216
217
218
219
220
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
    (pdb-pass  2 gimp-image-undo-group-end)
    (pdb-pass  2 gimp-image-undo-group-start)
    (pdb-bool  2 gimp-image-undo-is-enabled)
    (pdb-decar 2 gimp-image-undo-thaw)
    (pdb-pass  2 gimp-image-unset-active-channel)
    (pdb-decar 2 gimp-image-width)





















    ; Image::get-layers takes an option 'mode' argument (that is not
    ; available with the 'gimp-image-get-layers' procedure).
    ; if 'mode' is either 0 or omitted altogether return just the 
    ;   top-level layers and fundaments
    ; If 'mode' is 1 then a nested list of all real layers (no
    ;   fundaments) is returned.
    ; If 'mode' is 2 then a nested list is returned, where the first
................................................................................
            (if (null? top-layers)
              (reverse layers)
              (loop (cdr top-layers)
                    (cons (if (zero? (car (gimp-item-is-group (car top-layers))))
                            (car top-layers)
                            (if (= (car mode) 2)
                              (cons (car top-layers)
                                    (Item::get-children (car top-layers) (car mode)))
                              (Item::get-children (car top-layers) (car mode))))
                          layers)))))))
    (define (list)
      (vector->list (cadr (gimp-image-list))))
    ))
    
(define Layer
  (make-environment