image effects with tcl commands

2014-06-16
2014-06-18
  • Natanael Mojica

    Natanael Mojica - 2014-06-16

    Hi Peter

    I attached two ini files
    in the Imagenes1 ini, I created effects for 6 images using the snowmix commands like: image place move alpha, coordination, scale, (write too much) the idea is to make transitions between the 6 different images.
    to reduce the number of commands to write, I decided to make these same transitions between images using the tcl interpreter, and That are in the ini file imagenes, for example:

    using snowmix commands :

    image place alpha 1 1
    next 200
    image place move alpha 1 -0.05 40
    next 40
    image place alpha 2 1
    next 200
    image place move alpha 2 -0.05 40
    next 40
    image place alpha 3 1
    next 200
    image place move alpha 3 -0.05 40
    next 40
    image place alpha 4 1
    next 200
    image place move alpha 4 -0.05 40
    next 40
    image place alpha 5 1
    next 200
    image place move alpha 5 -0.05 40
    next 40
    image place alpha 6 1
    next 200
    image place move alpha 6 -0.05 40
    next 40
    image place alpha 1 0
    image place move alpha 1 0.05 40
    next 40

    then, to the same effect using tcl:

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    command create Animacion1.tcl
    proc Fade { iid1 iid2 steps } {
    #set s ""
    if {$iid1 > $iid2 || steps ==0} return error
    set delta [expr 1.000000 / $steps]
    if {$steps < 0} { set steps [expr -$steps] }
    while {$iid1 <= $iid2} {
    append s " image place move alpha $iid1 $delta $steps\n"
    append s " next 200\n"
    incr iid1
    }
    return "\n$s\n"
    }
    command end
    tcl exec Animacion1.tcl

    for run the command above i use:
    

    command create fade
    tcl eval Fade 1 6 -40
    loop
    command end

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    but that seems not to work, what thing I'm doing wrong?

     
    Last edit: Natanael Mojica 2014-06-16
    • Peter Maersk-Moller

      Hi Natanael.

      I'll look into it. However, one thing worth noting is your use of the next command.

      The command next only works when used in a command macro. When you call a command macro and the it gets executed, then when execution meet a next, the execution of that command macro is supspended at the pointer for where in the command macro the suspension took place is saved. Then the next time the macro is called, the execution starts where the execution was suspended.

      When you return the commands from the tcl procedure Fade, you return something like this:

      image place move alpha 1 -0.05 40
      next 200
      

      Then the first line is executed reducing the alpha value for the image over the next 40 frames automatically. However the next line has no effect as the command next is not available outside a command macro.

      As I understand it, you want an image to be shown for 200 frames, then the image fades over the next 40 frames. Then after the image has faded, you show a new image for 200 frames, then fades it over the next 40 frames etc.

      There are many ways to do that. One solution is to use the after command:

      after +8 image place move alpha 1 -0.05 40
      

      This will after 8 seconds, 200 frames at 25fps is 8 seconds, execute the command to fade the image.

      Will look into a tcl script for you later.

      P

       
  • Natanael Mojica

    Natanael Mojica - 2014-06-18

    thanks Peter

    another question, Snowmix and tcl communicate using only the command macro?. tcl return a string, which is usually a command macro (I see your examples saphire-digitalmeter, radar), are there other ways for communicate betwen snowmix and tcl?

    well, about the script I try to write anoher script for solve the problem, thanks

    Natanael

     
    • Peter Maersk-Moller

      Hi Natanael.

      Currently the string returned from the tcl interpreter is executed by the snowmix command parser if the string is prepended with a newline. So the methods now are these:

      tcl eval SOMETHING
      

      to send data into the interpreter and

      return "\ntext string 1 This is a text string\n"
      

      to send commands back to snowmix.

      The next version will have communication built-in directly with the following commands to use in the tcl interpreter:

      set a [snowmix info text string 1]
      

      to fetch settings information and

      snowmix parse "set text string 1 This is a string"
      

      For your slideshow: Yes I think this is a script you can write yourself. If you get stuck, drop a message here. There are many ways to to it

      A flexible way would be a function that gets called at framerate. The you build a state machine with counters and settings for the state machine to start, stop, fade in, fade out, change image and add image to the list of images to be shown.

      best regards

      Peter MM

       


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks