-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspirals.spd
More file actions
executable file
·67 lines (52 loc) · 1.5 KB
/
spirals.spd
File metadata and controls
executable file
·67 lines (52 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/local/bin/spd
import "GUI"
main
return SpiralDemo().RunAsMain
class SpiralDemo (Window)
|[bounceable]| Spirals
constructor
.spirals <~ bounceable((0.5 , 0.13), (0.25,0.0), vec4(0.1, 0, 0.3,0))
.spirals <~ bounceable((0.25, 0.05), (0.5, 0.0), vec4(0.3,-0.2,0, 0))
.spirals <~ bounceable((0.75, -0.1), (0.75,0.0), vec4(0.5, 0, 0, 0))
behaviour FrameStep
for s in .Spirals
s.y.x2 -= 0.0024
s.x.x += s.x.x2/128
s.y.x += s.y.x2/128
s.x = s.x.Bounce
s.y = s.y.Bounce
gui.Touch
behaviour Drawbackground
where.DrawRect(self, colors.black)
|| C = .LastRect.vec4
|| C2 = C + (C.size*0.25, -C.size*0.25)
|| L = 24s()
for (s in .Spirals) (i)
L = -L
|| PS = ((s.x.x, s.y.x) * c2.size) + c2.xy
where.DrawSpiral(144, L, PS, s.col * 0.2[], (3s+i*1s)())
class Bounceable
|vec2| X // This is wierd but i don't care
|vec2| Y // Its just a demo :). demos are ALWWAYS WIERD
|vec4| Col
function vec2.bounce (|vec2|)
if .x > 1.0
return (2.0, 0) - self
if .x < 0
return -self
return self
function image.DrawSpiral (|float| Max, |float| angle, |vec2| XY, |vec4| HSB, |float| Pulse)
|| sub = 24.0
max += sub/2
Pulse = Pulse * max
for j in max
if j <= sub
continue
|| i = j - sub
|| R = ((i*0.2123)+angle).SinCos
|| closeness = (i - Pulse + 4.0() ).Length
|| strength = (-0.005*closeness.pow2).Exp * 5.0
|| P = R*(50.0+i+strength) + XY
|| A = ((Max-i)*2.0)/max
|| C = Colors.wheel((i*0.005, 0.7, 1.0, A)+HSB)
.DrawSoftCircle((P-4.0, P+4.0), C)