[REBOL] Re: PREZ dialect
From: jeff:rebol at: 6-Jun-2001 9:14
Thanks for the reminder, Allen..
The Prez dialect is up on my reb page:
There is a simple test script that the viewer will fetch
from my site as well.
I don't have it doc'd really, but below is the test example,
with a little explaination:
First the main function PRESENT expects to receive a block,
sort of like LAYOUT. At the beginning of the block you can
define some preset effects. These effects can be based on
the built in effects with overrides for your needs (sort of
like stylize). So for example, we have a slow-fade-red,
below, which is a fade that starts immediately (0:0:0) and
fades to red in 0:0:10 seconds. GO is an effect which says
to move to an absolute place. GROW is an effect which
affects the element's size, positive or negative
(shrinking). (there's also an effect MOVE which will just
move some item in a given direction, usually given a small
pair, like 1x1, move up 1 over 1 etc..) Each new preset can
be built out of a number of different builtin effects.
;-- Test-prez.r ------------------------------------------------------
slow-fade-red fade [start: 0:0:0 fade-to: red duration: 0:0:10]
go-c-slow go [xy: 250x250 duration: :0:5]
go-c-fast go [xy: 250x250 duration: :0:1]
go-c-med-fade go [xy: 250x250 duration: :0:3] fade [
start: :0:1 fade-to: green duration: :0:3
slow-grow-fade grow [start: :0:1 xy: 150x150 duration: :0:10 ] fade [
start: :0:1 fade-to: 10.20.200 duration: :0:10
slow-shrink grow [start :0:1 xy: 5x5 duration: :0:10]
size 500x500 [
h1 "Testing presentation engine"
button "8" :0:0 slow-grow-fade
button "9" :0:0 slow-shrink
txt "1" :0:0 go-c-slow
txt "2" :0:1 go-c-fast
h1 "3" :0:2 go-c-med-fade
at 480x400 guide
h1 "4" :0:0 go-c-fast
h2 "5" :0:1 go-c-slow
h3 "6" :0:2 go-c-med-fade
Okay, so the actual presentation portion has the required
format of size pair! [prez-block]. The size must be set because the
things may be flying all over the place and there'll be no way
to figure out the bounds of the presentation. So then the
presentation block is a lot like a layout. You can specify
any number of styles and then provide effects that apply to
the preceding style.
Above we are using presents, but they are shorthand for the
more generic approach where you place the effect info right
after the affect. This is the format:
style appear-time [effect-block]
button "Hello" 0:0:1 [
fade :0:0 green :0:02
fade :0:2 yellow :0:04
fade :0:4 black :0:06
The button, specified above, will appear 1 second after the
presentation begins (the first time after "Hello"). It will
immediately fade to green taking 2 seconds to complete
(specified by the first line). At 2 seconds after the
button's effects have started (right after the green fade
completed) the button will fade to yellow for 2 seconds--
finally, 4 seconds after the effects have begun, the button
fades to black in 2 seconds. Green yellow and black fade,
like some crazy rasta man stuff, a'rite!
A preset works basically by replacing that big block with the
effects block that it represents. This is handy if you are
applying the same effect repeatedly to a number of elements.
You can, of course, use any VID style, including images -- but
there are some odd bugs with some of VID that may appear.
Images don't have a proper fading ability, just fade to a
color-- not fade to transparent..
The way the system works is it basically takes the
presentation, runs through and makes absolute time
calculations for everything in the presentation. Then there's
a central player loop that says "hmm, is there anything that
needs to appear now? yes-- appear and start your
effects... hmm are there any effects that need updating?
Yes.. go update yourselves.." etc..
The code might seem a little hairy if you look at it, but do
feel free to modify and/or improve it!! :-)