Revision 7589635e
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
---|---|---|
28 | 28 |
import org.distorted.examples.R; |
29 | 29 |
|
30 | 30 |
import org.distorted.library.EffectTypes; |
31 |
import org.distorted.library.type.Interpolator2D;
|
|
31 |
import org.distorted.library.type.Dynamic2D;
|
|
32 | 32 |
import org.distorted.library.Distorted; |
33 | 33 |
import org.distorted.library.DistortedBitmap; |
34 |
import org.distorted.library.type.Float2D; |
|
35 |
import org.distorted.library.type.Float4D; |
|
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; |
... | ... | |
45 | 46 |
{ |
46 | 47 |
private GLSurfaceView mView; |
47 | 48 |
private DistortedBitmap mBean; |
48 |
private Float2D pLeft, pRight;
|
|
49 |
private Interpolator2D iLeft, iRight;
|
|
50 |
private Float4D rLeft, rRight;
|
|
49 |
private Static2D pLeft, pRight;
|
|
50 |
private Dynamic2D iLeft, iRight;
|
|
51 |
private Static4D rLeft, rRight;
|
|
51 | 52 |
private int bmpHeight, bmpWidth; |
52 | 53 |
|
53 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
56 | 57 |
{ |
57 | 58 |
mView = v; |
58 | 59 |
|
59 |
pLeft = new Float2D(100, 199);
|
|
60 |
pRight= new Float2D(230, 150);
|
|
60 |
pLeft = new Static2D(100, 199);
|
|
61 |
pRight= new Static2D(230, 150);
|
|
61 | 62 |
|
62 |
rLeft = new Float4D(-9,-31,35,35);
|
|
63 |
rRight= new Float4D(-9,-31,35,35);
|
|
63 |
rLeft = new Static4D(-9,-31,35,35);
|
|
64 |
rRight= new Static4D(-9,-31,35,35);
|
|
64 | 65 |
|
65 |
iLeft = new Interpolator2D();
|
|
66 |
iRight= new Interpolator2D();
|
|
66 |
iLeft = new Dynamic2D();
|
|
67 |
iRight= new Dynamic2D();
|
|
67 | 68 |
|
68 | 69 |
iLeft.setCount(0.0f); |
69 | 70 |
iRight.setCount(0.0f); |
70 | 71 |
iLeft.setDuration(1500); |
71 | 72 |
iRight.setDuration(1500); |
72 | 73 |
|
73 |
Float2D p1 = new Float2D(0,0);
|
|
74 |
Float2D p2 = new Float2D(-10,-34);
|
|
74 |
Static2D p1 = new Static2D(0,0);
|
|
75 |
Static2D p2 = new Static2D(-10,-34);
|
|
75 | 76 |
|
76 | 77 |
iLeft.add(p1); |
77 | 78 |
iLeft.add(p1); |
... | ... | |
107 | 108 |
if( bmpHeight/bmpWidth > height/width ) |
108 | 109 |
{ |
109 | 110 |
int w = (height*bmpWidth)/bmpHeight; |
110 |
mBean.move((width-w)/2 ,0, 0); |
|
111 |
mBean.scale((float)height/bmpHeight); |
|
111 |
float factor = (float)height/bmpHeight; |
|
112 |
|
|
113 |
mBean.move( new Static3D((width-w)/2,0,0) ); |
|
114 |
mBean.scale( new Static3D(factor,factor,factor) ); |
|
112 | 115 |
} |
113 | 116 |
else |
114 | 117 |
{ |
115 | 118 |
int h = (width*bmpHeight)/bmpWidth; |
116 |
mBean.move(0 ,(height-h)/2, 0); |
|
117 |
mBean.scale((float)width/bmpWidth); |
|
119 |
float factor = (float)width/bmpWidth; |
|
120 |
|
|
121 |
mBean.move( new Static3D(0,(height-h)/2,0) ); |
|
122 |
mBean.scale( new Static3D(factor,factor,factor) ); |
|
118 | 123 |
} |
119 | 124 |
|
120 | 125 |
Distorted.onSurfaceChanged(width, height); |
Also available in: Unified diff
Major push towards simplifying DistortedObject's public API.
All MATRIX effects are using the new API - the 'DataND' marker interfaces.