Revision 59759251
Added by Leszek Koltunski over 8 years ago
src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
---|---|---|
153 | 153 |
inter.add(new Static1D(0)); |
154 | 154 |
inter.add(new Static1D(1)); |
155 | 155 |
|
156 |
mSuccess.chroma(inter, color, null, new Static2D(0,0) );
|
|
156 |
mSuccess.chroma(inter, color); |
|
157 | 157 |
|
158 | 158 |
try |
159 | 159 |
{ |
src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.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.Dynamic1D; |
|
33 | 34 |
import org.distorted.library.type.Dynamic3D; |
35 |
import org.distorted.library.type.Static1D; |
|
34 | 36 |
import org.distorted.library.type.Static2D; |
35 | 37 |
import org.distorted.library.type.Static3D; |
36 | 38 |
import org.distorted.library.type.Static4D; |
... | ... | |
163 | 165 |
bmp[0].sink(10.0f, RegionEye, pLeft , 2000, 0.0f); |
164 | 166 |
bmp[0].sink(10.0f, RegionEye, pRight, 2000, 0.0f); |
165 | 167 |
bmp[1].distort(mDI, pNose1); |
166 |
bmp[2].macroblock(50, 3000, 0.0f); |
|
168 |
|
|
169 |
Dynamic1D macroblockDyn = new Dynamic1D(); |
|
170 |
macroblockDyn.setDuration(3000); |
|
171 |
macroblockDyn.setCount(0); |
|
172 |
macroblockDyn.add(new Static1D(1)); |
|
173 |
macroblockDyn.add(new Static1D(50)); |
|
174 |
|
|
175 |
bmp[2].macroblock(macroblockDyn); |
|
167 | 176 |
|
168 | 177 |
try |
169 | 178 |
{ |
src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
---|---|---|
31 | 31 |
import org.distorted.library.Distorted; |
32 | 32 |
import org.distorted.library.DistortedBitmap; |
33 | 33 |
import org.distorted.library.EffectTypes; |
34 |
import org.distorted.library.type.Dynamic1D; |
|
35 |
import org.distorted.library.type.Static1D; |
|
34 | 36 |
import org.distorted.library.type.Static2D; |
35 | 37 |
import org.distorted.library.type.Static3D; |
36 | 38 |
|
... | ... | |
133 | 135 |
mText.move( new Static3D(lisaWidth/6,lisaHeight/3,0) ); |
134 | 136 |
mText.scale( new Static3D(factor,factor,factor) ); |
135 | 137 |
mText.sink(0.5f, new Static2D( textWidth/2, textHeight/2), 5000, 0.0f); |
136 |
mLisa.macroblock(4, 10000, 0.0f); |
|
138 |
|
|
139 |
Dynamic1D macroblockDyn = new Dynamic1D(); |
|
140 |
macroblockDyn.setDuration(10000); |
|
141 |
macroblockDyn.setCount(0); |
|
142 |
macroblockDyn.add(new Static1D(1)); |
|
143 |
macroblockDyn.add(new Static1D(5)); |
|
144 |
|
|
145 |
mLisa.macroblock(macroblockDyn); |
|
137 | 146 |
|
138 | 147 |
try |
139 | 148 |
{ |
src/main/java/org/distorted/examples/macroblock/MacroblockRenderer.java | ||
---|---|---|
47 | 47 |
{ |
48 | 48 |
private GLSurfaceView mView; |
49 | 49 |
private DistortedBitmap macroblock; |
50 |
private Static4D Region; |
|
50 |
private Static4D macRegion, alphaRegion;
|
|
51 | 51 |
private int bmpHeight, bmpWidth; |
52 |
private Static2D traP, macP; |
|
53 |
|
|
52 |
|
|
54 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
55 | 54 |
|
56 | 55 |
public MacroblockRenderer(GLSurfaceView v) |
57 | 56 |
{ |
58 | 57 |
mView = v; |
59 | 58 |
|
60 |
Region = new Static4D(0,0,100,100); |
|
61 |
macP = new Static2D(530,200); |
|
62 |
traP = new Static2D(230,200); |
|
59 |
macRegion = new Static4D( 530, 200,100,100); |
|
60 |
alphaRegion = new Static4D( 230, 200,100,100); |
|
63 | 61 |
} |
64 | 62 |
|
65 | 63 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
95 | 93 |
bmpHeight = bitmap.getHeight(); |
96 | 94 |
bmpWidth = bitmap.getWidth(); |
97 | 95 |
|
98 |
macroblock = new DistortedBitmap(bitmap, 30); |
|
99 |
macroblock.macroblock( 30, Region, macP, 3000, 0.0f); |
|
100 |
macroblock.alpha (0.0f, Region, traP, 3000, 0.0f); |
|
96 |
macroblock = new DistortedBitmap(bitmap, 30); |
|
97 |
|
|
98 |
Dynamic1D macroblockDyn = new Dynamic1D(); |
|
99 |
macroblockDyn.setDuration(3000); |
|
100 |
macroblockDyn.setCount(0); |
|
101 |
macroblockDyn.add(new Static1D( 1)); |
|
102 |
macroblockDyn.add(new Static1D(30)); |
|
103 |
|
|
104 |
macroblock.macroblock(macroblockDyn, macRegion); |
|
105 |
|
|
106 |
Dynamic1D alphaDyn = new Dynamic1D(); |
|
107 |
alphaDyn.setDuration(3000); |
|
108 |
alphaDyn.setCount(0); |
|
109 |
alphaDyn.add(new Static1D(1)); |
|
110 |
alphaDyn.add(new Static1D(0)); |
|
111 |
|
|
112 |
macroblock.alpha( alphaDyn, alphaRegion, false ); |
|
101 | 113 |
|
102 | 114 |
try |
103 | 115 |
{ |
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; |
src/main/java/org/distorted/examples/olimpic/OlimpicRenderer.java | ||
---|---|---|
34 | 34 |
import org.distorted.library.type.Static1D; |
35 | 35 |
import org.distorted.library.Distorted; |
36 | 36 |
import org.distorted.library.DistortedBitmap; |
37 |
import org.distorted.library.type.Static4D; |
|
37 | 38 |
|
38 | 39 |
import android.graphics.Bitmap; |
39 | 40 |
import android.graphics.BitmapFactory; |
... | ... | |
104 | 105 |
tmp = (DistortedBitmap)mCircleNode[i].getObject(); |
105 | 106 |
tmp.move( new Static3D(positions[2*i], positions[2*i+1], 0) ); |
106 | 107 |
tmp.rotate( center, mRot, axis ); |
107 |
tmp.chroma(0.8f, new Static3D(colors[3*i],colors[3*i+1], colors[3*i+2]));
|
|
108 |
tmp.chroma( new Static4D(0.8f, colors[3*i],colors[3*i+1], colors[3*i+2]) );
|
|
108 | 109 |
} |
109 | 110 |
} |
110 | 111 |
|
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; |
src/main/java/org/distorted/examples/starwars/StarWarsRenderer.java | ||
---|---|---|
182 | 182 |
Dynamic1D di = new Dynamic1D(); |
183 | 183 |
di.setDuration(randomTime); |
184 | 184 |
di.setCount(0.0f); |
185 |
di.setNoise(0.3f);
|
|
185 |
di.setNoise(0.5f);
|
|
186 | 186 |
di.add(new Static1D(randomAlpha1)); |
187 | 187 |
di.add(new Static1D(randomAlpha2)); |
188 | 188 |
|
189 |
mStars[i].alpha(di, null, new Static2D(0,0));
|
|
189 |
mStars[i].alpha(di); |
|
190 | 190 |
|
191 | 191 |
mRoot.attach(mStars[i]); |
192 | 192 |
} |
... | ... | |
202 | 202 |
|
203 | 203 |
mGFFA.move( new Static3D(w/5,h/3,0) ); |
204 | 204 |
mGFFA.scale( new Static3D(scale,scale,scale) ); |
205 |
mGFFA.alpha(di, null, new Static2D(0,0));
|
|
205 |
mGFFA.alpha(di); |
|
206 | 206 |
|
207 | 207 |
mRoot.attach(mGFFA); |
208 | 208 |
mGFFA.addEventListener(this); |
... | ... | |
384 | 384 |
mCrawlBackground.move( new Static3D(0,screenH-backH,0) ); |
385 | 385 |
mCrawlBackground.rotate(new Static3D(screenW/2,backH,0), new Static1D(CRAWL_ANGLE), new Static3D(1,0,0) ); |
386 | 386 |
|
387 |
final int transpDistance = 5; |
|
388 |
mCrawlBackground.smooth_alpha((1-transpDistance/2)*1.0f, new Static4D(0,0,transpDistance*backH,transpDistance*backH), new Static2D(screenW/2,(1-transpDistance)*backH)); |
|
387 |
final int transpDist = 5; |
|
388 |
Static4D region = new Static4D(screenW/2,(1-transpDist)*backH,transpDist*backH,transpDist*backH); |
|
389 |
mCrawlBackground.alpha(new Static1D(1-transpDist/2), region, true); |
|
389 | 390 |
|
390 | 391 |
mCrawl.move(di); |
391 | 392 |
mCrawl.scale( new Static3D(scale,scale,scale) ); |
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.