1 |
bc0a685b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2016 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
|
|
// This file is part of Distorted. //
|
5 |
|
|
// //
|
6 |
|
|
// Distorted is free software: you can redistribute it and/or modify //
|
7 |
|
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
|
|
// Distorted is distributed in the hope that it will be useful, //
|
12 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
|
|
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
427ab7bf
|
Leszek Koltunski
|
|
20 |
5068fa06
|
Leszek Koltunski
|
package org.distorted.examples.deform;
|
21 |
427ab7bf
|
Leszek Koltunski
|
|
22 |
5068fa06
|
Leszek Koltunski
|
import org.distorted.library.Distorted;
|
23 |
|
|
import org.distorted.examples.R;
|
24 |
7abd1d00
|
Leszek Koltunski
|
import org.distorted.library.EffectNames;
|
25 |
427ab7bf
|
Leszek Koltunski
|
|
26 |
|
|
import android.app.Activity;
|
27 |
|
|
import android.opengl.GLSurfaceView;
|
28 |
|
|
import android.os.Bundle;
|
29 |
|
|
import android.view.View;
|
30 |
|
|
import android.widget.RadioButton;
|
31 |
|
|
import android.widget.SeekBar;
|
32 |
|
|
import android.widget.TextView;
|
33 |
|
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
34 |
|
|
|
35 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
36 |
|
|
|
37 |
|
|
public class DeformActivity extends Activity implements OnSeekBarChangeListener
|
38 |
|
|
{
|
39 |
|
|
private TextView textR;
|
40 |
7abd1d00
|
Leszek Koltunski
|
|
41 |
427ab7bf
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42 |
|
|
|
43 |
|
|
@Override
|
44 |
|
|
protected void onCreate(Bundle icicle)
|
45 |
|
|
{
|
46 |
|
|
super.onCreate(icicle);
|
47 |
|
|
setContentView(R.layout.deformlayout);
|
48 |
7abd1d00
|
Leszek Koltunski
|
|
49 |
|
|
SeekBar barR = (SeekBar)findViewById(R.id.deformSeekRadius);
|
50 |
427ab7bf
|
Leszek Koltunski
|
barR.setOnSeekBarChangeListener(this);
|
51 |
|
|
|
52 |
|
|
textR = (TextView)findViewById(R.id.deformTextRadius);
|
53 |
|
|
|
54 |
|
|
barR.setProgress(50);
|
55 |
|
|
|
56 |
6f3024ae
|
Leszek Koltunski
|
textR.setText(getString(R.string.radius_placeholder,"50"));
|
57 |
7abd1d00
|
Leszek Koltunski
|
|
58 |
|
|
RadioButton effect = (RadioButton)findViewById(R.id.deformDistortButton);
|
59 |
427ab7bf
|
Leszek Koltunski
|
effect.setChecked(true);
|
60 |
30c71dd5
|
Leszek Koltunski
|
|
61 |
|
|
DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
62 |
|
|
|
63 |
|
|
view.getRenderer().setMode(EffectNames.DISTORT);
|
64 |
427ab7bf
|
Leszek Koltunski
|
}
|
65 |
|
|
|
66 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
67 |
|
|
|
68 |
|
|
@Override
|
69 |
|
|
protected void onPause()
|
70 |
|
|
{
|
71 |
30c71dd5
|
Leszek Koltunski
|
DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
72 |
|
|
|
73 |
|
|
view.getRenderer().onPause();
|
74 |
|
|
view.onPause();
|
75 |
427ab7bf
|
Leszek Koltunski
|
super.onPause();
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
79 |
|
|
|
80 |
|
|
@Override
|
81 |
|
|
protected void onResume()
|
82 |
|
|
{
|
83 |
|
|
super.onResume();
|
84 |
|
|
|
85 |
30c71dd5
|
Leszek Koltunski
|
GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
86 |
|
|
view.onResume();
|
87 |
427ab7bf
|
Leszek Koltunski
|
}
|
88 |
|
|
|
89 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
90 |
|
|
|
91 |
|
|
@Override
|
92 |
|
|
protected void onDestroy()
|
93 |
|
|
{
|
94 |
7abd1d00
|
Leszek Koltunski
|
Distorted.onDestroy();
|
95 |
427ab7bf
|
Leszek Koltunski
|
super.onDestroy();
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
99 |
|
|
|
100 |
|
|
public void Distort(View v)
|
101 |
|
|
{
|
102 |
30c71dd5
|
Leszek Koltunski
|
DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
103 |
|
|
view.getRenderer().setMode(EffectNames.DISTORT);
|
104 |
427ab7bf
|
Leszek Koltunski
|
}
|
105 |
|
|
|
106 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107 |
|
|
|
108 |
|
|
public void Deform(View v)
|
109 |
|
|
{
|
110 |
30c71dd5
|
Leszek Koltunski
|
DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
111 |
|
|
view.getRenderer().setMode(EffectNames.DEFORM);
|
112 |
427ab7bf
|
Leszek Koltunski
|
}
|
113 |
|
|
|
114 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
115 |
|
|
|
116 |
|
|
public void Shear(View v)
|
117 |
|
|
{
|
118 |
30c71dd5
|
Leszek Koltunski
|
DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
119 |
|
|
view.getRenderer().setMode(EffectNames.SHEAR);
|
120 |
427ab7bf
|
Leszek Koltunski
|
}
|
121 |
|
|
|
122 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
123 |
|
|
|
124 |
|
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
125 |
|
|
{
|
126 |
|
|
switch (bar.getId())
|
127 |
|
|
{
|
128 |
30c71dd5
|
Leszek Koltunski
|
case R.id.deformSeekRadius: DeformSurfaceView view = (DeformSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
129 |
|
|
view.getRenderer().setRegionRadius(progress);
|
130 |
6f3024ae
|
Leszek Koltunski
|
textR.setText(getString(R.string.radius_placeholder,(progress<100 ? (""+progress): "Infinity") ));
|
131 |
30c71dd5
|
Leszek Koltunski
|
break;
|
132 |
427ab7bf
|
Leszek Koltunski
|
}
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
136 |
|
|
|
137 |
|
|
public void onStartTrackingTouch(SeekBar bar) { }
|
138 |
|
|
|
139 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
140 |
|
|
|
141 |
|
|
public void onStopTrackingTouch(SeekBar bar) { }
|
142 |
|
|
|
143 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
144 |
|
|
|
145 |
|
|
}
|