Revision 59759251
Added by Leszek Koltunski almost 8 years ago
src/main/java/org/distorted/examples/scratchpad/ScratchpadSurfaceView.java | ||
---|---|---|
25 | 25 |
import android.view.MotionEvent; |
26 | 26 |
import android.util.AttributeSet; |
27 | 27 |
|
28 |
import org.distorted.library.type.Dynamic1D; |
|
29 |
import org.distorted.library.type.Static1D; |
|
28 | 30 |
import org.distorted.library.type.Static2D; |
29 | 31 |
import org.distorted.library.type.Static3D; |
30 | 32 |
import org.distorted.library.type.Static4D; |
... | ... | |
42 | 44 |
|
43 | 45 |
private static Static4D region; |
44 | 46 |
private static Static2D point; |
45 |
|
|
46 |
private static Dynamic3D di; |
|
47 |
|
|
48 |
private static Static4D mRegion; |
|
49 |
private static Dynamic1D mInterA, mInterM, mInterB; |
|
50 |
|
|
51 |
private static Dynamic3D mInterD; |
|
47 | 52 |
private static Static3D v0, v1, v2, v3; |
48 | 53 |
|
49 | 54 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
55 | 60 |
mDuration = 10000; |
56 | 61 |
mCount = 1.0f; |
57 | 62 |
|
58 |
di = new Dynamic3D(); |
|
63 |
mInterD = new Dynamic3D(); |
|
64 |
mInterD.setDuration(mDuration); |
|
65 |
mInterD.setCount(mCount); |
|
66 |
|
|
67 |
int h = 30; |
|
68 |
int r = 20; |
|
69 |
|
|
70 |
v0 = new Static3D( 0, r, h ); |
|
71 |
v1 = new Static3D(-r, 0, h ); |
|
72 |
v2 = new Static3D( 0,-r, h ); |
|
73 |
v3 = new Static3D( r, 0, h ); |
|
74 |
|
|
75 |
mInterD.add(v0); |
|
76 |
mInterD.add(v1); |
|
77 |
mInterD.add(v2); |
|
78 |
mInterD.add(v3); |
|
79 |
|
|
80 |
mInterA = new Dynamic1D(); |
|
81 |
mInterA.setDuration(mDuration); |
|
82 |
mInterA.setCount(mCount); |
|
83 |
mInterA.add(new Static1D(1)); |
|
84 |
mInterA.add(new Static1D(0)); |
|
85 |
|
|
86 |
mInterB = new Dynamic1D(); |
|
87 |
mInterB.setDuration(mDuration); |
|
88 |
mInterB.setCount(mCount); |
|
89 |
mInterB.add(new Static1D(1)); |
|
90 |
mInterB.add(new Static1D(0)); |
|
91 |
|
|
92 |
mInterM = new Dynamic1D(); |
|
93 |
mInterM.setDuration(mDuration); |
|
94 |
mInterM.setCount(mCount); |
|
95 |
mInterM.add(new Static1D(1)); |
|
96 |
mInterM.add(new Static1D(10)); |
|
59 | 97 |
|
60 |
di.setDuration(mDuration); |
|
61 |
di.setCount(mCount); |
|
62 |
|
|
63 | 98 |
if(!isInEditMode()) |
64 | 99 |
{ |
65 | 100 |
setFocusable(true); |
... | ... | |
77 | 112 |
|
78 | 113 |
point = new Static2D(0,0); |
79 | 114 |
region= new Static4D(0,0,60,60); |
80 |
|
|
81 |
int h = 30; |
|
82 |
int r = 20; |
|
83 |
|
|
84 |
v0 = new Static3D( 0, r, h ); |
|
85 |
v1 = new Static3D(-r, 0, h ); |
|
86 |
v2 = new Static3D( 0,-r, h ); |
|
87 |
v3 = new Static3D( r, 0, h ); |
|
88 |
|
|
89 |
di.add(v0); |
|
90 |
di.add(v1); |
|
91 |
di.add(v2); |
|
92 |
di.add(v3); |
|
115 |
mRegion = new Static4D(0,0,60,60); |
|
93 | 116 |
|
94 | 117 |
setEffect(0); |
95 | 118 |
} |
... | ... | |
122 | 145 |
public static void setDuration(int duration) |
123 | 146 |
{ |
124 | 147 |
mDuration = duration; |
125 |
di.setDuration(duration); |
|
148 |
mInterD.setDuration(duration); |
|
149 |
mInterA.setDuration(duration); |
|
150 |
mInterB.setDuration(duration); |
|
151 |
mInterM.setDuration(duration); |
|
126 | 152 |
} |
127 | 153 |
|
128 | 154 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
130 | 156 |
public static void setCount(float count) |
131 | 157 |
{ |
132 | 158 |
mCount = count; |
133 |
di.setCount(count); |
|
159 |
mInterD.setCount(count); |
|
160 |
mInterA.setCount(count); |
|
161 |
mInterB.setCount(count); |
|
162 |
mInterM.setCount(count); |
|
134 | 163 |
} |
135 | 164 |
|
136 | 165 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
145 | 174 |
case MotionEvent.ACTION_DOWN: x = (int)event.getX()*ScratchpadRenderer.BWID/mScrW; |
146 | 175 |
y = (int)event.getY()*ScratchpadRenderer.BHEI/mScrH; |
147 | 176 |
point.set(x,y); |
148 |
|
|
177 |
mRegion.set(x,y,60,60); |
|
178 |
|
|
149 | 179 |
switch(mCurrentEffect) |
150 | 180 |
{ |
151 |
case 0: ScratchpadRenderer.mBackground.distort(di, region, point);
|
|
181 |
case 0: ScratchpadRenderer.mBackground.distort(mInterD, region, point);
|
|
152 | 182 |
break; |
153 | 183 |
case 1: ScratchpadRenderer.mBackground.sink(0.3f, region, point, mDuration, mCount); |
154 | 184 |
break; |
155 |
case 2: ScratchpadRenderer.mBackground.alpha(0.0f, region, point, mDuration, mCount);
|
|
185 |
case 2: ScratchpadRenderer.mBackground.alpha(mInterA, mRegion, false);
|
|
156 | 186 |
break; |
157 |
case 3: ScratchpadRenderer.mBackground.macroblock(10, region, point, mDuration, mCount);
|
|
187 |
case 3: ScratchpadRenderer.mBackground.macroblock(mInterM, mRegion);
|
|
158 | 188 |
break; |
159 |
case 4: ScratchpadRenderer.mBackground.brightness(0.0f, region, point, mDuration, mCount);
|
|
189 |
case 4: ScratchpadRenderer.mBackground.brightness(mInterB, mRegion, false);
|
|
160 | 190 |
break; |
161 | 191 |
} |
162 | 192 |
break; |
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.