-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnoisefield.pde
129 lines (102 loc) · 2.78 KB
/
noisefield.pde
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/3897*@* */
/* !do not delete the line above, required for linking your tweak if you re-upload */
int NUM_PARTICLES = 300;
class NoiseFieldRenderer extends AudioRenderer {
int rotations;
NoiseFieldRenderer(AudioSource source) {
//rotations = (int) source.sampleRate() / source.bufferSize();
}
int oX = mouseX;
int oY = mouseY;
ParticleSystem p;
void setup()
{
smooth();
size(canvasW, canvasH);
colorMode(HSB, 255);
background(0);
int setTraceModeF = 10;
int setSpeed = 20;
int setContrastModeF = 2;
p = new ParticleSystem();
}
synchronized void draw()
{
colorMode(HSB, 255);
noStroke();
int setTraceModeF = (int)map(vFader4, 0, 255, 0, 100);
fill(0, setTraceModeF);
rect(0, 0, width, height);
try {
p.update();
p.render();
throw new NullPointerException();
}
catch (NullPointerException e) {
}
}
public void onClick(float mX, float mY) {
float cX = mX * canvasW;
float cY = mY * canvasH;
oX = (int)cX;
oY = (int)cY;
}
}
class Particle
{
PVector position, velocity;
Particle()
{
position = new PVector(random(width), random(height));
velocity = new PVector();
}
void update()
{
float setSpeed = (float)map(vFader5, 0, 255, 0.1, 10);
int setDetailF = (int)map(vFader6, 0, 255, 1, 20);
//float noisefields = setNoiseDetailF;
//velocity.x = setSpeed*(noise(noisefield.oX/10+position.y/100)-.5);
//velocity.y = setSpeed*(noise(noisefield.oY/10+position.x/100)-.5);
velocity.x = setSpeed*(noise(noisefield.oX/setDetailF+position.y/10)-0.5);
velocity.y = setSpeed*(noise(noisefield.oY/setDetailF+position.x/10)-0.5);
position.add(velocity);
if (position.x<0)position.x+=width;
if (position.x>width)position.x-=width;
if (position.y<0)position.y+=height;
if (position.y>height)position.y-=height;
}
void render()
{
//int setContrastModeF = (int)map(vFader6, 0, 255, 1, 10);
int setContrastModeF = (int)map(vFader6, 0, 255, 1, 10);
//stroke((setcolorMode+10)+20*sin(setContrastModeF*HALF_PI*noisefield.rotations), vFader2, vFader3);
stroke((setcolorMode+10)- setContrastModeF*sin(HALF_PI), vFader2, vFader3);
line(position.x, position.y, position.x-velocity.x, position.y-velocity.y);
}
}
class ParticleSystem
{
Particle[] particles;
ParticleSystem()
{
particles = new Particle[NUM_PARTICLES];
for(int i = 0; i < NUM_PARTICLES; i++)
{
particles[i]= new Particle();
}
}
void update()
{
for(int i = 0; i < NUM_PARTICLES; i++)
{
particles[i].update();
}
}
void render()
{
for(int i = 0; i < NUM_PARTICLES; i++)
{
particles[i].render();
}
}
}