Project

General

Profile

« Previous | Next » 

Revision 4562f295

Added by Leszek Koltunski over 7 years ago

Tidy up 'Moving effects'

View differences:

src/main/java/org/distorted/examples/movingeffects/MovingEffectsActivity.java
73 73
      {
74 74
      super.onResume();
75 75
      
76
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
77
      mView.onResume();
76
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
77
      view.onResume();
78 78
      }
79 79

  
80 80
///////////////////////////////////////////////////////////////////
......
83 83
      {
84 84
      Abort(null);   
85 85
      
86
      GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
87
      mView.onPause();
86
      GLSurfaceView view = (GLSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
87
      view.onPause();
88 88
      
89 89
      super.onPause();
90 90
      }
......
116 116
    
117 117
    public void Bubble(View v)
118 118
      {
119
      MovingEffectsSurfaceView.Bubble();
119
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
120
      view.Bubble();
120 121
      
121 122
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
122 123
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
......
130 131

  
131 132
    public void Sink(View v)
132 133
      {
133
      MovingEffectsSurfaceView.Sink();
134
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
135
      view.Sink();
134 136
      
135 137
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
136 138
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
......
144 146
    
145 147
    public void Transparency(View v)
146 148
      {
147
      MovingEffectsSurfaceView.Transparency();
149
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
150
      view.Transparency();
148 151
      
149 152
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
150 153
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
......
158 161

  
159 162
    public void Chroma(View v)
160 163
      {
161
      MovingEffectsSurfaceView.Chroma();
164
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
165
      view.Chroma();
162 166
      
163 167
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
164 168
      mChroma.setBackgroundColor(COLOR_PRESSED);
......
172 176

  
173 177
    public void Swirl(View v)
174 178
      {
175
      MovingEffectsSurfaceView.Swirl();
179
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
180
      view.Swirl();
176 181
      
177 182
      mAbort.setBackgroundColor(COLOR_UNPRESSED);
178 183
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
......
186 191

  
187 192
    public void Abort(View v)
188 193
      {
189
      MovingEffectsSurfaceView.Abort();
194
      MovingEffectsSurfaceView view = (MovingEffectsSurfaceView) this.findViewById(R.id.movingeffectsSurfaceView);
195
      view.Abort();
190 196
      
191 197
      mAbort.setBackgroundColor(COLOR_PRESSED);
192 198
      mChroma.setBackgroundColor(COLOR_UNPRESSED);
src/main/java/org/distorted/examples/movingeffects/MovingEffectsRenderer.java
36 36

  
37 37
class MovingEffectsRenderer implements GLSurfaceView.Renderer
38 38
   {  
39
   private GLSurfaceView mView;
39
   private MovingEffectsSurfaceView mView;
40 40
   private Canvas mCanvas;
41 41
   private Bitmap mBitmap;
42 42
   private Paint mPaint;
......
46 46

  
47 47
///////////////////////////////////////////////////////////////////////////////////////////////////
48 48

  
49
   MovingEffectsRenderer(GLSurfaceView v)
49
   MovingEffectsRenderer(MovingEffectsSurfaceView v)
50 50
     {    
51 51
     mPaint = new Paint();
52 52
     mPaint.setAntiAlias(true);
......
107 107
     mCanvas = new Canvas(mBitmap);
108 108

  
109 109
     Distorted.onSurfaceChanged(texW, texH);
110
     MovingEffectsSurfaceView.onSurfaceChanged(texW,texH);
110
     mView.onSurfaceChanged(texW,texH);
111 111
     }
112 112
   
113 113
///////////////////////////////////////////////////////////////////////////////////////////////////
......
118 118
       
119 119
     long time = System.currentTimeMillis();
120 120
      
121
     if (MovingEffectsSurfaceView.getCurrentEffect() == MovingEffectsSurfaceView.EFFECT_POINTS )
121
     if (mView.getCurrentEffect() == MovingEffectsSurfaceView.EFFECT_POINTS )
122 122
       {
123 123
       drawBackground();   
124
       MovingEffectsSurfaceView.drawCurve(mCanvas,time);
124
       mView.drawCurve(mCanvas,time);
125 125
       mBackground.setBitmap(mBitmap);  
126 126
       }
127 127
      
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java
50 50
    public static final int EFFECT_CHROMA=4;
51 51
    public static final int EFFECT_SWIRL =5;
52 52

  
53
    private static Dynamic2D di2D;
54
    private static Static4D dr;
55
    private static Dynamic4D mRegion;
56

  
57
    private static Paint mPaint;
58
    private static int moving;
59 53
    private static final Object lock = new Object();
60
    private static long mTime = 0;
54

  
55
    private Dynamic2D di2D;
56
    private Static4D dr;
57
    private Dynamic4D mRegion;
58

  
59
    private Paint mPaint;
60
    private int moving;
61
    private long mTime = 0;
61 62
    
62
    private static int mCurrEffect;
63
    private static int mSize1, mSize2, mSizeR;
64
    private static int mMax;
63
    private int mCurrEffect;
64
    private int mSize1, mSize2, mSizeR;
65
    private int mMax;
65 66

  
66 67
///////////////////////////////////////////////////////////////////////////////////////////////////
67 68
    
......
96 97

  
97 98
///////////////////////////////////////////////////////////////////////////////////////////////////
98 99

  
99
    public static void onSurfaceChanged(int width,int height)
100
    public void onSurfaceChanged(int width,int height)
100 101
      {
101 102
      mMax = width>height ? width:height;
102 103

  
......
109 110

  
110 111
///////////////////////////////////////////////////////////////////////////////////////////////////
111 112

  
112
    public static int getCurrentEffect()
113
    public int getCurrentEffect()
113 114
      {
114 115
      return mCurrEffect;
115 116
      }
116 117
    
117 118
///////////////////////////////////////////////////////////////////////////////////////////////////
118 119
    
119
    public static void Bubble()
120
    public void Bubble()
120 121
      {
121 122
      if( mCurrEffect==EFFECT_BUBBLE ) return;     
122 123
      
......
131 132

  
132 133
///////////////////////////////////////////////////////////////////////////////////////////////////
133 134

  
134
    public static void Sink()
135
    public void Sink()
135 136
      {
136 137
      if( mCurrEffect==EFFECT_SINK ) return; 
137 138
         
......
146 147

  
147 148
///////////////////////////////////////////////////////////////////////////////////////////////////
148 149

  
149
    public static void Chroma()
150
    public void Chroma()
150 151
      {
151 152
      if( mCurrEffect==EFFECT_CHROMA ) return;
152 153
         
......
161 162

  
162 163
///////////////////////////////////////////////////////////////////////////////////////////////////
163 164

  
164
    public static void Transparency()
165
    public void Transparency()
165 166
      {
166 167
      if( mCurrEffect==EFFECT_TRANS ) return;   
167 168
      
......
176 177

  
177 178
///////////////////////////////////////////////////////////////////////////////////////////////////
178 179

  
179
    public static void Swirl()
180
    public void Swirl()
180 181
      {
181 182
      if( mCurrEffect==EFFECT_SWIRL ) return;   
182 183
      
......
191 192
    
192 193
///////////////////////////////////////////////////////////////////////////////////////////////////
193 194

  
194
    public static void Abort()
195
    public void Abort()
195 196
      {
196 197
      synchronized(lock)
197 198
        {
......
205 206

  
206 207
///////////////////////////////////////////////////////////////////////////////////////////////////
207 208
 
208
    public static void drawCurve(Canvas c, long time)
209
    public void drawCurve(Canvas c, long time)
209 210
      {
210 211
      synchronized(lock)
211 212
        {  

Also available in: Unified diff