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
|
|
25
|
import android.app.Activity;
|
26
|
import android.opengl.GLSurfaceView;
|
27
|
import android.os.Bundle;
|
28
|
import android.view.View;
|
29
|
import android.widget.RadioButton;
|
30
|
import android.widget.SeekBar;
|
31
|
import android.widget.TextView;
|
32
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
public class DeformActivity extends Activity implements OnSeekBarChangeListener
|
37
|
{
|
38
|
private SeekBar barR;
|
39
|
private TextView textR;
|
40
|
private RadioButton effect;
|
41
|
|
42
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
43
|
|
44
|
@Override
|
45
|
protected void onCreate(Bundle icicle)
|
46
|
{
|
47
|
super.onCreate(icicle);
|
48
|
setContentView(R.layout.deformlayout);
|
49
|
|
50
|
barR = (SeekBar)findViewById(R.id.deformSeekRadius);
|
51
|
barR.setOnSeekBarChangeListener(this);
|
52
|
|
53
|
textR = (TextView)findViewById(R.id.deformTextRadius);
|
54
|
|
55
|
barR.setProgress(50);
|
56
|
|
57
|
textR.setText("Radius: 50");
|
58
|
|
59
|
effect = (RadioButton)findViewById(R.id.deformDistortButton);
|
60
|
effect.setChecked(true);
|
61
|
DeformRenderer.setMode(DeformRenderer.MODE_DISTORT);
|
62
|
}
|
63
|
|
64
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
65
|
|
66
|
@Override
|
67
|
protected void onPause()
|
68
|
{
|
69
|
DeformRenderer.onPause();
|
70
|
|
71
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
72
|
mView.onPause();
|
73
|
|
74
|
super.onPause();
|
75
|
}
|
76
|
|
77
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
78
|
|
79
|
@Override
|
80
|
protected void onResume()
|
81
|
{
|
82
|
super.onResume();
|
83
|
|
84
|
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.deformSurfaceView);
|
85
|
mView.onResume();
|
86
|
}
|
87
|
|
88
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
89
|
|
90
|
@Override
|
91
|
protected void onDestroy()
|
92
|
{
|
93
|
android.util.Log.e("activity","onDestroy");
|
94
|
|
95
|
Distorted.onDestroy();
|
96
|
super.onDestroy();
|
97
|
}
|
98
|
|
99
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
100
|
|
101
|
public void Distort(View v)
|
102
|
{
|
103
|
DeformRenderer.setMode(DeformRenderer.MODE_DISTORT);
|
104
|
}
|
105
|
|
106
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
107
|
|
108
|
public void Deform(View v)
|
109
|
{
|
110
|
DeformRenderer.setMode(DeformRenderer.MODE_DEFORM);
|
111
|
}
|
112
|
|
113
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114
|
|
115
|
public void Shear(View v)
|
116
|
{
|
117
|
DeformRenderer.setMode(DeformRenderer.MODE_SHEAR);
|
118
|
}
|
119
|
|
120
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
121
|
|
122
|
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
|
123
|
{
|
124
|
switch (bar.getId())
|
125
|
{
|
126
|
case R.id.deformSeekRadius: DeformRenderer.setRegionRadius(progress);
|
127
|
textR.setText("Radius: "+progress);
|
128
|
break;
|
129
|
}
|
130
|
}
|
131
|
|
132
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
133
|
|
134
|
public void onStartTrackingTouch(SeekBar bar) { }
|
135
|
|
136
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
137
|
|
138
|
public void onStopTrackingTouch(SeekBar bar) { }
|
139
|
|
140
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
141
|
|
142
|
}
|