using a variable to increment another variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hello list,

I wrote a script to generate several frames (1000 to 3000) from an image
with four layers. Basically, what the script does is to change the opacity
of some layers, and save the frames.

But I had a problem when I tried to use a variable as the increment of
another variable. Let me explain. The opacity of a layer changes from 0 to
100 in the first 600 frames. The opacity of another layers changes from 0 to
100 from frame 400 to frame 700. So, I tried to make this:

(define (teia-cria-animacao01 image drawable color)
    (let* (
            (nFrame 0)
            (nLayerStep1 0)
            (nLayerStep2 (/ 100 600))
            (nLayerStep3 0)
            (nLayerStep4 0)


            (nOpacityLayer1 0)
            (nOpacityLayer2 00)
            (nOpacityLayer3 0)
            (nOpacityLayer4 0)
        )

        ; loops through the current image, and get the layers, setting the
variables layer1, layer2, layer3, layer 4
        ; (i cut this code, because it works well)

        ; now the problem is: it doesn't change the value of nOpacityLayer2

        (while (< nFrame 1000)

            (set! nOpacityLayer1 (+ nOpacityLayer1 nLayerStep1) )
            (set! nOpacityLayer2 (+ nOpacityLayer2 nLayerStep2) )
            (set! nOpacityLayer3 (+ nOpacityLayer3 nLayerStep3) )
            (set! nOpacityLayer4 (+ nOpacityLayer4 nLayerStep4) )

            (gimp-layer-set-opacity layer1 nOpacityLayer1)
            (gimp-layer-set-opacity layer2 nOpacityLayer2)
            (gimp-layer-set-opacity layer3 nOpacityLayer3)
            (gimp-layer-set-opacity layer4 nOpacityLayer4)

            ; it only changes if I use a number, not a variable, as step.
For example:
            ; (set! nOpacityLayer2 (+ nOpacityLayer2 0.3) )
            ; worked fine.
        )
    )
)


For me, it is important to change the values of nLayerStep, because I can
change them, based on the value of nFrame. So, I can show a layer from frame
500 to the end, changing the value of nLayerStep1 when nFrame = 500.

For now, I am using numbers, but using nLayerStep would make the script more
flexible.


thank you,
andrei


[Non-text portions of this message have been removed]


[Index of Archives]     [Gimp Developers]     [Gimp Users]     [Yosemite News]     [Epson Inkjet Printers]     [Scanners]     [Gimp's Home]     [Steve's Art]

&hbsp; Powered by Linux