-
-
Save dockimbel/3cd5910b9674f67d1b910080eca100c9 to your computer and use it in GitHub Desktop.
Animated bubbles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Title: "Bubbles" | |
Author: [REBOL version "Gabriele Santilli" Red port "Gregg Irwin"] | |
File: %bubbles.red | |
Tabs: 4 | |
Needs: View | |
] | |
system/view/auto-sync?: no | |
bubbles: [] | |
d: [pen 80.80.255.175] | |
t: now/time/precise | |
random/seed to integer! t/second | |
rand: func [v] [random v] | |
rnd-pair: does [as-pair rand 400 rand 400] | |
move-bubble: func [bubble] [ | |
bubble/1/x: bubble/1/x - 3 + rand 5 | |
bubble/1/y: bubble/1/y - 2 - rand 6 | |
if bubble/1/y < 24 [bubble/1/y: 428] | |
bubble/-10: bubble/1 - (bubble/2 / 3) | |
] | |
loop 100 [ | |
insert insert bbl: insert tail d [ | |
fill-pen radial 150x150 30 150 0 1 1 128.128.255.105 90.90.255.165 80.80.255.175 | |
circle | |
] rnd-pair 4 + rand 20 | |
bbl/-8: bbl/2 | |
bbl/-9: to integer! bbl/2 * 0.2 ; decimal! chokes draw right now | |
bbl/-10: bbl/1 - (bbl/2 / 3) | |
insert/only tail bubbles bbl | |
] | |
view [ | |
size 400x400 | |
origin 0x0 | |
canvas: base 400x400 10.10.255 draw d rate 60 | |
on-time [ | |
foreach bubble bubbles [move-bubble bubble] | |
show canvas | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment