thumbnail of wtflisp.png
thumbnail of wtflisp.png
wtflisp png
(5.25 KB, 358x195)
 >>/17783/
That thing about editing the layer name to change the frame properties is a blatant hack. This was bothersome for me because I needed to control the timing of frames broadly over dozens of frames and doing so manually was obviously out the question so I wrote some bydlo-level lisp to automate that. Here is simple example: 
(define (-1+ n)
  (- n 1))

(define (rename-all-layers image renamer)
  (let*
    ((res (gimp-image-get-layers image))
     (nlayers (car res))
     (layers (vector->list (cadr res)))
     (loop
       (lambda (total-layers layers)
         (if (> (length layers) 0)
             (let*
               ((layer (car layers))
                (layer-index (-1+ (length layers)))
                (layer-name (renamer layer layer-index total-layers)))
               (begin
                 (display "calling (gimp-item-set-name ")
                 (display layer)
                 (display " ")
                 (display layer-name)
                 (display ")\n")
                 (gimp-item-set-name layer layer-name)
                 (loop total-layers (cdr layers))))
             (display "done\n")))))
    (loop nlayers layers)))

(define (rename-all-frames-with-duration-curve image duration-func)
  (let
    ((frame-renamer
       (lambda (layer index total-layers)
               (string-append "frame "
                              (number->string index)
                              " ("
                              (number->string (duration-func total-layers index))
                              "ms)"))))
    (rename-all-layers image frame-renamer)))

(define (rename-all-frames-with-constant-duration image duration-ms)
  (rename-all-frames-with-duration-curve image (lambda (t i) duration-ms)))

; time(index) = -2*(index-total/2)**2 + max_time
(define (square-timer total-layers layer-index)
  (let ((max-duration 150))
       (trunc (round (+ (* -2 (pow (- layer-index (/ total-layers 2)) 2)) max-duration)))))


Then entering something like: 
(rename-all-frames-with-duration-curve 1 square-timer)


Would rename all layers in image with ID '1' (use '(gimp-image-list)' to list IDs) so that each frame period is determined by a polynomial (the 'square-timer' function). The result in this case would be the frame rate smoothly decreasing at a quadratic rate from start until middle of the animation and then increasing again. to change the timing you change the function (to make it more general one would need to implement some bezier algorithm here)

So that's the memo.