Revision 7589635e
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/check/CheckRenderer.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.Float1D;
|
|
34 |
import org.distorted.library.type.Float2D;
|
|
35 |
import org.distorted.library.type.Float3D;
|
|
36 |
import org.distorted.library.type.Float4D;
|
|
37 |
import org.distorted.library.type.Interpolator1D;
|
|
38 |
import org.distorted.library.type.Interpolator2D;
|
|
33 |
import org.distorted.library.type.Static1D;
|
|
34 |
import org.distorted.library.type.Static2D;
|
|
35 |
import org.distorted.library.type.Static3D;
|
|
36 |
import org.distorted.library.type.Static4D;
|
|
37 |
import org.distorted.library.type.Dynamic1D;
|
|
38 |
import org.distorted.library.type.Dynamic2D;
|
|
39 | 39 |
|
40 | 40 |
import android.app.AlertDialog; |
41 | 41 |
import android.content.Context; |
... | ... | |
85 | 85 |
if( bmpHeight/bmpWidth > height/width ) |
86 | 86 |
{ |
87 | 87 |
int w = (height*bmpWidth)/bmpHeight; |
88 |
mSuccess.move((width-w)/2 ,0, 0); |
|
89 |
mSuccess.scale((float)height/bmpHeight); |
|
88 |
float factor = (float)height/bmpHeight; |
|
89 |
|
|
90 |
mSuccess.move( new Static3D((width-w)/2,0,0) ); |
|
91 |
mSuccess.scale( new Static3D(factor,factor,factor) ); |
|
90 | 92 |
} |
91 | 93 |
else |
92 | 94 |
{ |
93 | 95 |
int h = (width*bmpHeight)/bmpWidth; |
94 |
mSuccess.move(0 ,(height-h)/2, 0); |
|
95 |
mSuccess.scale((float)width/bmpWidth); |
|
96 |
float factor = (float)width/bmpWidth; |
|
97 |
|
|
98 |
mSuccess.move( new Static3D(0,(height-h)/2,0) ); |
|
99 |
mSuccess.scale( new Static3D(factor,factor,factor) ); |
|
96 | 100 |
} |
97 | 101 |
|
98 | 102 |
Distorted.onSurfaceChanged(width, height); |
... | ... | |
128 | 132 |
// |
129 | 133 |
// Even if adding some of the Effects fails, the App will still start - you just won't see |
130 | 134 |
// the effects that failed to add. |
131 |
Float2D pDown = new Float2D(bmpWidth/2, 0);
|
|
132 |
Float3D vDown = new Float3D( 0,-bmpHeight,0);
|
|
133 |
Float4D mRegion = new Float4D( 0, 0, 40 ,40 );
|
|
135 |
Static2D pDown = new Static2D(bmpWidth/2, 0);
|
|
136 |
Static3D vDown = new Static3D( 0,-bmpHeight,0);
|
|
137 |
Static4D mRegion = new Static4D( 0, 0, 40 ,40 );
|
|
134 | 138 |
|
135 |
Interpolator2D mPoint = new Interpolator2D();
|
|
139 |
Dynamic2D mPoint = new Dynamic2D();
|
|
136 | 140 |
mPoint.setCount(0.0f); |
137 | 141 |
mPoint.setDuration(2000); |
138 |
mPoint.add(new Float2D( 0, bmpHeight/2));
|
|
139 |
mPoint.add(new Float2D( bmpWidth, bmpHeight/2));
|
|
142 |
mPoint.add(new Static2D( 0, bmpHeight/2));
|
|
143 |
mPoint.add(new Static2D( bmpWidth, bmpHeight/2));
|
|
140 | 144 |
|
141 | 145 |
mSuccess.swirl( 30, mRegion, mPoint ); |
142 | 146 |
mSuccess.deform(vDown, pDown, 2000, 0.0f); |
143 | 147 |
|
144 | 148 |
// Now try adding 1 Fragment Effect. Likewise, will fail if maxFragmentEffects is <1. |
145 |
Float3D color = new Float3D(1,0,0);
|
|
146 |
Interpolator1D inter = new Interpolator1D();
|
|
149 |
Static3D color = new Static3D(1,0,0);
|
|
150 |
Dynamic1D inter = new Dynamic1D();
|
|
147 | 151 |
inter.setCount(0.0f); |
148 | 152 |
inter.setDuration(2000); |
149 |
inter.add(new Float1D(0));
|
|
150 |
inter.add(new Float1D(1));
|
|
153 |
inter.add(new Static1D(0));
|
|
154 |
inter.add(new Static1D(1));
|
|
151 | 155 |
|
152 |
mSuccess.chroma(inter, color, null, new Float2D(0,0) );
|
|
156 |
mSuccess.chroma(inter, color, null, new Static2D(0,0) );
|
|
153 | 157 |
|
154 | 158 |
try |
155 | 159 |
{ |
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.