Skip to content

Instantly share code, notes, and snippets.

@iArnold
Last active June 20, 2016 14:55
Show Gist options
  • Save iArnold/145cccbe09723af58235fc3fecb9ea29 to your computer and use it in GitHub Desktop.
Save iArnold/145cccbe09723af58235fc3fecb9ea29 to your computer and use it in GitHub Desktop.
Sparks with a twist
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
@iArnold
Copy link
Author

iArnold commented Jun 20, 2016

That is why I wanted to know if the code from the Wiki can be adapted to draw on a transparent background. Now I had to use some tool on the web to get transparency.

@iArnold
Copy link
Author

iArnold commented Jun 20, 2016

Could not just add this picture to the gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment