Last active
June 20, 2016 14:55
-
-
Save iArnold/145cccbe09723af58235fc3fecb9ea29 to your computer and use it in GitHub Desktop.
Sparks with a twist
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: "Sparks demo" | |
Author: "Qingtian Xie" | |
File: %sparks.red | |
Tabs: 4 | |
Needs: View | |
] | |
system/view/auto-sync?: no | |
font-A: make font! [ | |
name: "Times New Roman" | |
size: 20 | |
color: red | |
style: [bold] | |
anti-alias?: yes | |
] | |
sparks: make block! 200 | |
one-sixty: 1.0 / 60.0 | |
view [ | |
bg-canvas: base 200.200.200 640x480 top "Move the mouse ;-)" | |
at 0x0 | |
canvas: image %sparks-red-logo-tp.png 640x480 all-over rate 0:0:0.01666 | |
on-time [ | |
draw: copy [pen red ] | |
foreach spark sparks [ | |
spark/1: spark/1 + (spark/2 / 2) | |
spark/2/y: spark/2/y + 3 | |
spark/3: spark/3 - one-sixty | |
reduce/into ['line spark/1 spark/1 + spark/2] tail draw | |
] | |
bg-canvas/draw: draw | |
show bg-canvas | |
forall sparks [ ;-- remove old spark | |
if sparks/1/3 < 0.0 [sparks: back remove sparks] | |
] | |
][sparks one-sixty] | |
on-over [ | |
append/only sparks reduce [ ;@@ optimize the memory usage | |
event/offset | |
as-pair (20 * random 1.0) - 10 (-40 * random 1.0) | |
1.0 | |
] | |
] | |
do [bg-canvas/font: font-A] | |
] | |
system/view/auto-sync?: yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could not just add this picture to the gist