Version 3 of Rolling credits

Updated 2007-01-23 18:15:46 by suchenwi

Richard Suchenwirth 2007-01-23 - Waiting for a lengthy zipping, I hacked up this plaything that simulates credits of a movie, rolling over the screen.

http://mini.net/files/credits.jpg

 package require Tk
 proc titleshow {w title} {
    set -fill black
    set -font {Helvetica 16}
    set x [expr {[winfo width $w]/2}]
    set y [winfo height $w]
    foreach line [split $title \n] {
        set line [string trim $line]
        if [string match -* $line] {
            eval [linsert $line 0 set]
        } else {
            $w create text $x $y -text $line -fill ${-fill} -font ${-font} \
                -justify center -tag title
            incr y 48
        }
    }
    every 40 "if !\[titleshow'roll $w title -2\] return"
 }
 proc titleshow'roll  {w tag dy} {
    $w move $tag 0 $dy
    foreach i [$w find withtag $tag] {
        set y1 [lindex [$w bbox $i] end]
        if {$y1<0} {$w delete $i}
    }
    llength [$w find withtag $tag]
 }
 proc every {ms body} {eval $body; after $ms [info level 0]}

# That's all the code, here's a testing demo:

 pack [canvas .c -bg black]
 tkwait visibility .c

 titleshow .c {
    -fill white
    -font {Helvetica 18 italic}
    Richard Suchenwirth presents
    -font {Helvetica 24 bold}
    -fill yellow
    THE IMPORTANCE
    OF BEING UNEARNEST
    -font {Helvetica 18}
    -fill white
    with
    -font {Helvetica 24}
    -fill yellow
    MARILYN MONROE
    GARY COOPER
    PETER SELLERS

    -font {Helvetica 18}
    Camera     Alphonse de Lumiere
    Gaffer     Joe Smith

    -font {Helvetica 10}
    (c) United Hackers, Inc. MMVII
 }

Category Animation