Revision 59759251
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/movingeffects/MovingEffectsSurfaceView.java | ||
---|---|---|
29 | 29 |
import android.util.AttributeSet; |
30 | 30 |
|
31 | 31 |
import org.distorted.library.EffectTypes; |
32 |
import org.distorted.library.type.Dynamic1D; |
|
32 | 33 |
import org.distorted.library.type.Dynamic2D; |
33 | 34 |
import org.distorted.library.type.Dynamic3D; |
35 |
import org.distorted.library.type.Dynamic4D; |
|
36 |
import org.distorted.library.type.Static1D; |
|
34 | 37 |
import org.distorted.library.type.Static2D; |
35 | 38 |
import org.distorted.library.type.Static3D; |
36 | 39 |
import org.distorted.library.type.Static4D; |
... | ... | |
53 | 56 |
|
54 | 57 |
private static int xDown,yDown; |
55 | 58 |
private static int mScrW, mScrH; |
56 |
|
|
59 |
|
|
60 |
private static Dynamic1D macroDyn, alphaDyn; |
|
57 | 61 |
private static Dynamic2D di2D; |
58 | 62 |
private static Dynamic3D di3D; |
59 | 63 |
private static Static4D dr; |
60 |
|
|
64 |
|
|
65 |
private static Dynamic4D mRegion; |
|
66 |
|
|
61 | 67 |
private static Paint mPaint; |
62 | 68 |
private static int moving; |
63 | 69 |
private static Object lock = new Object(); |
... | ... | |
70 | 76 |
public MovingEffectsSurfaceView(Context c, AttributeSet attrs) |
71 | 77 |
{ |
72 | 78 |
super(c, attrs); |
73 |
|
|
79 |
|
|
80 |
macroDyn = new Dynamic1D(); |
|
81 |
macroDyn.setDuration(0); |
|
82 |
macroDyn.setCount(0.5f); |
|
83 |
macroDyn.add(new Static1D(1)); |
|
84 |
macroDyn.add(new Static1D(3)); |
|
85 |
|
|
86 |
alphaDyn = new Dynamic1D(); |
|
87 |
alphaDyn.setDuration(0); |
|
88 |
alphaDyn.setCount(0.5f); |
|
89 |
alphaDyn.add(new Static1D(1.0f)); |
|
90 |
alphaDyn.add(new Static1D(0.5f)); |
|
91 |
|
|
74 | 92 |
mCurrEffect=EFFECT_POINTS; |
75 | 93 |
mPaint = new Paint(); |
76 | 94 |
mPaint.setStyle(Style.FILL); |
... | ... | |
85 | 103 |
di3D.add(new Static3D(0,0,30)); |
86 | 104 |
|
87 | 105 |
dr = new Static4D(0,0,60,60); |
88 |
|
|
106 |
|
|
107 |
mRegion = new Dynamic4D(); |
|
108 |
mRegion.setCount(0); |
|
109 |
mRegion.setDuration(LOOP_TIME); |
|
110 |
|
|
89 | 111 |
if(!isInEditMode()) |
90 | 112 |
{ |
91 | 113 |
setFocusable(true); |
... | ... | |
158 | 180 |
{ |
159 | 181 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX); |
160 | 182 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT); |
161 |
MovingEffectsRenderer.mBackground.macroblock(3, dr, di2D, 0, 0.5f);
|
|
183 |
MovingEffectsRenderer.mBackground.macroblock(macroDyn, mRegion);
|
|
162 | 184 |
mCurrEffect = EFFECT_MACRO; |
163 | 185 |
} |
164 | 186 |
} |
... | ... | |
173 | 195 |
{ |
174 | 196 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX); |
175 | 197 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT); |
176 |
MovingEffectsRenderer.mBackground.smooth_alpha(0.5f, dr, di2D, 0, 0.5f);
|
|
198 |
MovingEffectsRenderer.mBackground.alpha(alphaDyn, mRegion, true);
|
|
177 | 199 |
mCurrEffect = EFFECT_TRANS; |
178 | 200 |
} |
179 | 201 |
} |
... | ... | |
202 | 224 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.VERTEX); |
203 | 225 |
MovingEffectsRenderer.mBackground.abortEffects(EffectTypes.FRAGMENT); |
204 | 226 |
di2D.removeAll(); |
227 |
mRegion.removeAll(); |
|
205 | 228 |
mCurrEffect = EFFECT_POINTS; |
206 | 229 |
} |
207 | 230 |
} |
... | ... | |
274 | 297 |
synchronized(lock) |
275 | 298 |
{ |
276 | 299 |
di2D.add(new Static2D(xDown,yDown)); |
300 |
mRegion.add(new Static4D(xDown,yDown,60,60)); |
|
277 | 301 |
} |
278 | 302 |
} |
279 | 303 |
break; |
... | ... | |
282 | 306 |
xDown = (int)event.getX()*MovingEffectsRenderer.BWID/mScrW; |
283 | 307 |
yDown = (int)event.getY()*MovingEffectsRenderer.BHEI/mScrH; |
284 | 308 |
di2D.setPoint(moving, xDown, yDown); |
309 |
mRegion.setPoint(moving, xDown, yDown, 60, 60); |
|
285 | 310 |
} |
286 | 311 |
break; |
287 | 312 |
case MotionEvent.ACTION_UP : moving = -1; |
Also available in: Unified diff
Major push towards simplifying DistortedObject's public API.
All Fragment effects are using the new API - the 'DataND' marker interfaces.