Revision c7a31368
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
58 | 58 |
private static final Object lock = new Object(); |
59 | 59 |
|
60 | 60 |
private Dynamic3D mCenter; |
61 |
private Static4D mRegionVertex; |
|
62 |
private Static3D mRegionFragment; |
|
63 |
|
|
64 | 61 |
private Paint mPaint; |
65 | 62 |
private int moving; |
66 | 63 |
private int mScrWidth, mScrHeight; |
... | ... | |
89 | 86 |
mPaint.setStyle(Style.FILL); |
90 | 87 |
moving = -1; |
91 | 88 |
|
92 |
mCenter = new Dynamic3D(LOOP_TIME,0.0f); |
|
93 |
mRegionFragment = new Static3D(0,0,0); |
|
94 |
mRegionVertex = new Static4D(0,0,0,0); |
|
95 |
mDeform = new Static3D(0,0,0); |
|
89 |
mCenter = new Dynamic3D(LOOP_TIME,0.0f); |
|
90 |
mDeform = new Static3D(0,0,0.15f); |
|
96 | 91 |
|
97 | 92 |
if(!isInEditMode()) |
98 | 93 |
{ |
... | ... | |
105 | 100 |
setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 ); |
106 | 101 |
setRenderer(mRenderer); |
107 | 102 |
|
108 |
mEffectDeform = new VertexEffectDeform ( mDeform , mCenter, mRegionVertex); |
|
109 |
mEffectSink = new VertexEffectSink (new Static1D(10) , mCenter, mRegionVertex); |
|
110 |
mEffectSwirl = new VertexEffectSwirl (new Static1D(30) , mCenter, mRegionVertex); |
|
111 |
mEffectAlpha = new FragmentEffectAlpha (new Static1D(0.5f), mCenter, mRegionFragment, true); |
|
112 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mCenter, mRegionFragment, true); |
|
103 |
Static3D regionFrag = new Static3D(0.15f,0.15f,0.15f); |
|
104 |
Static4D regionVert = new Static4D(0,0,0,0.15f); |
|
105 |
|
|
106 |
mEffectDeform = new VertexEffectDeform ( mDeform , mCenter, regionVert); |
|
107 |
mEffectSink = new VertexEffectSink (new Static1D(10) , mCenter, regionVert); |
|
108 |
mEffectSwirl = new VertexEffectSwirl (new Static1D(30) , mCenter, regionVert); |
|
109 |
mEffectAlpha = new FragmentEffectAlpha (new Static1D(0.5f), mCenter, regionFrag, true); |
|
110 |
mEffectChroma = new FragmentEffectChroma(new Static1D(0.5f), new Static3D(1,0,0), mCenter, regionFrag, true); |
|
113 | 111 |
} |
114 | 112 |
} |
115 | 113 |
|
... | ... | |
124 | 122 |
|
125 | 123 |
mSize1 = max/200; |
126 | 124 |
mSize2 = max/80; |
127 |
int rad= max/6; |
|
128 |
|
|
129 |
mRegionVertex.set(0,0,0,rad); |
|
130 |
mRegionFragment.set(rad,rad,rad); |
|
131 |
mDeform.set2(max/7); |
|
132 | 125 |
} |
133 | 126 |
|
134 | 127 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
246 | 239 |
|
247 | 240 |
if( len>=2 ) |
248 | 241 |
{ |
249 |
float step = (float)LOOP_TIME/(NUM_POINTS+1); |
|
242 |
final float step = (float)LOOP_TIME/(NUM_POINTS+1);
|
|
250 | 243 |
|
251 | 244 |
for(int i=0; i<NUM_POINTS; i++) |
252 | 245 |
{ |
253 | 246 |
mPaint.setColor( 0xffffffff ); |
254 | 247 |
mCenter.get( drawCoord, 0, (long)(i*step) ); |
255 |
c.drawCircle(drawCoord[0] + mScrWidth*0.5f, mScrHeight*0.5f - drawCoord[1], mSize1, mPaint );
|
|
248 |
c.drawCircle( (drawCoord[0]+0.5f)*mScrWidth, mScrHeight*(0.5f-drawCoord[1]), mSize1, mPaint );
|
|
256 | 249 |
} |
257 | 250 |
} |
258 | 251 |
|
... | ... | |
261 | 254 |
for(int curr=0; curr<len; curr++) |
262 | 255 |
{ |
263 | 256 |
cu = mCenter.getPoint(curr); |
264 |
c.drawCircle(cu.get0() + mScrWidth*0.5f, mScrHeight*0.5f - cu.get1(), mSize2, mPaint);
|
|
257 |
c.drawCircle( (cu.get0()+0.5f)*mScrWidth, mScrHeight*(0.5f-cu.get1()), mSize2, mPaint);
|
|
265 | 258 |
} |
266 | 259 |
|
267 | 260 |
if( time-mTime > LOOP_TIME ) mTime = time; |
... | ... | |
275 | 268 |
{ |
276 | 269 |
if( mCurrEffect!=EFFECT_POINTS ) return true; |
277 | 270 |
|
278 |
int xDown = (int)event.getX() - mScrWidth/2;
|
|
279 |
int yDown = mScrHeight/2 - (int)event.getY();
|
|
271 |
float xDown = event.getX()/mScrWidth - 0.5f;
|
|
272 |
float yDown = 0.5f - event.getY()/mScrHeight;
|
|
280 | 273 |
|
281 | 274 |
switch(event.getAction()) |
282 | 275 |
{ |
Also available in: Unified diff
Further corrections for the first apps.