1 ; lay-out-frames - lay out frames of animated gif to make xpenguins theme
2 ; Copyright (C) 2001 Robin Hogan
4 ; This program is free software; you can redistribute it and/or modify
5 ; it under the terms of the GNU General Public License as published by
6 ; the Free Software Foundation; either version 2 of the License, or
7 ; (at your option) any later version.
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU General Public License for more details.
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program; if not, write to the Free Software
16 ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 (define (script-fu-lay-out-frames img
24 (let* ((frameWidth (car (gimp-image-width img)))
25 (frameHeight (car (gimp-image-height img)))
26 (layers (gimp-image-get-layers img))
27 (nFrames (car layers))
28 (frameList (cadr layers))
29 (width (* frameWidth nFrames))
33 (reversedYoffset frameHeight)
36 (gimp-image-undo-disable img)
39 (set! height (* frameHeight 2))
42 (set! normalYoffset frameHeight)
43 (set! reversedYoffset 0)))))
45 (gimp-image-resize img width height 0 0)
47 (while (< frame nFrames)
48 (let* ((currentFrame (aref frameList (- (- nFrames 1) frame)))
49 (offsets (gimp-drawable-offsets currentFrame))
50 (xoffset (car offsets))
51 (yoffset (cadr offsets))
53 (gimp-layer-resize currentFrame
58 (gimp-layer-set-offsets currentFrame
63 (set! newFrame (car (gimp-layer-copy currentFrame TRUE)))
64 (gimp-image-add-layer img newFrame -1)
65 (gimp-layer-set-offsets newFrame
68 (gimp-flip newFrame 0)
70 (set! frame (+ frame 1))))
73 (gimp-image-merge-visible-layers img 0))
75 (gimp-convert-indexed img 2 0 63 0 1 ""))
76 (gimp-image-undo-enable img)
77 (gimp-displays-flush)))
79 (script-fu-register "script-fu-lay-out-frames"
80 _"<Image>/Script-Fu/Utils/Lay out frames..."
81 "Lay out the frames of an animation side by side. This is useful for creating themes for the XPenguins program."
82 "Robin Hogan <R.J.Hogan@reading.ac.uk>"
87 SF-DRAWABLE "Drawable" 0
88 SF-TOGGLE _"Include reversed frames" FALSE
89 SF-TOGGLE _"Swap normal & reversed frames" FALSE
90 SF-TOGGLE _"Merge down frames" FALSE
91 SF-TOGGLE _"Convert to an indexed image" FALSE)