Neocities /
Hodgepodge /
Programming / Animated Rebol Teslacoil
(cropped screenshot)
(It'll be animated when it's running)
The Code (teslacoil.r) :
rebol [title: "A Tesla Coil"]
random/seed now
branch: funct[x y L a][
x2: x + (L * sine a)
y2: y - (L * cosine a)
L2: L * (0.4 + ((random 2000) * 0.57 / 2000))
a2: a + (random 2000 / L) - (random 2000 / L)
c: to-integer (L * 7)
if c > 255 [c: 255]
append block compose [
line-width (L / 7)
pen (to-tuple reduce [c c 255])
line (as-pair x y) (as-pair x2 y2)
]
if L > 8 [loop (random 3) [branch x2 y2 L2 a2]] ; recursive
]
view layout[
origin 0x0 space 0x0
b: box black 400x400
led 0x0 rate 60 [
block: copy [line-cap rounded]
branch 200 399 64 0
b/effect: reduce ['draw block]
show b
]
]