Revision f988589e
Added by Leszek Koltunski over 9 years ago
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 21 | 21 |
<activity android:name=".fov.FOVActivity" /> |
| 22 | 22 |
<activity android:name=".deform.DeformActivity" /> |
| 23 | 23 |
<activity android:name=".listener.ListenerActivity" /> |
| 24 |
<activity android:name=".interpolator.InterpolatorActivity" />
|
|
| 24 |
<activity android:name=".dynamic.DynamicActivity" />
|
|
| 25 | 25 |
<activity android:name=".girl.GirlActivity" /> |
| 26 | 26 |
<activity android:name=".macroblock.MacroblockActivity" /> |
| 27 | 27 |
<activity android:name=".movingeffects.MovingEffectsActivity" /> |
| src/main/java/org/distorted/examples/TableOfContents.java | ||
|---|---|---|
| 39 | 39 |
import org.distorted.examples.fov.FOVActivity; |
| 40 | 40 |
import org.distorted.examples.deform.DeformActivity; |
| 41 | 41 |
import org.distorted.examples.listener.ListenerActivity; |
| 42 |
import org.distorted.examples.interpolator.InterpolatorActivity;
|
|
| 42 |
import org.distorted.examples.dynamic.DynamicActivity;
|
|
| 43 | 43 |
import org.distorted.examples.girl.GirlActivity; |
| 44 | 44 |
import org.distorted.examples.macroblock.MacroblockActivity; |
| 45 | 45 |
import org.distorted.examples.movingeffects.MovingEffectsActivity; |
| ... | ... | |
| 135 | 135 |
|
| 136 | 136 |
{
|
| 137 | 137 |
final Map<String, Object> item = new HashMap<>(); |
| 138 |
item.put(ITEM_IMAGE, R.drawable.icon_example_interpolator);
|
|
| 139 |
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_interpolator));
|
|
| 140 |
item.put(ITEM_SUBTITLE, getText(R.string.example_interpolator_subtitle));
|
|
| 138 |
item.put(ITEM_IMAGE, R.drawable.icon_example_dynamic);
|
|
| 139 |
item.put(ITEM_TITLE, (i+1)+". "+getText(R.string.example_dynamic));
|
|
| 140 |
item.put(ITEM_SUBTITLE, getText(R.string.example_dynamic_subtitle));
|
|
| 141 | 141 |
data.add(item); |
| 142 |
activityMapping.put(i++, InterpolatorActivity.class);
|
|
| 142 |
activityMapping.put(i++, DynamicActivity.class);
|
|
| 143 | 143 |
} |
| 144 | 144 |
|
| 145 | 145 |
{
|
| src/main/java/org/distorted/examples/bean/BeanRenderer.java | ||
|---|---|---|
| 28 | 28 |
import org.distorted.examples.R; |
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.library.EffectTypes; |
| 31 |
import org.distorted.library.type.Dynamic2D; |
|
| 32 | 31 |
import org.distorted.library.Distorted; |
| 33 | 32 |
import org.distorted.library.DistortedBitmap; |
| 34 | 33 |
import org.distorted.library.type.Dynamic3D; |
| ... | ... | |
| 64 | 63 |
rLeft = new Static4D(-9,-31,35,35); |
| 65 | 64 |
rRight= new Static4D(-9,-31,35,35); |
| 66 | 65 |
|
| 67 |
dLeft = new Dynamic3D(); |
|
| 68 |
dRight= new Dynamic3D(); |
|
| 69 |
|
|
| 70 |
dLeft.setCount(0.0f); |
|
| 71 |
dRight.setCount(0.0f); |
|
| 72 |
dLeft.setDuration(1500); |
|
| 73 |
dRight.setDuration(1500); |
|
| 74 |
|
|
| 66 |
dLeft = new Dynamic3D(1500,0.0f); |
|
| 67 |
dRight= new Dynamic3D(1500,0.0f); |
|
| 68 |
|
|
| 75 | 69 |
Static3D p1 = new Static3D( 0, 0, 0); |
| 76 | 70 |
Static3D p2 = new Static3D(-10,-34, 0); |
| 77 | 71 |
|
| ... | ... | |
| 112 | 106 |
float factor = (float)height/bmpHeight; |
| 113 | 107 |
|
| 114 | 108 |
mBean.move( new Static3D((width-w)/2,0,0) ); |
| 115 |
mBean.scale( new Static3D(factor,factor,factor) );
|
|
| 109 |
mBean.scale(factor);
|
|
| 116 | 110 |
} |
| 117 | 111 |
else |
| 118 | 112 |
{
|
| ... | ... | |
| 120 | 114 |
float factor = (float)width/bmpWidth; |
| 121 | 115 |
|
| 122 | 116 |
mBean.move( new Static3D(0,(height-h)/2,0) ); |
| 123 |
mBean.scale( new Static3D(factor,factor,factor) );
|
|
| 117 |
mBean.scale(factor);
|
|
| 124 | 118 |
} |
| 125 | 119 |
|
| 126 | 120 |
Distorted.onSurfaceChanged(width, height); |
| src/main/java/org/distorted/examples/check/CheckRenderer.java | ||
|---|---|---|
| 89 | 89 |
float factor = (float)height/bmpHeight; |
| 90 | 90 |
|
| 91 | 91 |
mSuccess.move( new Static3D((width-w)/2,0,0) ); |
| 92 |
mSuccess.scale( new Static3D(factor,factor,factor) );
|
|
| 92 |
mSuccess.scale(factor);
|
|
| 93 | 93 |
} |
| 94 | 94 |
else |
| 95 | 95 |
{
|
| ... | ... | |
| 97 | 97 |
float factor = (float)width/bmpWidth; |
| 98 | 98 |
|
| 99 | 99 |
mSuccess.move( new Static3D(0,(height-h)/2,0) ); |
| 100 |
mSuccess.scale( new Static3D(factor,factor,factor) );
|
|
| 100 |
mSuccess.scale(factor);
|
|
| 101 | 101 |
} |
| 102 | 102 |
|
| 103 | 103 |
Distorted.onSurfaceChanged(width, height); |
| ... | ... | |
| 134 | 134 |
// Even if adding some of the Effects fails, the App will still start - you just won't see |
| 135 | 135 |
// the effects that failed to add. |
| 136 | 136 |
|
| 137 |
Dynamic2D dSwirl = new Dynamic2D(); |
|
| 138 |
dSwirl.setCount(0.0f); |
|
| 139 |
dSwirl.setDuration(2000); |
|
| 137 |
Dynamic2D dSwirl = new Dynamic2D(2000,0.0f); |
|
| 140 | 138 |
dSwirl.add(new Static2D( 0, bmpHeight/2)); |
| 141 | 139 |
dSwirl.add(new Static2D( bmpWidth, bmpHeight/2)); |
| 142 | 140 |
|
| 143 | 141 |
mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) ); |
| 144 | 142 |
|
| 145 |
Dynamic3D dDeform = new Dynamic3D(); |
|
| 146 |
dDeform.setCount(0.0f); |
|
| 147 |
dDeform.setDuration(2000); |
|
| 143 |
Dynamic3D dDeform = new Dynamic3D(2000,0.0f); |
|
| 148 | 144 |
dDeform.add(new Static3D( 0, 0,0)); |
| 149 | 145 |
dDeform.add(new Static3D( 0,-bmpHeight,0)); |
| 150 | 146 |
|
| ... | ... | |
| 152 | 148 |
|
| 153 | 149 |
// Now try adding 1 Fragment Effect. Likewise, will fail if maxFragmentEffects is <1. |
| 154 | 150 |
Static3D color = new Static3D(1,0,0); |
| 155 |
Dynamic1D inter = new Dynamic1D(); |
|
| 156 |
inter.setCount(0.0f); |
|
| 157 |
inter.setDuration(2000); |
|
| 151 |
Dynamic1D inter = new Dynamic1D(2000,0.0f); |
|
| 158 | 152 |
inter.add(new Static1D(0)); |
| 159 | 153 |
inter.add(new Static1D(1)); |
| 160 | 154 |
|
| src/main/java/org/distorted/examples/cubes/CubesRenderer.java | ||
|---|---|---|
| 105 | 105 |
float factor = (float)height/(mRows*SIZE); |
| 106 | 106 |
|
| 107 | 107 |
mCubes.move( new Static3D((width-w)/2,0,0) ); |
| 108 |
mCubes.scale( new Static3D(factor,factor,factor) );
|
|
| 108 |
mCubes.scale(factor);
|
|
| 109 | 109 |
} |
| 110 | 110 |
else |
| 111 | 111 |
{
|
| ... | ... | |
| 113 | 113 |
float factor = (float)width/(mCols*SIZE); |
| 114 | 114 |
|
| 115 | 115 |
mCubes.move( new Static3D(0,(height-h)/2,0) ); |
| 116 |
mCubes.scale( new Static3D(factor,factor,factor) );
|
|
| 116 |
mCubes.scale(factor);
|
|
| 117 | 117 |
} |
| 118 | 118 |
|
| 119 | 119 |
Static3D center = new Static3D(mCols*SIZE/2,mRows*SIZE/2, 0); |
| src/main/java/org/distorted/examples/deform/DeformRenderer.java | ||
|---|---|---|
| 78 | 78 |
|
| 79 | 79 |
dr = new Static4D(0,0,0,0); |
| 80 | 80 |
|
| 81 |
mReleasedDynamic = new Dynamic3D(); |
|
| 81 |
mReleasedDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
|
|
| 82 | 82 |
mReleasedDynamic.setMode(Dynamic3D.MODE_PATH); |
| 83 |
mReleasedDynamic.setCount(0.5f); |
|
| 84 |
mReleasedDynamic.setDuration(NUM_VECTORS*500); |
|
| 85 | 83 |
|
| 86 |
mMovingDynamic = new Dynamic3D(); |
|
| 84 |
mMovingDynamic = new Dynamic3D(0,0.5f);
|
|
| 87 | 85 |
mMovingDynamic.setMode(Dynamic3D.MODE_PATH); |
| 88 |
mMovingDynamic.setCount(0.5f); |
|
| 89 |
mMovingDynamic.setDuration(0); |
|
| 90 | 86 |
|
| 91 | 87 |
v = new Static3D[NUM_VECTORS]; |
| 92 | 88 |
|
| src/main/java/org/distorted/examples/differentbitmaps/DifferentBitmapsRenderer.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.Dynamic2D; |
|
| 34 | 33 |
import org.distorted.library.type.Dynamic3D; |
| 35 | 34 |
import org.distorted.library.type.Static1D; |
| 36 | 35 |
import org.distorted.library.type.Static2D; |
| ... | ... | |
| 62 | 61 |
mView = v; |
| 63 | 62 |
|
| 64 | 63 |
// create shared effects - enlarge the nose and keep moving the whole bitmap left and right. |
| 65 |
dDistort = new Dynamic3D(); |
|
| 66 |
dDistort.setCount(0.0f); |
|
| 67 |
dDistort.setDuration(3000); |
|
| 64 |
dDistort = new Dynamic3D(3000,0.0f); |
|
| 68 | 65 |
vec = new Static3D[2]; |
| 69 | 66 |
vec[0] = new Static3D( 25,0,0); |
| 70 | 67 |
vec[1] = new Static3D(-25,0,0); |
| ... | ... | |
| 121 | 118 |
{
|
| 122 | 119 |
int w = (height*bmpWidth)/bmpHeight; |
| 123 | 120 |
float factor = (float)height/bmpHeight; |
| 124 |
Static3D scale = new Static3D(factor,factor,factor); |
|
| 125 | 121 |
|
| 126 | 122 |
for(int i=NUM-1; i>=0; i--) |
| 127 | 123 |
{
|
| 128 | 124 |
bmp[i].move( new Static3D((width-NUM*w)/2 +i*w ,0,0) ); |
| 129 |
bmp[i].scale(scale);
|
|
| 125 |
bmp[i].scale(factor);
|
|
| 130 | 126 |
} |
| 131 | 127 |
} |
| 132 | 128 |
else |
| ... | ... | |
| 134 | 130 |
int w = width/NUM; |
| 135 | 131 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
| 136 | 132 |
float factor = (float)width/(bmpWidth*NUM); |
| 137 |
Static3D scale = new Static3D(factor,factor,factor); |
|
| 138 | 133 |
|
| 139 | 134 |
for(int i=NUM-1; i>=0; i--) |
| 140 | 135 |
{
|
| 141 | 136 |
bmp[i].move( new Static3D(i*w,(height-h)/2,0) ); |
| 142 |
bmp[i].scale(scale);
|
|
| 137 |
bmp[i].scale(factor);
|
|
| 143 | 138 |
} |
| 144 | 139 |
} |
| 145 | 140 |
|
| src/main/java/org/distorted/examples/differenteffects/DifferentEffectsRenderer.java | ||
|---|---|---|
| 68 | 68 |
RegionEye = new Static4D(0,0,60,60); |
| 69 | 69 |
|
| 70 | 70 |
// bmp[1] effects |
| 71 |
mDI = new Dynamic3D(); |
|
| 72 |
mDI.setCount(0.0f); |
|
| 73 |
mDI.setDuration(1000); |
|
| 71 |
mDI = new Dynamic3D(1000,0.0f); |
|
| 74 | 72 |
vec = new Static3D[2]; |
| 75 | 73 |
vec[0] = new Static3D( 50,0,0); |
| 76 | 74 |
vec[1] = new Static3D(-50,0,0); |
| ... | ... | |
| 106 | 104 |
{
|
| 107 | 105 |
int w = (height*bmpWidth)/bmpHeight; |
| 108 | 106 |
float factor = (float)height/bmpHeight; |
| 109 |
Static3D scaleFactor = new Static3D(factor,factor,factor); |
|
| 110 | 107 |
|
| 111 | 108 |
for(int i=NUM-1; i>=0; i--) |
| 112 | 109 |
{
|
| 113 | 110 |
bmp[i].move( new Static3D((width-NUM*w)/2 +i*w , 0, 0) ); |
| 114 |
bmp[i].scale(scaleFactor);
|
|
| 111 |
bmp[i].scale(factor);
|
|
| 115 | 112 |
} |
| 116 | 113 |
} |
| 117 | 114 |
else |
| ... | ... | |
| 119 | 116 |
int w = width/NUM; |
| 120 | 117 |
int h = (width*bmpHeight)/(bmpWidth*NUM); |
| 121 | 118 |
float factor = (float)width/(bmpWidth*NUM); |
| 122 |
Static3D scaleFactor = new Static3D(factor,factor,factor); |
|
| 123 | 119 |
|
| 124 | 120 |
for(int i=NUM-1; i>=0; i--) |
| 125 | 121 |
{
|
| 126 | 122 |
bmp[i].move( new Static3D(i*w, (height-h)/2, 0) ); |
| 127 |
bmp[i].scale(scaleFactor);
|
|
| 123 |
bmp[i].scale(factor);
|
|
| 128 | 124 |
} |
| 129 | 125 |
} |
| 130 | 126 |
|
| ... | ... | |
| 162 | 158 |
// setting the bitmap once is enough; others are cloned! |
| 163 | 159 |
bmp[0].setBitmap(bitmap); |
| 164 | 160 |
|
| 165 |
Dynamic1D sink = new Dynamic1D(); |
|
| 166 |
sink.setDuration(2000); |
|
| 167 |
sink.setCount(0); |
|
| 161 |
Dynamic1D sink = new Dynamic1D(2000,0.0f); |
|
| 168 | 162 |
sink.add(new Static1D( 1)); |
| 169 | 163 |
sink.add(new Static1D(10)); |
| 170 | 164 |
|
| ... | ... | |
| 172 | 166 |
bmp[0].sink(sink, pRight,RegionEye); |
| 173 | 167 |
bmp[1].distort(mDI, pNose1); |
| 174 | 168 |
|
| 175 |
Dynamic1D macroblockDyn = new Dynamic1D(); |
|
| 176 |
macroblockDyn.setDuration(3000); |
|
| 177 |
macroblockDyn.setCount(0); |
|
| 169 |
Dynamic1D macroblockDyn = new Dynamic1D(3000,0.0f); |
|
| 178 | 170 |
macroblockDyn.add(new Static1D(1)); |
| 179 | 171 |
macroblockDyn.add(new Static1D(50)); |
| 180 | 172 |
|
| src/main/java/org/distorted/examples/dynamic/DynamicActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.dynamic; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.Distorted; |
|
| 23 |
import org.distorted.library.type.Dynamic1D; |
|
| 24 |
import org.distorted.examples.R; |
|
| 25 |
|
|
| 26 |
import android.app.Activity; |
|
| 27 |
import android.opengl.GLSurfaceView; |
|
| 28 |
import android.os.Bundle; |
|
| 29 |
import android.view.View; |
|
| 30 |
import android.widget.SeekBar; |
|
| 31 |
import android.widget.TextView; |
|
| 32 |
import android.widget.SeekBar.OnSeekBarChangeListener; |
|
| 33 |
|
|
| 34 |
/////////////////////////////////////////////////////////////////// |
|
| 35 |
|
|
| 36 |
public class DynamicActivity extends Activity implements OnSeekBarChangeListener |
|
| 37 |
{
|
|
| 38 |
private SeekBar barD, barN; |
|
| 39 |
private TextView textD, textN; |
|
| 40 |
|
|
| 41 |
/////////////////////////////////////////////////////////////////// |
|
| 42 |
@Override |
|
| 43 |
protected void onCreate(Bundle savedInstanceState) |
|
| 44 |
{
|
|
| 45 |
super.onCreate(savedInstanceState); |
|
| 46 |
setContentView(R.layout.interpolatorlayout); |
|
| 47 |
|
|
| 48 |
barD = (SeekBar)findViewById(R.id.interpolatorSeekDuration); |
|
| 49 |
barD.setOnSeekBarChangeListener(this); |
|
| 50 |
textD = (TextView)findViewById(R.id.interpolatorTextDuration); |
|
| 51 |
|
|
| 52 |
barN = (SeekBar)findViewById(R.id.interpolatorSeekNoise); |
|
| 53 |
barN.setOnSeekBarChangeListener(this); |
|
| 54 |
textN = (TextView)findViewById(R.id.interpolatorTextNoise); |
|
| 55 |
|
|
| 56 |
barD.setProgress(50); |
|
| 57 |
textD.setText("Duration: 10 s");
|
|
| 58 |
|
|
| 59 |
barN.setProgress(0); |
|
| 60 |
textN.setText("Noise: 0.0");
|
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
/////////////////////////////////////////////////////////////////// |
|
| 64 |
@Override |
|
| 65 |
protected void onResume() |
|
| 66 |
{
|
|
| 67 |
super.onResume(); |
|
| 68 |
|
|
| 69 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView); |
|
| 70 |
mView.onResume(); |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
/////////////////////////////////////////////////////////////////// |
|
| 74 |
@Override |
|
| 75 |
protected void onPause() |
|
| 76 |
{
|
|
| 77 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView); |
|
| 78 |
mView.onPause(); |
|
| 79 |
|
|
| 80 |
super.onPause(); |
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
/////////////////////////////////////////////////////////////////// |
|
| 84 |
@Override |
|
| 85 |
public void onStop() |
|
| 86 |
{
|
|
| 87 |
super.onStop(); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
/////////////////////////////////////////////////////////////////// |
|
| 91 |
@Override |
|
| 92 |
public void onDestroy() |
|
| 93 |
{
|
|
| 94 |
Distorted.onDestroy(); |
|
| 95 |
super.onDestroy(); |
|
| 96 |
} |
|
| 97 |
|
|
| 98 |
/////////////////////////////////////////////////////////////////// |
|
| 99 |
|
|
| 100 |
public void Loop(View v) |
|
| 101 |
{
|
|
| 102 |
DynamicSurfaceView.setMode(Dynamic1D.MODE_LOOP); |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
/////////////////////////////////////////////////////////////////// |
|
| 106 |
|
|
| 107 |
public void Path(View v) |
|
| 108 |
{
|
|
| 109 |
DynamicSurfaceView.setMode(Dynamic1D.MODE_PATH); |
|
| 110 |
} |
|
| 111 |
|
|
| 112 |
/////////////////////////////////////////////////////////////////// |
|
| 113 |
|
|
| 114 |
public void Jump(View v) |
|
| 115 |
{
|
|
| 116 |
DynamicSurfaceView.setMode(Dynamic1D.MODE_JUMP); |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
/////////////////////////////////////////////////////////////////// |
|
| 120 |
|
|
| 121 |
public void Dim1D(View v) |
|
| 122 |
{
|
|
| 123 |
DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_1D); |
|
| 124 |
} |
|
| 125 |
|
|
| 126 |
/////////////////////////////////////////////////////////////////// |
|
| 127 |
|
|
| 128 |
public void Dim2D(View v) |
|
| 129 |
{
|
|
| 130 |
DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_2D); |
|
| 131 |
} |
|
| 132 |
|
|
| 133 |
/////////////////////////////////////////////////////////////////// |
|
| 134 |
|
|
| 135 |
public void Dim3DXY(View v) |
|
| 136 |
{
|
|
| 137 |
DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXY); |
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
/////////////////////////////////////////////////////////////////// |
|
| 141 |
|
|
| 142 |
public void Dim3DXZ(View v) |
|
| 143 |
{
|
|
| 144 |
DynamicSurfaceView.setDimension(DynamicSurfaceView.DIM_3DXZ); |
|
| 145 |
} |
|
| 146 |
|
|
| 147 |
/////////////////////////////////////////////////////////////////// |
|
| 148 |
|
|
| 149 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
|
| 150 |
{
|
|
| 151 |
float v, t; |
|
| 152 |
int i; |
|
| 153 |
|
|
| 154 |
switch (bar.getId()) |
|
| 155 |
{
|
|
| 156 |
case R.id.interpolatorSeekDuration: v = progress*200; |
|
| 157 |
i = (int)(v/100); |
|
| 158 |
t = i/10.0f; |
|
| 159 |
DynamicSurfaceView.setDuration((int)v); |
|
| 160 |
textD.setText("Duration: "+(int)t+" s");
|
|
| 161 |
break; |
|
| 162 |
case R.id.interpolatorSeekNoise : DynamicSurfaceView.setNoise(progress/100.0f); |
|
| 163 |
textN.setText("Noise: "+(progress/100.f));
|
|
| 164 |
break; |
|
| 165 |
} |
|
| 166 |
} |
|
| 167 |
|
|
| 168 |
/////////////////////////////////////////////////////////////////// |
|
| 169 |
|
|
| 170 |
public void onStartTrackingTouch(SeekBar bar) { }
|
|
| 171 |
|
|
| 172 |
/////////////////////////////////////////////////////////////////// |
|
| 173 |
|
|
| 174 |
public void onStopTrackingTouch(SeekBar bar) { }
|
|
| 175 |
|
|
| 176 |
/////////////////////////////////////////////////////////////////// |
|
| 177 |
// end of file |
|
| 178 |
} |
|
| src/main/java/org/distorted/examples/dynamic/DynamicRenderer.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.dynamic; |
|
| 21 |
|
|
| 22 |
import javax.microedition.khronos.egl.EGLConfig; |
|
| 23 |
import javax.microedition.khronos.opengles.GL10; |
|
| 24 |
|
|
| 25 |
import android.graphics.Bitmap; |
|
| 26 |
import android.graphics.Canvas; |
|
| 27 |
import android.graphics.Paint; |
|
| 28 |
import android.graphics.Paint.Style; |
|
| 29 |
import android.opengl.GLES20; |
|
| 30 |
import android.opengl.GLSurfaceView; |
|
| 31 |
|
|
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 33 |
import org.distorted.library.Distorted; |
|
| 34 |
import org.distorted.library.EffectTypes; |
|
| 35 |
import org.distorted.library.type.Static3D; |
|
| 36 |
|
|
| 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 38 |
|
|
| 39 |
public class DynamicRenderer implements GLSurfaceView.Renderer |
|
| 40 |
{
|
|
| 41 |
public static final int BWID = 300; |
|
| 42 |
public static final int BHEI = 400; |
|
| 43 |
|
|
| 44 |
private GLSurfaceView mView; |
|
| 45 |
private DistortedBitmap mBackground; |
|
| 46 |
private Canvas mCanvas; |
|
| 47 |
private Bitmap mBitmap; |
|
| 48 |
private Paint mPaint; |
|
| 49 |
private int texWidth, texHeight; |
|
| 50 |
|
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public DynamicRenderer(GLSurfaceView v) |
|
| 54 |
{
|
|
| 55 |
mPaint = new Paint(); |
|
| 56 |
mPaint.setAntiAlias(true); |
|
| 57 |
mPaint.setFakeBoldText(true); |
|
| 58 |
mPaint.setColor(0xff447da7); |
|
| 59 |
mPaint.setStyle(Style.FILL); |
|
| 60 |
|
|
| 61 |
mView = v; |
|
| 62 |
|
|
| 63 |
texWidth = BWID; |
|
| 64 |
texHeight= BHEI; |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 68 |
|
|
| 69 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
| 70 |
{
|
|
| 71 |
mBackground = new DistortedBitmap(texWidth,texHeight, 2); |
|
| 72 |
mBitmap = Bitmap.createBitmap(texWidth,texHeight, Bitmap.Config.ARGB_8888); |
|
| 73 |
mCanvas = new Canvas(mBitmap); |
|
| 74 |
|
|
| 75 |
try |
|
| 76 |
{
|
|
| 77 |
Distorted.onSurfaceCreated(mView.getContext()); |
|
| 78 |
} |
|
| 79 |
catch(Exception ex) |
|
| 80 |
{
|
|
| 81 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
| 82 |
} |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 |
|
|
| 87 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
| 88 |
{
|
|
| 89 |
mBackground.abortEffects(EffectTypes.MATRIX); |
|
| 90 |
mBackground.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) ); |
|
| 91 |
Distorted.onSurfaceChanged(width, height); |
|
| 92 |
DynamicSurfaceView.setScreenSize(width,height); |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 96 |
|
|
| 97 |
public void onDrawFrame(GL10 glUnused) |
|
| 98 |
{
|
|
| 99 |
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); |
|
| 100 |
|
|
| 101 |
long time = System.currentTimeMillis(); |
|
| 102 |
|
|
| 103 |
mCanvas.drawRect(0, 0, texWidth, texHeight, mPaint); |
|
| 104 |
DynamicSurfaceView.drawCurve(mCanvas,time); |
|
| 105 |
mBackground.setBitmap(mBitmap); |
|
| 106 |
mBackground.draw(time); |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 110 |
} |
|
| src/main/java/org/distorted/examples/dynamic/DynamicSurfaceView.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.dynamic; |
|
| 21 |
|
|
| 22 |
import android.content.Context; |
|
| 23 |
import android.opengl.GLSurfaceView; |
|
| 24 |
import android.os.Build; |
|
| 25 |
import android.view.MotionEvent; |
|
| 26 |
import android.util.AttributeSet; |
|
| 27 |
import android.graphics.Canvas; |
|
| 28 |
import android.graphics.Paint.Style; |
|
| 29 |
import android.graphics.Paint; |
|
| 30 |
|
|
| 31 |
import org.distorted.library.type.Dynamic1D; |
|
| 32 |
import org.distorted.library.type.Dynamic2D; |
|
| 33 |
import org.distorted.library.type.Dynamic3D; |
|
| 34 |
import org.distorted.library.type.Static1D; |
|
| 35 |
import org.distorted.library.type.Static2D; |
|
| 36 |
import org.distorted.library.type.Static3D; |
|
| 37 |
|
|
| 38 |
/////////////////////////////////////////////////////////////////// |
|
| 39 |
|
|
| 40 |
public class DynamicSurfaceView extends GLSurfaceView |
|
| 41 |
{
|
|
| 42 |
public static final int DIM_1D = 0; |
|
| 43 |
public static final int DIM_2D = 1; |
|
| 44 |
public static final int DIM_3DXY = 2; |
|
| 45 |
public static final int DIM_3DXZ = 3; |
|
| 46 |
|
|
| 47 |
private static final int NUM_INTERPOLATIONS= 100; |
|
| 48 |
private static final int MAX_VECTORS = 6; |
|
| 49 |
|
|
| 50 |
private DynamicRenderer mRenderer; |
|
| 51 |
private static int xDown,yDown; |
|
| 52 |
private static int mScrW, mScrH; |
|
| 53 |
|
|
| 54 |
private static Dynamic1D di1D; |
|
| 55 |
private static Dynamic2D di2D; |
|
| 56 |
private static Dynamic3D di3D; |
|
| 57 |
|
|
| 58 |
private static Paint mPaint; |
|
| 59 |
private static int moving; |
|
| 60 |
private static Object lock = new Object(); |
|
| 61 |
private static long mTime = 0; |
|
| 62 |
private static int mDuration; |
|
| 63 |
private static float mPosition; |
|
| 64 |
private static float mNoise; |
|
| 65 |
|
|
| 66 |
private static int currentDim = DIM_2D; |
|
| 67 |
|
|
| 68 |
private static Static1D p1D; |
|
| 69 |
private static Static2D p2D; |
|
| 70 |
private static Static3D p3D; |
|
| 71 |
|
|
| 72 |
private static float[] mDrawCoord = new float[3]; |
|
| 73 |
|
|
| 74 |
/////////////////////////////////////////////////////////////////// |
|
| 75 |
|
|
| 76 |
public DynamicSurfaceView(Context c, AttributeSet attrs) |
|
| 77 |
{
|
|
| 78 |
super(c, attrs); |
|
| 79 |
|
|
| 80 |
mPaint = new Paint(); |
|
| 81 |
mPaint.setStyle(Style.FILL); |
|
| 82 |
mPaint.setAntiAlias(true); |
|
| 83 |
|
|
| 84 |
moving = -1; |
|
| 85 |
mDuration = 10000; |
|
| 86 |
mPosition = 0; |
|
| 87 |
mNoise = 0.0f; |
|
| 88 |
|
|
| 89 |
di1D = new Dynamic1D(mDuration,0.5f); |
|
| 90 |
di1D.setNoise(mNoise); |
|
| 91 |
|
|
| 92 |
di2D = new Dynamic2D(mDuration,0.5f); |
|
| 93 |
di2D.setNoise(mNoise); |
|
| 94 |
|
|
| 95 |
di3D = new Dynamic3D(mDuration,0.5f); |
|
| 96 |
di3D.setNoise(mNoise); |
|
| 97 |
|
|
| 98 |
if(!isInEditMode()) |
|
| 99 |
{
|
|
| 100 |
setFocusable(true); |
|
| 101 |
setFocusableInTouchMode(true); |
|
| 102 |
|
|
| 103 |
setEGLContextClientVersion(2); |
|
| 104 |
|
|
| 105 |
if( Build.FINGERPRINT.startsWith("generic") ) // when running on the emulator, insert a magic line that is
|
|
| 106 |
{ // supposed to cure the 'no config chosen' crash on emulator startup
|
|
| 107 |
setEGLConfigChooser(8, 8, 8, 8, 16, 0); |
|
| 108 |
} |
|
| 109 |
|
|
| 110 |
mRenderer = new DynamicRenderer(this); |
|
| 111 |
setRenderer(mRenderer); |
|
| 112 |
} |
|
| 113 |
} |
|
| 114 |
|
|
| 115 |
/////////////////////////////////////////////////////////////////// |
|
| 116 |
|
|
| 117 |
public static void setMode(int mode) |
|
| 118 |
{
|
|
| 119 |
di1D.setMode(mode); |
|
| 120 |
di2D.setMode(mode); |
|
| 121 |
di3D.setMode(mode); |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
/////////////////////////////////////////////////////////////////// |
|
| 125 |
|
|
| 126 |
public static void setScreenSize(int width, int height) |
|
| 127 |
{
|
|
| 128 |
mScrW = width; |
|
| 129 |
mScrH = height; |
|
| 130 |
} |
|
| 131 |
|
|
| 132 |
/////////////////////////////////////////////////////////////////// |
|
| 133 |
|
|
| 134 |
public static void setDuration(int duration) |
|
| 135 |
{
|
|
| 136 |
mDuration = duration; |
|
| 137 |
|
|
| 138 |
di1D.setDuration(duration); |
|
| 139 |
di2D.setDuration(duration); |
|
| 140 |
di3D.setDuration(duration); |
|
| 141 |
} |
|
| 142 |
|
|
| 143 |
/////////////////////////////////////////////////////////////////// |
|
| 144 |
|
|
| 145 |
public static void setNoise(float noise) |
|
| 146 |
{
|
|
| 147 |
mNoise = noise; |
|
| 148 |
|
|
| 149 |
di1D.setNoise(noise); |
|
| 150 |
di2D.setNoise(noise); |
|
| 151 |
di3D.setNoise(noise); |
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
/////////////////////////////////////////////////////////////////// |
|
| 155 |
|
|
| 156 |
public static void setDimension(int dim) |
|
| 157 |
{
|
|
| 158 |
if( currentDim != dim ) |
|
| 159 |
{
|
|
| 160 |
if( !(currentDim==DIM_3DXY && dim==DIM_3DXZ) && !(currentDim==DIM_3DXZ && dim==DIM_3DXY) ) |
|
| 161 |
{
|
|
| 162 |
synchronized(lock) |
|
| 163 |
{
|
|
| 164 |
di1D.removeAll(); |
|
| 165 |
di2D.removeAll(); |
|
| 166 |
di3D.removeAll(); |
|
| 167 |
} |
|
| 168 |
} |
|
| 169 |
|
|
| 170 |
currentDim = dim; |
|
| 171 |
} |
|
| 172 |
} |
|
| 173 |
|
|
| 174 |
/////////////////////////////////////////////////////////////////// |
|
| 175 |
|
|
| 176 |
public static void drawCurve(Canvas c, long time) |
|
| 177 |
{
|
|
| 178 |
mPosition += (mTime>0 && mDuration>0) ? ((float)(time-mTime)*NUM_INTERPOLATIONS/mDuration) : 0; |
|
| 179 |
|
|
| 180 |
synchronized(lock) |
|
| 181 |
{
|
|
| 182 |
switch(currentDim) |
|
| 183 |
{
|
|
| 184 |
case DIM_1D: drawCurve1D(c,time); break; |
|
| 185 |
case DIM_2D: drawCurve2D(c,time); break; |
|
| 186 |
default : drawCurve3D(c,time); break; |
|
| 187 |
} |
|
| 188 |
} |
|
| 189 |
|
|
| 190 |
mTime = time; |
|
| 191 |
} |
|
| 192 |
|
|
| 193 |
/////////////////////////////////////////////////////////////////// |
|
| 194 |
|
|
| 195 |
private static void drawCurve1D(Canvas c, long time) |
|
| 196 |
{
|
|
| 197 |
int len = di1D.getNumPoints(); |
|
| 198 |
|
|
| 199 |
mPaint.setColor(0xff000000); |
|
| 200 |
|
|
| 201 |
c.drawLine(0, DynamicRenderer.BHEI/2, DynamicRenderer.BWID, DynamicRenderer.BHEI/2, mPaint); |
|
| 202 |
c.drawText("x", 0.95f* DynamicRenderer.BWID, 0.55f* DynamicRenderer.BHEI , mPaint);
|
|
| 203 |
|
|
| 204 |
if( len>=2 ) |
|
| 205 |
{
|
|
| 206 |
for(int i=0; i<NUM_INTERPOLATIONS; i++) |
|
| 207 |
{
|
|
| 208 |
int color = i<=mPosition ? 0xff - ((int)mPosition -i)*0xff/(NUM_INTERPOLATIONS-1) |
|
| 209 |
: 0xff - ((int)mPosition+NUM_INTERPOLATIONS-i)*0xff/(NUM_INTERPOLATIONS-1); |
|
| 210 |
|
|
| 211 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
|
| 212 |
di1D.interpolate(mDrawCoord,0, (float)i/NUM_INTERPOLATIONS); |
|
| 213 |
c.drawCircle(mDrawCoord[0], DynamicRenderer.BHEI/2 , 2.0f, mPaint ); |
|
| 214 |
} |
|
| 215 |
} |
|
| 216 |
|
|
| 217 |
mPaint.setColor(0xffff0000); |
|
| 218 |
|
|
| 219 |
for(int curr=0; curr<len; curr++) |
|
| 220 |
{
|
|
| 221 |
p1D = di1D.getPoint(curr); |
|
| 222 |
c.drawCircle(p1D.getX(), DynamicRenderer.BHEI/2 , 5.0f, mPaint); |
|
| 223 |
} |
|
| 224 |
} |
|
| 225 |
|
|
| 226 |
/////////////////////////////////////////////////////////////////// |
|
| 227 |
|
|
| 228 |
private static void drawCurve2D(Canvas c, long time) |
|
| 229 |
{
|
|
| 230 |
int len = di2D.getNumPoints(); |
|
| 231 |
|
|
| 232 |
mPaint.setColor(0xff000000); |
|
| 233 |
|
|
| 234 |
c.drawLine(0, DynamicRenderer.BHEI/2, DynamicRenderer.BWID, DynamicRenderer.BHEI/2, mPaint); |
|
| 235 |
c.drawLine(DynamicRenderer.BWID/2, 0, DynamicRenderer.BWID/2, DynamicRenderer.BHEI, mPaint); |
|
| 236 |
|
|
| 237 |
c.drawText("x", 0.95f* DynamicRenderer.BWID, 0.55f* DynamicRenderer.BHEI , mPaint);
|
|
| 238 |
c.drawText("y", 0.55f* DynamicRenderer.BWID, 0.05f* DynamicRenderer.BHEI , mPaint);
|
|
| 239 |
|
|
| 240 |
if( len>=2 ) |
|
| 241 |
{
|
|
| 242 |
for(int i=0; i<NUM_INTERPOLATIONS; i++) |
|
| 243 |
{
|
|
| 244 |
int color = i<=mPosition ? 0xff - ((int)mPosition -i)*0xff/(NUM_INTERPOLATIONS-1) |
|
| 245 |
: 0xff - ((int)mPosition+NUM_INTERPOLATIONS-i)*0xff/(NUM_INTERPOLATIONS-1); |
|
| 246 |
|
|
| 247 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
|
| 248 |
di2D.interpolate(mDrawCoord,0, (float)i/NUM_INTERPOLATIONS); |
|
| 249 |
c.drawCircle(mDrawCoord[0], mDrawCoord[1], 2.0f, mPaint ); |
|
| 250 |
} |
|
| 251 |
} |
|
| 252 |
|
|
| 253 |
mPaint.setColor(0xffff0000); |
|
| 254 |
|
|
| 255 |
for(int curr=0; curr<len; curr++) |
|
| 256 |
{
|
|
| 257 |
p2D = di2D.getPoint(curr); |
|
| 258 |
c.drawCircle(p2D.getX(),p2D.getY(), 5.0f, mPaint); |
|
| 259 |
} |
|
| 260 |
} |
|
| 261 |
|
|
| 262 |
/////////////////////////////////////////////////////////////////// |
|
| 263 |
|
|
| 264 |
private static void drawCurve3D(Canvas c, long time) |
|
| 265 |
{
|
|
| 266 |
int len = di3D.getNumPoints(); |
|
| 267 |
|
|
| 268 |
mPaint.setColor(0xff000000); |
|
| 269 |
|
|
| 270 |
c.drawLine(0, DynamicRenderer.BHEI/2, DynamicRenderer.BWID, DynamicRenderer.BHEI/2, mPaint); |
|
| 271 |
c.drawLine(DynamicRenderer.BWID/2, 0, DynamicRenderer.BWID/2, DynamicRenderer.BHEI, mPaint); |
|
| 272 |
|
|
| 273 |
c.drawText("x", 0.95f* DynamicRenderer.BWID, 0.55f* DynamicRenderer.BHEI , mPaint);
|
|
| 274 |
c.drawText( currentDim==DIM_3DXY ? "y" : "z", 0.55f* DynamicRenderer.BWID, 0.05f* DynamicRenderer.BHEI , mPaint); |
|
| 275 |
|
|
| 276 |
if( len>=2 ) |
|
| 277 |
{
|
|
| 278 |
for(int i=0; i<NUM_INTERPOLATIONS; i++) |
|
| 279 |
{
|
|
| 280 |
int color = i<=mPosition ? 0xff - ((int)mPosition -i)*0xff/(NUM_INTERPOLATIONS-1) |
|
| 281 |
: 0xff - ((int)mPosition+NUM_INTERPOLATIONS-i)*0xff/(NUM_INTERPOLATIONS-1); |
|
| 282 |
|
|
| 283 |
mPaint.setColor( 0xffffff + ((color&0xff)<<24) ); |
|
| 284 |
di3D.interpolate(mDrawCoord,0, (float)i/NUM_INTERPOLATIONS); |
|
| 285 |
c.drawCircle(mDrawCoord[0], mDrawCoord[currentDim==DIM_3DXY ? 1:2], 2.0f, mPaint ); |
|
| 286 |
} |
|
| 287 |
} |
|
| 288 |
|
|
| 289 |
mPaint.setColor(0xffff0000); |
|
| 290 |
|
|
| 291 |
for(int curr=0; curr<len; curr++) |
|
| 292 |
{
|
|
| 293 |
p3D = di3D.getPoint(curr); |
|
| 294 |
c.drawCircle(p3D.getX(), currentDim==DIM_3DXY ? p3D.getY():p3D.getZ(), 5.0f, mPaint); |
|
| 295 |
} |
|
| 296 |
} |
|
| 297 |
|
|
| 298 |
/////////////////////////////////////////////////////////////////// |
|
| 299 |
|
|
| 300 |
private void addNewPoint(int x, int y) |
|
| 301 |
{
|
|
| 302 |
float gx,gy,gz; |
|
| 303 |
int len; |
|
| 304 |
|
|
| 305 |
switch(currentDim) |
|
| 306 |
{
|
|
| 307 |
case DIM_1D: len = di1D.getNumPoints(); |
|
| 308 |
|
|
| 309 |
for(int g=0; g<len; g++) |
|
| 310 |
{
|
|
| 311 |
p1D = di1D.getPoint(g); |
|
| 312 |
gx = p1D.getX(); |
|
| 313 |
|
|
| 314 |
if( (xDown-gx)*(xDown-gx) < (DynamicRenderer.BHEI)*(DynamicRenderer.BHEI)/100 ) |
|
| 315 |
{
|
|
| 316 |
moving = g; |
|
| 317 |
break; |
|
| 318 |
} |
|
| 319 |
} |
|
| 320 |
if( moving<0 ) |
|
| 321 |
{
|
|
| 322 |
synchronized(lock) |
|
| 323 |
{
|
|
| 324 |
if( len>=MAX_VECTORS ) di1D.removeAll(); |
|
| 325 |
di1D.add(new Static1D(xDown)); |
|
| 326 |
} |
|
| 327 |
} |
|
| 328 |
break; |
|
| 329 |
case DIM_2D: len = di2D.getNumPoints(); |
|
| 330 |
|
|
| 331 |
for(int g=0; g<len; g++) |
|
| 332 |
{
|
|
| 333 |
p2D = di2D.getPoint(g); |
|
| 334 |
gx = p2D.getX(); |
|
| 335 |
gy = p2D.getY(); |
|
| 336 |
|
|
| 337 |
if( (xDown-gx)*(xDown-gx) + (yDown-gy)*(yDown-gy) < (DynamicRenderer.BHEI)*(DynamicRenderer.BHEI)/100 ) |
|
| 338 |
{
|
|
| 339 |
moving = g; |
|
| 340 |
break; |
|
| 341 |
} |
|
| 342 |
} |
|
| 343 |
if( moving<0 ) |
|
| 344 |
{
|
|
| 345 |
synchronized(lock) |
|
| 346 |
{
|
|
| 347 |
if( len>=MAX_VECTORS ) di2D.removeAll(); |
|
| 348 |
di2D.add(new Static2D(xDown,yDown)); |
|
| 349 |
} |
|
| 350 |
} |
|
| 351 |
break; |
|
| 352 |
default : len = di3D.getNumPoints(); |
|
| 353 |
|
|
| 354 |
for(int g=0; g<len; g++) |
|
| 355 |
{
|
|
| 356 |
p3D = di3D.getPoint(g); |
|
| 357 |
gx = p3D.getX(); |
|
| 358 |
gy = p3D.getY(); |
|
| 359 |
gz = p3D.getZ(); |
|
| 360 |
|
|
| 361 |
if( currentDim==DIM_3DXY ) |
|
| 362 |
{
|
|
| 363 |
if( (xDown-gx)*(xDown-gx) + (yDown-gy)*(yDown-gy) < (DynamicRenderer.BHEI)*(DynamicRenderer.BHEI)/100 ) |
|
| 364 |
{
|
|
| 365 |
moving = g; |
|
| 366 |
break; |
|
| 367 |
} |
|
| 368 |
} |
|
| 369 |
if( currentDim==DIM_3DXZ ) |
|
| 370 |
{
|
|
| 371 |
if( (xDown-gx)*(xDown-gx) + (yDown-gz)*(yDown-gz) < (DynamicRenderer.BHEI)*(DynamicRenderer.BHEI)/100 ) |
|
| 372 |
{
|
|
| 373 |
moving = g; |
|
| 374 |
break; |
|
| 375 |
} |
|
| 376 |
} |
|
| 377 |
} |
|
| 378 |
if( moving<0 ) |
|
| 379 |
{
|
|
| 380 |
synchronized(lock) |
|
| 381 |
{
|
|
| 382 |
if( len>=MAX_VECTORS ) di3D.removeAll(); |
|
| 383 |
|
|
| 384 |
if( currentDim==DIM_3DXY ) |
|
| 385 |
{
|
|
| 386 |
di3D.add(new Static3D(xDown,yDown, DynamicRenderer.BHEI/2)); |
|
| 387 |
} |
|
| 388 |
if( currentDim==DIM_3DXZ ) |
|
| 389 |
{
|
|
| 390 |
di3D.add(new Static3D(xDown, DynamicRenderer.BHEI/2,yDown)); |
|
| 391 |
} |
|
| 392 |
} |
|
| 393 |
} |
|
| 394 |
break; |
|
| 395 |
} |
|
| 396 |
} |
|
| 397 |
|
|
| 398 |
/////////////////////////////////////////////////////////////////// |
|
| 399 |
|
|
| 400 |
@Override public boolean onTouchEvent(MotionEvent event) |
|
| 401 |
{
|
|
| 402 |
int action = event.getAction(); |
|
| 403 |
|
|
| 404 |
switch(action) |
|
| 405 |
{
|
|
| 406 |
case MotionEvent.ACTION_DOWN: xDown = (int)event.getX()* DynamicRenderer.BWID/mScrW; |
|
| 407 |
yDown = (int)event.getY()* DynamicRenderer.BHEI/mScrH; |
|
| 408 |
|
|
| 409 |
addNewPoint(xDown,yDown); |
|
| 410 |
|
|
| 411 |
break; |
|
| 412 |
case MotionEvent.ACTION_MOVE: if( moving>=0 ) |
|
| 413 |
{
|
|
| 414 |
xDown = (int)event.getX()* DynamicRenderer.BWID/mScrW; |
|
| 415 |
yDown = (int)event.getY()* DynamicRenderer.BHEI/mScrH; |
|
| 416 |
|
|
| 417 |
switch(currentDim) |
|
| 418 |
{
|
|
| 419 |
case DIM_1D : di1D.setPoint(moving, xDown); |
|
| 420 |
break; |
|
| 421 |
case DIM_2D : di2D.setPoint(moving, xDown, yDown); |
|
| 422 |
break; |
|
| 423 |
case DIM_3DXY: di3D.setPoint(moving, xDown, yDown, (int)di3D.getPoint(moving).getZ()); |
|
| 424 |
break; |
|
| 425 |
case DIM_3DXZ: di3D.setPoint(moving, xDown, (int)di3D.getPoint(moving).getY(), yDown); |
|
| 426 |
break; |
|
| 427 |
} |
|
| 428 |
} |
|
| 429 |
break; |
|
| 430 |
case MotionEvent.ACTION_UP : moving = -1; |
|
| 431 |
break; |
|
| 432 |
} |
|
| 433 |
|
|
| 434 |
return true; |
|
| 435 |
} |
|
| 436 |
|
|
| 437 |
/////////////////////////////////////////////////////////////////// |
|
| 438 |
} |
|
| src/main/java/org/distorted/examples/fbo/FBORenderer.java | ||
|---|---|---|
| 80 | 80 |
float factor = (float)height/lisaHeight; |
| 81 | 81 |
|
| 82 | 82 |
mLisa.move( new Static3D((width-w)/2,0,0) ); |
| 83 |
mLisa.scale( new Static3D(factor,factor,factor));
|
|
| 83 |
mLisa.scale(factor);
|
|
| 84 | 84 |
} |
| 85 | 85 |
else |
| 86 | 86 |
{
|
| 87 | 87 |
int h = (width*lisaHeight)/lisaWidth; |
| 88 | 88 |
float factor = (float)width/lisaWidth; |
| 89 | 89 |
|
| 90 |
mLisa.move( new Static3D(0,(height-h)/2,0) );
|
|
| 91 |
mLisa.scale( new Static3D(factor,factor,factor) );
|
|
| 90 |
mLisa.move( new Static3D(0,(height-h)/2,0) ); |
|
| 91 |
mLisa.scale(factor);
|
|
| 92 | 92 |
} |
| 93 | 93 |
|
| 94 | 94 |
Distorted.onSurfaceChanged(width, height); |
| ... | ... | |
| 133 | 133 |
float factor = lisaWidth/(1.5f*textWidth); |
| 134 | 134 |
|
| 135 | 135 |
mText.move( new Static3D(lisaWidth/6,lisaHeight/3,0) ); |
| 136 |
mText.scale( new Static3D(factor,factor,factor) );
|
|
| 136 |
mText.scale(factor);
|
|
| 137 | 137 |
|
| 138 |
Dynamic1D sinkDyn = new Dynamic1D(); |
|
| 139 |
sinkDyn.setDuration(5000); |
|
| 140 |
sinkDyn.setCount(0); |
|
| 138 |
Dynamic1D sinkDyn = new Dynamic1D(5000,0.0f); |
|
| 141 | 139 |
sinkDyn.add(new Static1D(1.0f)); |
| 142 | 140 |
sinkDyn.add(new Static1D(0.5f)); |
| 143 | 141 |
|
| 144 | 142 |
mText.sink(sinkDyn, new Static2D(textWidth/2,textHeight/2)); |
| 145 | 143 |
|
| 146 |
Dynamic1D macroblockDyn = new Dynamic1D(); |
|
| 147 |
macroblockDyn.setDuration(10000); |
|
| 148 |
macroblockDyn.setCount(0); |
|
| 144 |
Dynamic1D macroblockDyn = new Dynamic1D(10000,0.0f); |
|
| 149 | 145 |
macroblockDyn.add(new Static1D(1)); |
| 150 | 146 |
macroblockDyn.add(new Static1D(5)); |
| 151 | 147 |
|
| src/main/java/org/distorted/examples/girl/GirlRenderer.java | ||
|---|---|---|
| 74 | 74 |
pLeft = new Static2D(132, 264); |
| 75 | 75 |
pRight= new Static2D(247, 264); |
| 76 | 76 |
|
| 77 |
// Make the boobs bigger
|
|
| 77 |
// Size
|
|
| 78 | 78 |
sinkRegion = new Static4D(0,0,60,60); |
| 79 | 79 |
|
| 80 | 80 |
s0 = new Static1D(boobsSink); |
| 81 | 81 |
|
| 82 |
diSink = new Dynamic1D(); |
|
| 83 |
diSink.setCount(0.5f); |
|
| 84 |
diSink.setDuration(0); |
|
| 82 |
diSink = new Dynamic1D(0,0.5f); |
|
| 85 | 83 |
diSink.add(s0); |
| 86 | 84 |
|
| 87 |
// Boobs Movement
|
|
| 85 |
// Upper Movement
|
|
| 88 | 86 |
Region = new Static4D(0,0,45,45); |
| 89 | 87 |
|
| 90 |
diL = new Dynamic3D(); |
|
| 91 |
diR = new Dynamic3D(); |
|
| 92 |
|
|
| 93 |
diL.setCount(0.0f); |
|
| 94 |
diR.setCount(0.0f); |
|
| 95 |
diL.setDuration(1000); |
|
| 96 |
diR.setDuration(1000); |
|
| 97 |
|
|
| 88 |
diL = new Dynamic3D(1000,0.0f); |
|
| 89 |
diR = new Dynamic3D(1000,0.0f); |
|
| 90 |
|
|
| 98 | 91 |
v0 = new Static3D( 0,-boobsSwing, 0); |
| 99 | 92 |
v1 = new Static3D( boobsSwing, 0, 0); |
| 100 | 93 |
v2 = new Static3D( 0, boobsSwing, 0); |
| ... | ... | |
| 110 | 103 |
diR.add(v2); |
| 111 | 104 |
diR.add(v1); |
| 112 | 105 |
|
| 113 |
// Movement of the hips
|
|
| 106 |
// Lower Movement
|
|
| 114 | 107 |
pHips = new Static2D(216,505); |
| 115 | 108 |
HipsRegion = new Static4D(0,0,120,120); |
| 116 |
diHips = new Dynamic1D(); |
|
| 109 |
diHips = new Dynamic1D(1000,0.0f);
|
|
| 117 | 110 |
|
| 118 | 111 |
d0 = new Static1D(-hipsSwirl); |
| 119 | 112 |
d1 = new Static1D(+hipsSwirl); |
| 120 | 113 |
|
| 121 | 114 |
diHips.add(d0); |
| 122 | 115 |
diHips.add(d1); |
| 123 |
diHips.setDuration(1000); |
|
| 124 |
diHips.setCount(0.0f); |
|
| 125 | 116 |
} |
| 126 | 117 |
|
| 127 | 118 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 175 | 166 |
float factor = (float)height/bmpHeight; |
| 176 | 167 |
|
| 177 | 168 |
mGirl.move( new Static3D((width-w)/2,0,0) ); |
| 178 |
mGirl.scale( new Static3D(factor,factor,factor) );
|
|
| 169 |
mGirl.scale(factor);
|
|
| 179 | 170 |
} |
| 180 | 171 |
else |
| 181 | 172 |
{
|
| ... | ... | |
| 183 | 174 |
float factor = (float)width/bmpWidth; |
| 184 | 175 |
|
| 185 | 176 |
mGirl.move( new Static3D(0,(height-h)/2,0) ); |
| 186 |
mGirl.scale( new Static3D(factor,factor,factor) );
|
|
| 177 |
mGirl.scale(factor);
|
|
| 187 | 178 |
} |
| 188 | 179 |
|
| 189 | 180 |
Distorted.onSurfaceChanged(width, height); |
| src/main/java/org/distorted/examples/interpolator/InterpolatorActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.interpolator; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.Distorted; |
|
| 23 |
import org.distorted.library.type.Dynamic1D; |
|
| 24 |
import org.distorted.examples.R; |
|
| 25 |
|
|
| 26 |
import android.app.Activity; |
|
| 27 |
import android.opengl.GLSurfaceView; |
|
| 28 |
import android.os.Bundle; |
|
| 29 |
import android.view.View; |
|
| 30 |
import android.widget.SeekBar; |
|
| 31 |
import android.widget.TextView; |
|
| 32 |
import android.widget.SeekBar.OnSeekBarChangeListener; |
|
| 33 |
|
|
| 34 |
/////////////////////////////////////////////////////////////////// |
|
| 35 |
|
|
| 36 |
public class InterpolatorActivity extends Activity implements OnSeekBarChangeListener |
|
| 37 |
{
|
|
| 38 |
private SeekBar barD, barN; |
|
| 39 |
private TextView textD, textN; |
|
| 40 |
|
|
| 41 |
/////////////////////////////////////////////////////////////////// |
|
| 42 |
@Override |
|
| 43 |
protected void onCreate(Bundle savedInstanceState) |
|
| 44 |
{
|
|
| 45 |
super.onCreate(savedInstanceState); |
|
| 46 |
setContentView(R.layout.interpolatorlayout); |
|
| 47 |
|
|
| 48 |
barD = (SeekBar)findViewById(R.id.interpolatorSeekDuration); |
|
| 49 |
barD.setOnSeekBarChangeListener(this); |
|
| 50 |
textD = (TextView)findViewById(R.id.interpolatorTextDuration); |
|
| 51 |
|
|
| 52 |
barN = (SeekBar)findViewById(R.id.interpolatorSeekNoise); |
|
| 53 |
barN.setOnSeekBarChangeListener(this); |
|
| 54 |
textN = (TextView)findViewById(R.id.interpolatorTextNoise); |
|
| 55 |
|
|
| 56 |
barD.setProgress(50); |
|
| 57 |
textD.setText("Duration: 10 s");
|
|
| 58 |
|
|
| 59 |
barN.setProgress(0); |
|
| 60 |
textN.setText("Noise: 0.0");
|
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
/////////////////////////////////////////////////////////////////// |
|
| 64 |
@Override |
|
| 65 |
protected void onResume() |
|
| 66 |
{
|
|
| 67 |
super.onResume(); |
|
| 68 |
|
|
| 69 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView); |
|
| 70 |
mView.onResume(); |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
/////////////////////////////////////////////////////////////////// |
|
| 74 |
@Override |
|
| 75 |
protected void onPause() |
|
| 76 |
{
|
|
| 77 |
GLSurfaceView mView = (GLSurfaceView) this.findViewById(R.id.interpolatorSurfaceView); |
|
| 78 |
mView.onPause(); |
|
| 79 |
|
|
| 80 |
super.onPause(); |
|
| 81 |
} |
|
| 82 |
|
|
| 83 |
/////////////////////////////////////////////////////////////////// |
|
| 84 |
@Override |
|
| 85 |
public void onStop() |
|
| 86 |
{
|
|
| 87 |
super.onStop(); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
/////////////////////////////////////////////////////////////////// |
|
| 91 |
@Override |
|
| 92 |
public void onDestroy() |
|
| 93 |
{
|
|
| 94 |
Distorted.onDestroy(); |
|
| 95 |
super.onDestroy(); |
|
| 96 |
} |
|
| 97 |
|
|
| 98 |
/////////////////////////////////////////////////////////////////// |
|
| 99 |
|
|
| 100 |
public void Loop(View v) |
|
| 101 |
{
|
|
| 102 |
InterpolatorSurfaceView.setMode(Dynamic1D.MODE_LOOP); |
|
| 103 |
} |
|
| 104 |
|
|
| 105 |
/////////////////////////////////////////////////////////////////// |
|
| 106 |
|
|
| 107 |
public void Path(View v) |
|
| 108 |
{
|
|
| 109 |
InterpolatorSurfaceView.setMode(Dynamic1D.MODE_PATH); |
|
| 110 |
} |
|
| 111 |
|
|
| 112 |
/////////////////////////////////////////////////////////////////// |
|
| 113 |
|
|
| 114 |
public void Jump(View v) |
|
| 115 |
{
|
|
| 116 |
InterpolatorSurfaceView.setMode(Dynamic1D.MODE_JUMP); |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
/////////////////////////////////////////////////////////////////// |
|
| 120 |
|
|
| 121 |
public void Dim1D(View v) |
|
| 122 |
{
|
|
| 123 |
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_1D); |
|
| 124 |
} |
|
| 125 |
|
|
| 126 |
/////////////////////////////////////////////////////////////////// |
|
| 127 |
|
|
| 128 |
public void Dim2D(View v) |
|
| 129 |
{
|
|
| 130 |
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_2D); |
|
| 131 |
} |
|
| 132 |
|
|
| 133 |
/////////////////////////////////////////////////////////////////// |
|
| 134 |
|
|
| 135 |
public void Dim3DXY(View v) |
|
| 136 |
{
|
|
| 137 |
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_3DXY); |
|
| 138 |
} |
|
| 139 |
|
|
| 140 |
/////////////////////////////////////////////////////////////////// |
|
| 141 |
|
|
| 142 |
public void Dim3DXZ(View v) |
|
| 143 |
{
|
|
| 144 |
InterpolatorSurfaceView.setDimension(InterpolatorSurfaceView.DIM_3DXZ); |
|
| 145 |
} |
|
| 146 |
|
|
| 147 |
/////////////////////////////////////////////////////////////////// |
|
| 148 |
|
|
| 149 |
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) |
|
| 150 |
{
|
|
| 151 |
float v, t; |
|
| 152 |
int i; |
|
| 153 |
|
|
| 154 |
switch (bar.getId()) |
|
| 155 |
{
|
|
| 156 |
case R.id.interpolatorSeekDuration: v = progress*200; |
|
| 157 |
i = (int)(v/100); |
|
| 158 |
t = i/10.0f; |
|
| 159 |
InterpolatorSurfaceView.setDuration((int)v); |
|
| 160 |
textD.setText("Duration: "+(int)t+" s");
|
|
| 161 |
break; |
|
| 162 |
case R.id.interpolatorSeekNoise : InterpolatorSurfaceView.setNoise(progress/100.0f); |
|
| 163 |
textN.setText("Noise: "+(progress/100.f));
|
|
| 164 |
break; |
|
| 165 |
} |
|
| 166 |
} |
|
| 167 |
|
|
| 168 |
/////////////////////////////////////////////////////////////////// |
|
| 169 |
|
|
| 170 |
public void onStartTrackingTouch(SeekBar bar) { }
|
|
| 171 |
|
|
| 172 |
/////////////////////////////////////////////////////////////////// |
|
| 173 |
|
|
| 174 |
public void onStopTrackingTouch(SeekBar bar) { }
|
|
| 175 |
|
|
| 176 |
/////////////////////////////////////////////////////////////////// |
|
| 177 |
// end of file |
|
| 178 |
} |
|
| src/main/java/org/distorted/examples/interpolator/InterpolatorRenderer.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.examples.interpolator; |
|
| 21 |
|
|
| 22 |
import javax.microedition.khronos.egl.EGLConfig; |
|
| 23 |
import javax.microedition.khronos.opengles.GL10; |
|
| 24 |
|
|
| 25 |
import android.graphics.Bitmap; |
|
| 26 |
import android.graphics.Canvas; |
|
| 27 |
import android.graphics.Paint; |
|
| 28 |
import android.graphics.Paint.Style; |
|
| 29 |
import android.opengl.GLES20; |
|
| 30 |
import android.opengl.GLSurfaceView; |
|
| 31 |
|
|
| 32 |
import org.distorted.library.DistortedBitmap; |
|
| 33 |
import org.distorted.library.Distorted; |
|
| 34 |
import org.distorted.library.EffectTypes; |
|
| 35 |
import org.distorted.library.type.Static3D; |
|
| 36 |
|
|
| 37 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 38 |
|
|
| 39 |
public class InterpolatorRenderer implements GLSurfaceView.Renderer |
|
| 40 |
{
|
|
| 41 |
public static final int BWID = 300; |
|
| 42 |
public static final int BHEI = 400; |
|
| 43 |
|
|
| 44 |
private GLSurfaceView mView; |
|
| 45 |
private DistortedBitmap mBackground; |
|
| 46 |
private Canvas mCanvas; |
|
| 47 |
private Bitmap mBitmap; |
|
| 48 |
private Paint mPaint; |
|
| 49 |
private int texWidth, texHeight; |
|
| 50 |
|
|
| 51 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 52 |
|
|
| 53 |
public InterpolatorRenderer(GLSurfaceView v) |
|
| 54 |
{
|
|
| 55 |
mPaint = new Paint(); |
|
| 56 |
mPaint.setAntiAlias(true); |
|
| 57 |
mPaint.setFakeBoldText(true); |
|
| 58 |
mPaint.setColor(0xff447da7); |
|
| 59 |
mPaint.setStyle(Style.FILL); |
|
| 60 |
|
|
| 61 |
mView = v; |
|
| 62 |
|
|
| 63 |
texWidth = BWID; |
|
| 64 |
texHeight= BHEI; |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 68 |
|
|
| 69 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
| 70 |
{
|
|
| 71 |
mBackground = new DistortedBitmap(texWidth,texHeight, 2); |
|
| 72 |
mBitmap = Bitmap.createBitmap(texWidth,texHeight, Bitmap.Config.ARGB_8888); |
|
| 73 |
mCanvas = new Canvas(mBitmap); |
|
| 74 |
|
|
| 75 |
try |
|
| 76 |
{
|
|
| 77 |
Distorted.onSurfaceCreated(mView.getContext()); |
|
| 78 |
} |
|
| 79 |
catch(Exception ex) |
|
| 80 |
{
|
|
| 81 |
android.util.Log.e("Renderer", ex.getMessage() );
|
|
| 82 |
} |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 |
|
|
| 87 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
| 88 |
{
|
|
| 89 |
mBackground.abortEffects(EffectTypes.MATRIX); |
|
| 90 |
mBackground.scale( new Static3D((float)width/texWidth,(float)height/texHeight,1) ); |
|
| 91 |
Distorted.onSurfaceChanged(width, height); |
|
| 92 |
InterpolatorSurfaceView.setScreenSize(width,height); |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 96 |
|
|
| 97 |
public void onDrawFrame(GL10 glUnused) |
|
| 98 |
{
|
|
| 99 |
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); |
|
| 100 |
|
|
| 101 |
long time = System.currentTimeMillis(); |
|
| 102 |
|
|
| 103 |
mCanvas.drawRect(0, 0, texWidth, texHeight, mPaint); |
|
| 104 |
InterpolatorSurfaceView.drawCurve(mCanvas,time); |
|
| 105 |
mBackground.setBitmap(mBitmap); |
|
| 106 |
mBackground.draw(time); |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 110 |
} |
|
| src/main/java/org/distorted/examples/interpolator/InterpolatorSurfaceView.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2016 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Distorted. // |
|
| 5 |
// // |
|
| 6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
| 7 |
// it under the terms of the GNU General Public License as published by // |
|
| 8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
| 9 |
// (at your option) any later version. // |
|
| 10 |
// // |
|
| 11 |
// Distorted is distributed in the hope that it will be useful, // |
|
| 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
| 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
| 14 |
// GNU General Public License for more details. // |
|
| 15 |
// // |
|
| 16 |
// You should have received a copy of the GNU General Public License // |
|
| 17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
Also available in: Unified diff
Further reduce the distortedObject's API - now only 26 methods, 1/4 of the 104 before the reorganization.