REBOL [
Title: "Animation Style"
Author: "Christopher Ross-Gill"
Date: 17-Mar-2004
Version: 0.2.0
]
stylize/master [
ANIMATION: FACE with [
anim-size: size: color: image: none
anim-rate: make block! 0
length: counter: 0
progress: does [
counter: counter // length + 1
effect/crop: counter - 1 * 0x1 * anim-size
rate: any [select anim-rate to-issue counter rate]
]
feel: make svvf/sensor [
engage: func [face action event][
switch action [
time [face/progress show face]
down [face/state: on]
alt-down [face/state: on]
up [if face/state [do-face face face/text] face/state: off]
alt-up [if face/state [do-face-alt face face/text] face/state: off]
over [face/state: on]
away [face/state: off]
]
]
]
access: context [
set-face*: func [face value /local tmp][
all [
block? value
parse value [
any [
'image set tmp [image! | none!] (face/image: tmp) |
'rate [
set tmp [integer! | time! | none!]
(insert clear face/anim-rate reduce [#1 tmp] face/progress) |
set tmp block! (face/anim-rate: tmp)
] |
'size set tmp pair! (face/anim-size: tmp)
]
]
]
]
get-face*: func [face][
reduce ['image face/image 'rate face/anim-rate 'size face/anim-size]
]
clear-face*: func [face][face/image: none face/rate: none clear face/anim-rate]
]
effect: []
edge: [size: 0x0 color: black]
font: [size: 16 align: 'center valign: 'middle style: 'bold shadow: 2x2]
doc: [
info: "base style for images"
image: "loaded image data"
string: "text on top of image"
pair: "width and height of text area"
tuple: "colorize the image"
file: "load as image data"
url: "load as image data"
block: ["execute when clicked" "execute when alt-clicked"]
]
init: [
size: any [size anim-size if image? image [image/size] 100x100]
anim-size: any [anim-size size]
insert effect [crop 0x0 anim-size]
if color [insert tail effect reduce ['colorize color 0] color: none]
insert tail effect 'fit
length: either image? image [to-integer image/size/y / anim-size/y][1]
rate: any [rate 15]
either length = 1 [rate: none][progress]
]
words: [
rate [insert new/anim-rate reduce [#1 new/rate: second args] next args]
effect [insert new/effect second args next args]
anim-size [new/anim-size: second args next args]
anim-rate [insert tail new/anim-rate second args next args]
]
]
]