1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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
|
|
20
|
package org.distorted.examples.deform;
|
21
|
|
22
|
import org.distorted.library.Distorted;
|
23
|
import org.distorted.examples.R;
|
24
|
import org.distorted.library.EffectNames;
|
25
|
|
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
|
|
41
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
42
|
|
43
|
@Override
|
44
|
protected void onCreate(Bundle icicle)
|
45
|
{
|
46
|
super.onCreate(icicle);
|
47
|
setContentView(R.layout.deformlayout);
|
48
|
|
49
|
SeekBar barR = (SeekBar)findViewById(R.id.deformSeekRadius);
|
50
|
barR.setOnSeekBarChangeListener(this);
|
51
|
|
52
|
textR = (TextView)findViewById(R.id.deformTextRadius);
|
53
|
|
54
|
barR.setProgress(50);
|
55
|
|
56
|
textR.setText("Radius: 50");
|
57
|
|
58
|
RadioButton effect = (RadioButton)findViewById(R.id.deformDistortButton);
|
59
|
effect.setChecked(true);
|
60
|
DeformRenderer.setMode(EffectNames.DISTORT);
|
61
|
}
|
62
|
|
63
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
64
|
|
65
|
@Override
|
66
|
protected void onPause()
|
67
|
{
|
68
|
DeformRenderer.onPause();
|
69
|
|
70
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
71
|
mView.onPause();
|
72
|
|
73
|
super.onPause();
|
74
|
}
|
75
|
|
76
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
77
|
|
78
|
@Override
|
79
|
protected void onResume()
|
80
|
{
|
81
|
super.onResume();
|
82
|
|
83
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
84
|
mView.onResume();
|
85
|
}
|
86
|
|
87
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
88
|
|
89
|
@Override
|
90
|
protected void onDestroy()
|
91
|
{
|
92
|
Distorted.onDestroy();
|
93
|
super.onDestroy();
|
94
|
}
|
95
|
|
96
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97
|
|
98
|
public void Distort(View v)
|
99
|
{
|
100
|
DeformRenderer.setMode(EffectNames.DISTORT);
|
101
|
}
|
102
|
|
103
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
104
|
|
105
|
public void Deform(View v)
|
106
|
{
|
107
|
DeformRenderer.setMode(EffectNames.DEFORM);
|
108
|
}
|
109
|
|
110
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
111
|
|
112
|
public void Shear(View v)
|
113
|
{
|
114
|
DeformRenderer.setMode(EffectNames.SHEAR);
|
115
|
}
|
116
|
|
117
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
118
|
|
119
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
120
|
{
|
121
|
switch (bar.getId())
|
122
|
{
|
123
|
case R.id.deformSeekRadius: DeformRenderer.setRegionRadius(progress);
|
124
|
textR.setText("Radius: "+progress);
|
125
|
break;
|
126
|
}
|
127
|
}
|
128
|
|
129
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
130
|
|
131
|
public void onStartTrackingTouch(SeekBar bar) { }
|
132
|
|
133
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
134
|
|
135
|
public void onStopTrackingTouch(SeekBar bar) { }
|
136
|
|
137
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
138
|
|
139
|
}
|