Tuesday, 23 October 2012

Fading text

The following code is an example of fading text, push next to see the next effect:

    Title: "Fade Presentation"
    Date: 20-May-2000
    Purpose: "Demonstrate fade effects"
    File: %fadetext.r
    Author: "Jeff"
    library: [
        level: 'advanced
        platform: none
        type: none
        domain: 'GUI
        tested-under: none
        support: none
        license: none
        see-also: none
random/seed now
ptext: parse form next first system/words none
incr: func [/tup /templ /inc] [
    tup: 10.10.10 + random 255.255.255
    tmp: copy []
    inc: reduce [(to-integer tup/1 / 10) (to-integer tup/2 / 10) (to-integer tup/3 / 10)]  
    reduce [tup inc]
one-way: func [c end inc][
    make face/feel [
        engage: func [f a e] compose/deep [
            all [   a = 'time (to-set-path c/1) (c/1) (inc)
                (end) = (c/1) f/rate: 0
                ] show f
set [sc inc] incr
r-vect: does [2x2 - random 3x3]
gm:   does [compose [gradmul (r-vect) (white) (black)]]
bgc: does [one-way [f/color] sc compose [+ (inc)]]
tgc: does [one-way [f/font/color] black compose [- (inc)]]
view layout [
    bg: backdrop 0.0.0 with [rate: 10 feel: bgc effect: gm]
    tt: text (ptext/1) 120x30 (sc) with [font: [size: 18] rate: 10 feel: tgc effect: [key 0.0.0]]
    button "Next" [
        tt/text: first either tail? ptext: next ptext [ptest: head ptext][ptext] bg/effect: gm set [sc inc] incr
        bg/color: black tt/font/color: sc bg/feel: bgc
        tt/rate: bg/rate: 10 show reduce [bg tt]

No comments:

Post a Comment