[REBOL] bad animation ...
From: arngar::gmail::com at: 4-Jun-2007 11:37
Hi list !
first post ;-)
I try to create a simple animation and the result is very slow and
not smooth ....
Click on the white square and the other square move to the border of
the window ....
So why is it so slow ? (it is certainly the bad way to do ;-)
thanks for help
Arnaud
------------
rebol [
title: Inteface-test
version: 1
author: Arnaud
]
; --- there is certainly a better way ;-), but I need this function
blk-pair: function [b] [] [
to-pair reduce b
]
; ---- Window init
width: 800
height: 600
delta: 58
; --- menu cursor
cursor-moving: false
cur-menu-pos: 150x0 ; Cursor Menu position
cursor-img-menu: make image! [ 72x58 168.168.168 0 ] ; this cursor
will move
destination-image: make image! [ 72x58 255.255.255 0 ] ; click on
this image to launch the animation
; ---- Menu Anim
move-cursor-menu-to: function [ item-menu ] [] [
clear menu-bar/effect/draw
either cur-menu-pos/x > 0 [
cur-menu-pos/x: cur-menu-pos/x - 10
] [
cursor-moving: false
]
append menu-bar/effect/draw [ 'image cur-menu-pos cursor-img-
menu ]
show menu-bar
]
view layout/size [
backdrop black
origin 0x0
; ---- cursor menu
menu-bar: box blk-pair [ width delta ] effect [ gradient 0x1
68.68.68 0.0.0
draw [
image cur-menu-pos cursor-img-menu
]
]
at blk-pair [ 0 delta ]
box blk-pair [ width height - delta ]
; ---- Destination box, click on it ! to begin the animation
at 10x2
register-menu: box rate 0:0:0.1 feel [
detect: func [face event] [
if event/type = 'down [
cursor-moving: true
]
]
engage: func [f a e] [
if all [ (a = 'time)
cursor-moving ] [
move-cursor-menu-to register-menu ]
]
] effect [
draw [
image destination-image
]
]
] blk-pair [width height]