Project

General

Profile

« Previous | Next » 

Revision 7589635e

Added by Leszek Koltunski almost 8 years ago

Major push towards simplifying DistortedObject's public API.
All MATRIX effects are using the new API - the 'DataND' marker interfaces.

View differences:

src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.java
30 30
import org.distorted.library.Distorted;
31 31
import org.distorted.library.DistortedBitmap;
32 32
import org.distorted.library.EffectTypes;
33
import org.distorted.library.type.Float2D;
34
import org.distorted.library.type.Float4D;
35
import org.distorted.library.type.Interpolator2D;
33
import org.distorted.library.type.Dynamic2D;
34
import org.distorted.library.type.Static2D;
35
import org.distorted.library.type.Static3D;
36
import org.distorted.library.type.Static4D;
36 37

  
37 38
import android.graphics.Bitmap;
38 39
import android.graphics.BitmapFactory;
......
47 48
   
48 49
   private GLSurfaceView mView;
49 50
   private DistortedBitmap[] bmp;
50
   private Float2D point;
51
   private Interpolator2D di;
52
   private Float2D[] vec;
51
   private Static2D point;
52
   private Dynamic2D di;
53
   private Static2D[] vec;
53 54
   private int bmpHeight, bmpWidth;
54 55
    
55 56
///////////////////////////////////////////////////////////////////////////////////////////////////
......
59 60
      mView = v;
60 61
     
61 62
      // create shared effects - enlarge the nose and keep moving the whole bitmap left and right.
62
      di = new Interpolator2D();
63
      di = new Dynamic2D();
63 64
      di.setCount(0.0f);
64 65
      di.setDuration(3000);
65
      vec = new Float2D[2];
66
      vec[0] = new Float2D( 25,0);
67
      vec[1] = new Float2D(-25,0);
66
      vec = new Static2D[2];
67
      vec[0] = new Static2D( 25,0);
68
      vec[1] = new Static2D(-25,0);
68 69
      di.add(vec[0]);
69 70
      di.add(vec[1]);
70
      point = new Float2D(305, 380);
71
      point = new Static2D(305, 380);
71 72
      }
72 73

  
73 74
///////////////////////////////////////////////////////////////////////////////////////////////////
......
117 118
      if( bmpHeight/(NUM*bmpWidth) > height/width )
118 119
        {
119 120
        int w = (height*bmpWidth)/bmpHeight;
120
      
121
        float factor = (float)height/bmpHeight;
122
        Static3D scale = new Static3D(factor,factor,factor);
123

  
121 124
        for(int i=NUM-1; i>=0; i--) 
122 125
          {
123
          bmp[i].move( (width-NUM*w)/2 +i*w ,0,0);
124
          bmp[i].scale((float)height/bmpHeight);
126
          bmp[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) );
127
          bmp[i].scale(scale);
125 128
          }
126 129
        }
127 130
      else
128 131
        {
129 132
        int w = width/NUM;  
130 133
        int h = (width*bmpHeight)/(bmpWidth*NUM);
131
      
134
        float factor = (float)width/(bmpWidth*NUM);
135
        Static3D scale = new Static3D(factor,factor,factor);
136

  
132 137
        for(int i=NUM-1; i>=0; i--) 
133 138
          {
134
          bmp[i].move(i*w, (height-h)/2, 0);  
135
          bmp[i].scale((float)width/(bmpWidth*NUM));
139
          bmp[i].move( new Static3D(i*w,(height-h)/2,0) );
140
          bmp[i].scale(scale);
136 141
          }
137 142
        }
138 143
         
......
160 165
      bmp[1].setBitmap(bitmap1);
161 166
      bmp[2].setBitmap(bitmap2);
162 167
         
163
      bmp[0].sink(8.0f, new Float4D(0,0,80,80), point, 0, 0.5f);
168
      bmp[0].sink(8.0f, new Static4D(0,0,80,80), point, 0, 0.5f);
164 169
      bmp[0].distort(di,point); 
165 170
      
166 171
      try

Also available in: Unified diff