Revision 8b7c0ab3
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/examples/dynamic/DynamicActivity.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
public class DynamicActivity extends Activity implements OnSeekBarChangeListener |
37 | 37 |
{ |
38 |
private SeekBar barD, barN; |
|
39 | 38 |
private TextView textD, textN; |
40 |
|
|
39 |
private int progress0, progress1, progress2; |
|
40 |
|
|
41 | 41 |
/////////////////////////////////////////////////////////////////// |
42 | 42 |
@Override |
43 | 43 |
protected void onCreate(Bundle savedInstanceState) |
44 | 44 |
{ |
45 | 45 |
super.onCreate(savedInstanceState); |
46 |
setContentView(R.layout.interpolatorlayout); |
|
47 |
|
|
48 |
barD = (SeekBar)findViewById(R.id.interpolatorSeekDuration); |
|
49 |
barD.setOnSeekBarChangeListener(this); |
|
50 |
textD = (TextView)findViewById(R.id.interpolatorTextDuration); |
|
51 |
|
|
52 |
barN = (SeekBar)findViewById(R.id.interpolatorSeekNoise); |
|
53 |
barN.setOnSeekBarChangeListener(this); |
|
54 |
textN = (TextView)findViewById(R.id.interpolatorTextNoise); |
|
55 |
|
|
56 |
barD.setProgress(50); |
|
57 |
textD.setText("Duration: 10 s"); |
|
58 |
|
|
59 |
barN.setProgress(0); |
|
60 |
textN.setText("Noise: 0.0"); |
|
46 |
setContentView(R.layout.dynamicslayout); |
|
47 |
|
|
48 |
textD = (TextView)findViewById(R.id.dynamicTextDuration); |
|
49 |
textN = (TextView)findViewById(R.id.dynamicTextNoise); |
|
50 |
|
|
51 |
SeekBar bar = (SeekBar)findViewById(R.id.dynamicSeekDuration); |
|
52 |
bar.setOnSeekBarChangeListener(this); |
|
53 |
bar.setProgress(50); |
|
54 |
|
|
55 |
progress0=0; |
|
56 |
progress1=0; |
|
57 |
progress2=0; |
|
58 |
|
|
59 |
|
|
60 |
//textD.setText("Duration: 10 s"); |
|
61 |
//textN.setText("Noise: 0.0"); |
|
62 |
|
|
63 |
bar = (SeekBar)findViewById(R.id.dynamicSeekNoise0); |
|
64 |
bar.setProgress(0); |
|
65 |
bar.setOnSeekBarChangeListener(this); |
|
66 |
bar = (SeekBar)findViewById(R.id.dynamicSeekNoise1); |
|
67 |
bar.setProgress(0); |
|
68 |
bar.setOnSeekBarChangeListener(this); |
|
69 |
bar = (SeekBar)findViewById(R.id.dynamicSeekNoise2); |
|
70 |
bar.setProgress(0); |
|
71 |
bar.setOnSeekBarChangeListener(this); |
|
61 | 72 |
} |
62 | 73 |
|
63 | 74 |
/////////////////////////////////////////////////////////////////// |
... | ... | |
66 | 77 |
{ |
67 | 78 |
super.onResume(); |
68 | 79 |
|
69 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView);
|
|
80 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
70 | 81 |
mView.onResume(); |
71 | 82 |
} |
72 | 83 |
|
... | ... | |
74 | 85 |
@Override |
75 | 86 |
protected void onPause() |
76 | 87 |
{ |
77 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView);
|
|
88 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.dynamicSurfaceView);
|
|
78 | 89 |
mView.onPause(); |
79 | 90 |
|
80 | 91 |
super.onPause(); |
... | ... | |
148 | 159 |
|
149 | 160 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
150 | 161 |
{ |
151 |
float v, t; |
|
152 |
int i; |
|
153 |
|
|
154 |
switch (bar.getId()) |
|
162 |
int id = bar.getId(); |
|
163 |
|
|
164 |
if( id == R.id.dynamicSeekDuration ) |
|
165 |
{ |
|
166 |
float v = progress*200; |
|
167 |
int i = (int)(v/100); |
|
168 |
float t = i/10.0f; |
|
169 |
DynamicSurfaceView.setDuration((int)v); |
|
170 |
textD.setText("Duration: "+(int)t+" s"); |
|
171 |
} |
|
172 |
else |
|
155 | 173 |
{ |
156 |
case R.id.interpolatorSeekDuration: v = progress*200;
|
|
157 |
i = (int)(v/100);
|
|
158 |
t = i/10.0f;
|
|
159 |
DynamicSurfaceView.setDuration((int)v);
|
|
160 |
textD.setText("Duration: "+(int)t+" s");
|
|
161 |
break;
|
|
162 |
case R.id.interpolatorSeekNoise : DynamicSurfaceView.setNoise(progress/100.0f); |
|
163 |
textN.setText("Noise: "+(progress/100.f));
|
|
164 |
break;
|
|
174 |
switch(id)
|
|
175 |
{
|
|
176 |
case R.id.dynamicSeekNoise0 : progress0 = progress; break;
|
|
177 |
case R.id.dynamicSeekNoise1 : progress1 = progress; break;
|
|
178 |
case R.id.dynamicSeekNoise2 : progress2 = progress; break;
|
|
179 |
}
|
|
180 |
|
|
181 |
DynamicSurfaceView.setNoise(progress0/100.0f,progress1/100.0f,progress2/100.0f);
|
|
182 |
textN.setText("Noise: "+(progress0/100.f)+" "+(progress1/100.f)+" "+(progress2/100.f));
|
|
165 | 183 |
} |
166 | 184 |
} |
167 | 185 |
|
Also available in: Unified diff
Improve the Dynamics app (multi-dimensional noise)