Mailing List Archive: 49091 messages

## [REBOL] Draw performance

### From: davidegessi::tin::it at: 21-Jan-2003 19:16

```
Hi all,
I've read the new draw documentation in the rebol website and make some
exercises, one of them is Bubbles (inspired by a BeOS screensaver).
I have a P3 733, WinXP and the max number of bubbles that i can run is about
100, greater values produces flickering.
How, in this examples, can I improve the frame/rate ?

[Strange, but seems that fill circles or empty ones produces the same
performances.]

Ciao
Davide

8<----------
REBOL [
Title: "Bubbles"
File:  %bubbles.r
Date:  21-Jan-2003
Version: 0.0.1
Author: "Davide Gessi"
Email: [davidegessi--tin--it]
History: {
v0.0.1
- Prima release.
}
]

pick-velocity: func [
"pick a random non-zero velocity for a bubble"
][
v: 0x0
while [equal? v 0x0] [
v: subtract random 20x20 10x10
]
return v
]

create-bubbles: func [
"Creates a block containing bubbles information"
N [integer!] "how many bubble ?"
][
ret: make block! N
loop N [
append/only ret reduce [
to-pair reduce [bbwidth / 2 bbheight / 2]		;position
pick-velocity								;velocity
random 255.255.255						;color
]
]
return ret
]

step-bubbles: func [
"Makes bubbles do a step and return a draw sequence"
bubbles [block!] "the bubbles"
][
ret: copy []
forall bubbles [
b: first bubbles
b/1: b/1 + b/2
if any [b/1/1 < 0 b/1/1 > bbwidth b/1/2 < 0 b/1/2 > bbheight] [
;New bubble
b/1: to-pair reduce [bbwidth / 2 bbheight / 2]	;position
pick-velocity								;velocity
b/3: random 255.255.255					;color
b/4: random 30							;radius
]
;append ret reduce ['pen b/3 'fill-pen b/3 'circle b/1 b/4]
append ret reduce ['pen b/3 'circle b/1 b/4]
]
return ret
]

bbwidth: 800
bbheight: 600
bb: create-bubbles 100

view layout compose [
blackboard: box (to-pair reduce [bbwidth bbheight]) black effect [
draw [
pen red
fill-pen gray
circle 50x50 10
]
]
rate 20 feel [
engage: func [f a e] [
if equal? a 'time [
blackboard/effect: reduce ['draw step-bubbles bb]
show blackboard
]
]
]
]
8<----------

--
Windows XP is a 32-bit shell for a 16-bit extension to an 8-bit operating
system designed for a 4-bit microprocessor by a 2-bit company that can't
stand one bit of competition.
```