Revision 7589635e
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/sink/SinkRenderer.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; |
|
33 |
import org.distorted.library.type.Static2D; |
|
34 |
import org.distorted.library.type.Static3D; |
|
35 |
import org.distorted.library.type.Static4D; |
|
35 | 36 |
|
36 | 37 |
import android.graphics.Bitmap; |
37 | 38 |
import android.graphics.BitmapFactory; |
... | ... | |
44 | 45 |
{ |
45 | 46 |
private GLSurfaceView mView; |
46 | 47 |
private DistortedBitmap sinkBmp; |
47 |
private Float2D pLeft, pRight;
|
|
48 |
private Float4D Region;
|
|
48 |
private Static2D pLeft, pRight;
|
|
49 |
private Static4D Region;
|
|
49 | 50 |
private int bmpHeight, bmpWidth; |
50 | 51 |
|
51 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
54 | 55 |
{ |
55 | 56 |
mView = v; |
56 | 57 |
|
57 |
pLeft = new Float2D(214, 206);
|
|
58 |
pRight= new Float2D(390, 212);
|
|
59 |
Region= new Float4D(0,0,60,60);
|
|
58 |
pLeft = new Static2D(214, 206);
|
|
59 |
pRight= new Static2D(390, 212);
|
|
60 |
Region= new Static4D(0,0,60,60);
|
|
60 | 61 |
} |
61 | 62 |
|
62 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
78 | 79 |
if( bmpHeight/bmpWidth > height/width ) |
79 | 80 |
{ |
80 | 81 |
int w = (height*bmpWidth)/bmpHeight; |
81 |
sinkBmp.move((width-w)/2 ,0, 0); |
|
82 |
sinkBmp.scale((float)height/bmpHeight); |
|
82 |
float factor = (float)height/bmpHeight; |
|
83 |
|
|
84 |
sinkBmp.move( new Static3D((width-w)/2,0,0) ); |
|
85 |
sinkBmp.scale( new Static3D(factor,factor,factor) ); |
|
83 | 86 |
} |
84 | 87 |
else |
85 | 88 |
{ |
86 | 89 |
int h = (width*bmpHeight)/bmpWidth; |
87 |
sinkBmp.move(0 ,(height-h)/2, 0); |
|
88 |
sinkBmp.scale((float)width/bmpWidth); |
|
90 |
float factor = (float)width/bmpWidth; |
|
91 |
|
|
92 |
sinkBmp.move( new Static3D(0,(height-h)/2,0) ); |
|
93 |
sinkBmp.scale( new Static3D(factor,factor,factor) ); |
|
89 | 94 |
} |
90 | 95 |
|
91 | 96 |
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.