REBOL

 

Splash Banner - Source Code

Animated banner ad example.
Author: Carl Sassenrath
File size: 3K
Return to index

 

REBOL [Title: "REBOL/View 1.2 Splash" Version: 1.0.1]

wh: 7x10
win-size: logo.gif/size + 4x4 * wh

l: center-face layout [
    size win-size
    backcolor white
    at win-size - logo.gif/size / 2 - 0x40
    l1: image logo.gif
    pad logo.gif/size/x / 2 - 150 * 1x0
    space 0x6
    t1: h2 300 center "Lightweight Distributed Computing"
    b1: box 300x2 maroon
    t3: h3 300 center "From REBOL Technologies"
    t4: h3 300 center "WWW.REBOL.COM" [browse http://www.rebol.com]
]

clear find l/pane b1

make-logo: has [f] [
    f: make face [
        clr: random white
        size: logo.gif/size + 4x4
        offset: (random wh) - 1x1 * size
        image: logo.gif
        effect: reduce ['colorize clr]
        edge: make edge [color: clr]
        font: para: none
    ]
]

l2: l1/offset/y
t2: t1/offset/y
l1/offset/y: t1/offset/y: win-size/y

actions: [
    [   ; fly on
        if all [frame > 6 l1/offset/y > l2] [l1/offset/y: max l2 l1/offset/y - 16]
        if all [frame > 16 t1/offset/y > t2] [t1/offset/y: max t2 t1/offset/y - 16]
        t1/offset/y > t2
    ]
    [frame < 10]
    [   ; accelerated splatter
        loop frame [append l/pane make-logo]
        frame < 28
    ]
    [   ; setup for wipe
        l/image: to-image l 
        clear l/pane
        recycle
        l/effect: [grayscale]
        show l  ; <-- Bug: This extra show is required, or to-image does work.
        img: to-image l
        l/effect: none
        append l/pane f: make face [
            size: win-size * 0x1
            image: img
            edge: font: para: none
        ]
        false
    ][  ; wipe to grayscale
        (f/size/x: frame * 50) < win-size/x
    ][  ; setup for wipe
        f/size: 0x0
        l/image: img
        l/effect: [emboss]
        show l  ; <-- Bug!
        f/image: to-image l
        l/effect: none
        f/size: win-size * 1x0
        false
    ][  ; wipe to emboss
        (f/size/y: frame * 16) < win-size/y
    ][  ; setup for fade
        f/size: 0x0
        l/image: f/image
        l1/offset/y: t1/offset/y: win-size/y
        repend clear l/pane [l1 t1]
        false
    ][  ; fade to white, fly on again
        l/effect: reduce ['luma frame * 8]
        either l1/offset/y > l2 [l1/offset/y: max l2 l1/offset/y - 10][
            if t1/offset/y > t2 [t1/offset/y: max t2 t1/offset/y - 10]
        ]
        t1/offset/y > t2
    ][  ; fade in rest
        repend l/pane [b1 t3 t4]
        b1/color: t3/font/color: t4/font/color: white
        false
    ][
        b1/color: b1/color - 4.16.16
        if frame > 6 [
            t3/font/color: t3/font/color - 16
        ]
        if frame > 12 [
            t4/font/color: t4/font/color - 16
        ]
        t4/font/color <> 0.0.0
    ][
        frame < 60
    ]
]

view/new l
l/rate: 30
frame: 1

l/feel: make l/feel [
    detect: func [face evt] [
        if find [close down key] evt/type [quit]
        if evt/type = 'time [
            evt: do first actions
            frame: frame + 1
            show face
            if not evt [
                actions: next actions
                frame: 1
                if tail? actions [quit]
            ]
        ]
    ]
]
recycle
show l
do-events