Project

General

Profile

« Previous | Next » 

Revision c11a3a15

Added by Leszek Koltunski about 8 years ago

Encode more info in the EfectNames enum.

View differences:

src/main/java/org/distorted/examples/aroundtheworld/AroundTheWorldSurfaceViewPicker.java
95 95
          }
96 96
        else if( xf< -0.865f )
97 97
          {
98
          yf *= (-0.865f/xf);
99 98
          xf  =  -0.865f;
100 99
          }
101 100

  
src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java
57 57
  private TextView mText,mTextRegion,mTextCenter;
58 58

  
59 59
  private Dynamic1D mDyn1;
60
  private Dynamic2D mDyn2;
60 61
  private Dynamic3D mDyn3;
61 62
  private Dynamic5D mDyn5;
62 63
  private Static1D  mSta1;
64
  private Static2D  mSta2;
63 65
  private Static3D  mSta3;
64 66
  private Static5D  mSta5;
65 67
  private Dynamic4D mRegionDyn;
......
70 72
  private View mButton, mEffect, mCenter, mRegion;
71 73
  private long mId;
72 74

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74
// requires knowledge about effect nature
75

  
76
  private int getDimension()
77
    {
78
    switch(mName)
79
      {
80
      case DISTORT      :
81
      case DEFORM       : return 3;
82

  
83
      case CHROMA       :
84
      case SMOOTH_CHROMA: return 4;
85

  
86
      case WAVE         : return 5;
87

  
88
      default           : return 1;
89
      }
90
    }
91

  
92 75
///////////////////////////////////////////////////////////////////////////////////////////////////
93 76
// requires knowledge about effect nature
94 77

  
......
117 100
      }
118 101
    }
119 102

  
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121
// requires knowledge about effect nature
122

  
123
  private boolean supportsRegion()
124
    {
125
    return mName != EffectNames.DEFORM;
126
    }
127

  
128 103
///////////////////////////////////////////////////////////////////////////////////////////////////
129 104
// requires knowledge about effect nature
130 105

  
......
147 122
                              float v2 = (mInter[4]-50)*180 / 50;
148 123
                              mSta5.set(x2,y2,z2,w2,v2);
149 124
                              break;
150
      case SINK             : mSta1.set(mInter[0] > 50 ? 50.0f/(100.01f-mInter[0]) : mInter[0] / 50.0f);
151
                              break;
152 125
      case SWIRL            : mSta1.set( 3.6f*(mInter[0]-50) );
153 126
                              break;
154

  
155 127
      case ALPHA            :
156 128
      case SMOOTH_ALPHA     : mSta1.set(mInter[0]/100.0f);
157 129
                              break;
130
      case SINK             :
158 131
      case SATURATION       :
159 132
      case SMOOTH_SATURATION:
160 133
      case CONTRAST         :
......
172 145
    }
173 146

  
174 147
///////////////////////////////////////////////////////////////////////////////////////////////////
175
// requires knowledge about effect nature
176 148

  
177 149
  private void setDefaultInter()
178 150
    {
179
    switch(mName)
151
    switch(mDimension)
180 152
      {
181
      case DISTORT          :
182
      case DEFORM           : mInter[0] = 50;
183
                              mInter[1] = 50;
184
                              mInter[2] = 50;
185
                              break;
186
      case WAVE             : mInter[0] = 50;
187
                              mInter[1] = 50;
188
                              mInter[2] = 50;
189
                              mInter[3] = 50;
190
                              mInter[4] = 50;
191
                              break;
192
      case SINK             :
193
      case SWIRL            : mInter[0] = 50;
194
                              break;
195

  
196
      case ALPHA            :
197
      case SMOOTH_ALPHA     :
198
      case BRIGHTNESS       :
199
      case SMOOTH_BRIGHTNESS:
200
      case SATURATION       :
201
      case SMOOTH_SATURATION:
202
      case CONTRAST         :
203
      case SMOOTH_CONTRAST  : mInter[0] = 50;
204
                              break;
205

  
206
      case CHROMA           :
207
      case SMOOTH_CHROMA    : mInter[0] = 50;
208
                              mInter[1] =  0;
209
                              mInter[2] =  0;
210
                              mInter[3] =  0;
211
                              break;
153
      case 5: mInter[4] = 50;
154
      case 4: mInter[3] = 50;
155
      case 3: mInter[2] = 50;
156
      case 2: mInter[1] = 50;
157
      case 1: mInter[0] = 50;
212 158
      }
213 159
    }
214 160

  
......
224 170
      text += " "+f1;
225 171
      }
226 172

  
173
    if( mSta2 !=null )
174
      {
175
      float f1 = ((int)(mSta2.getX()*100))/100.0f;
176
      float f2 = ((int)(mSta2.getY()*100))/100.0f;
177
      text += " ("+f1+","+f2+")";
178
      }
179

  
227 180
    if( mSta3 !=null )
228 181
      {
229 182
      float f1 = ((int)(mSta3.getX()*100))/100.0f;
......
323 276
    mName = name;
324 277

  
325 278
    mDyn1 = null;
279
    mDyn2 = null;
326 280
    mDyn3 = null;
327 281
    mDyn5 = null;
328 282
    mSta1 = null;
283
    mSta2 = null;
329 284
    mSta3 = null;
330 285
    mSta5 = null;
331 286

  
332
    mDimension = getDimension();
287
    mDimension = mName.getDimension();
333 288

  
334 289
    switch(mDimension)
335 290
      {
......
337 292
               mSta1 = new Static1D(0);
338 293
               mDyn1.add(mSta1);
339 294
               break;
295
      case 2 : mDyn2 = new Dynamic2D();
296
               mSta2 = new Static2D(0,0);
297
               mDyn2.add(mSta2);
298
               break;
340 299
      case 3 : mDyn3 = new Dynamic3D();
341 300
               mSta3 = new Static3D(0,0,0);
342 301
               mDyn3.add(mSta3);
......
448 407
      seek[i].setProgress( mInter[i] );
449 408
      }
450 409

  
451
    Effects3DActivity.setSupportsRegion(supportsRegion());
410
    Effects3DActivity.setSupportsRegion(mName.supportsRegion());
452 411
    Effects3DActivity.setTypeVertex(mName.getType() == EffectTypes.VERTEX);
453 412

  
454 413
    return mEffect;
......
595 554

  
596 555
    if( fromUser )
597 556
      {
598
      Effects3DActivity.setSupportsRegion(supportsRegion());
557
      Effects3DActivity.setSupportsRegion(mName.supportsRegion());
599 558
      Effects3DActivity.setTypeVertex(mName.getType() == EffectTypes.VERTEX);
600 559

  
601 560
      Effects3DActivity act = mAct.get();
src/main/res/layout/effects3dlayout.xml
40 40
        <Button
41 41
            android:layout_width="wrap_content"
42 42
            android:layout_height="wrap_content"
43
            android:text="@string/RemoveAll"
43
            android:text="@string/reset"
44 44
            android:id="@+id/buttonRemove"
45 45
            android:onClick="removeAll"
46 46
            />

Also available in: Unified diff