-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathfeedback.py
More file actions
56 lines (39 loc) · 1.63 KB
/
Copy pathfeedback.py
File metadata and controls
56 lines (39 loc) · 1.63 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
"""Classic TouchDesigner-style feedback patch.
The TD network is:
source (this frame) ─┐
├─► Composite ─┬─► Out (display)
Feedback ─► Level ───┘ │
▲ (decay) │
└───────────────────────────────┘ feedback taps the composite output
i.e. out(t) = composite( source(t), decay * out(t-1) ).
Here the sketch canvas *is* the composite output. Because it isn't cleared each
frame, it persists and feeds back into itself. So:
- feedback(decay=...) is the Feedback TOP + Level (samples the previous
composite output and fades it, optionally zooming/rotating it);
- the shapes drawn afterwards are this frame's source, composited *over* the
faded feedback;
- the canvas persists, closing the loop.
"""
from mewnala import *
from math import sin, cos
t = 0.0
def setup():
size(800, 600)
background(0, 0, 0) # clear once; draw() never clears, so the canvas accumulates
def draw():
global t
# --- feedback line: previous composite output, decayed + slowly zoomed/rotated ---
feedback(decay=0.94, zoom=1.008, angle=0.006)
# --- this frame's source, composited over the feedback (drawn on top) ---
no_stroke()
x = width / 2 + cos(t) * 230
y = height / 2 + sin(t * 1.3) * 170
fill(0, 220, 255)
circle(x, y, 44)
x2 = width / 2 + cos(t * 0.7 + 2.0) * 150
y2 = height / 2 + sin(t * 1.1) * 120
fill(255, 90, 200)
circle(x2, y2, 28)
t += 0.03
# TODO: this should happen implicitly on module load somehow
run()