commit 39a0d81b7482f2925808d661e526aeaa980fb079
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Tue Apr 25 14:22:13 2017 +0100

    Convert next 4 APPs to the new Matrix effects.

diff --git a/src/main/java/org/distorted/examples/cubes/CubesRenderer.java b/src/main/java/org/distorted/examples/cubes/CubesRenderer.java
index 49a52b2..056a167 100644
--- a/src/main/java/org/distorted/examples/cubes/CubesRenderer.java
+++ b/src/main/java/org/distorted/examples/cubes/CubesRenderer.java
@@ -96,26 +96,16 @@ class CubesRenderer implements GLSurfaceView.Renderer
     public void onSurfaceChanged(GL10 glUnused, int width, int height) 
       {
       mScreenMin = width<height ? width:height;
-    	
-      mEffects.abortEffects(EffectTypes.MATRIX);
-      float factor;
-
-      if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
-        {
-        factor = (0.75f*height)/mObjHeight;
-        }
-      else
-        {
-        factor = (0.75f*width)/mObjWidth;
-        }
 
-      mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
-      mEffects.scale(factor);
-      Static3D center = new Static3D( (float)mObjWidth/2, (float)mObjHeight/2, 0.0f );
+    	float q= ((float)width/height)*((float)mObjHeight/mObjWidth);
+      float scale = 0.7f;
+      Static3D center = new Static3D(0,0,0);
 
+      mEffects.abortEffects(EffectTypes.MATRIX);
       mEffects.quaternion(mQuatInt1, center);
       mEffects.quaternion(mQuatInt2, center);
-       
+      mEffects.scale(  q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)) );
+
       mScreen.resize(width, height);
       }
 
diff --git a/src/main/java/org/distorted/examples/flag/FlagRenderer.java b/src/main/java/org/distorted/examples/flag/FlagRenderer.java
index d378581..3700bb8 100644
--- a/src/main/java/org/distorted/examples/flag/FlagRenderer.java
+++ b/src/main/java/org/distorted/examples/flag/FlagRenderer.java
@@ -150,26 +150,16 @@ class FlagRenderer implements GLSurfaceView.Renderer
     public void onSurfaceChanged(GL10 glUnused, int width, int height) 
       {
       mScreenMin = width<height ? width:height;
-    	
-      mEffects.abortEffects(EffectTypes.MATRIX);
-      float factor;
-
-      if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
-        {
-        factor = (0.8f*height)/mObjHeight;
-        }
-      else
-        {
-        factor = (0.8f*width)/mObjWidth;
-        }
 
-      mEffects.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
-      mEffects.scale(factor);
-      Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0);
+    	float q= ((float)width/height)*((float)mObjHeight/mObjWidth);
+      float scale = 0.8f;
+      Static3D center = new Static3D(0,0,0);
 
+      mEffects.abortEffects(EffectTypes.MATRIX);
       mEffects.quaternion(mQuatInt1, center);
       mEffects.quaternion(mQuatInt2, center);
-       
+      mEffects.scale(  q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)) );
+
       mScreen.resize(width, height);
       }
 
diff --git a/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java b/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java
index f6d8998..6307507 100644
--- a/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java
+++ b/src/main/java/org/distorted/examples/multiblur/MultiblurActivity.java
@@ -50,7 +50,7 @@ public class MultiblurActivity extends Activity implements SeekBar.OnSeekBarChan
       if( savedState==null )
         {
         distanceBar.setProgress(50);
-        rangeBar.setProgress(10);
+        rangeBar.setProgress(50);
         }
       }
 
diff --git a/src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java b/src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java
index e2ef1c2..dbddc31 100644
--- a/src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java
+++ b/src/main/java/org/distorted/examples/multiblur/MultiblurRenderer.java
@@ -68,7 +68,6 @@ class MultiblurRenderer implements GLSurfaceView.Renderer
         };
 
     private static final int NUM_OBJECTS = MOVE_VEC.length/3;
-    private static final int OBJ_SIZE    = 100;
 
     private GLSurfaceView mView;
     private DistortedTexture mTex1, mTex2;
@@ -83,6 +82,7 @@ class MultiblurRenderer implements GLSurfaceView.Renderer
     private DynamicQuat mQuatInt1, mQuatInt2;
     private int mDistance;
     private boolean[] mBlurStatus;
+    private int mScreenW, mScreenH;
 
     Static4D mQuat1, mQuat2;
     int mScreenMin;
@@ -114,7 +114,6 @@ class MultiblurRenderer implements GLSurfaceView.Renderer
       fpsTexture.setTexture(fpsBitmap);
       fpsCanvas = new Canvas(fpsBitmap);
       fpsEffects = new DistortedEffects();
-      fpsEffects.move( new Static3D(5,5,0) );
       durations = new long[NUM_FRAMES+1];
       currDuration = 0;
 
@@ -149,8 +148,8 @@ class MultiblurRenderer implements GLSurfaceView.Renderer
 
       MeshCubes mesh = new MeshCubes(1,1,false);
 
-      mTex1 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
-      mTex2 = new DistortedTexture(OBJ_SIZE,OBJ_SIZE);
+      mTex1 = new DistortedTexture(1,1);
+      mTex2 = new DistortedTexture(1,1);
 
       mQuat1 = new Static4D(0,0,0,1);  // unity
       mQuat2 = new Static4D(0,0,0,1);  // quaternions
@@ -196,20 +195,26 @@ class MultiblurRenderer implements GLSurfaceView.Renderer
     public void onSurfaceChanged(GL10 glUnused, int width, int height) 
       {
       mScreenMin = width<height ? width:height;
+      mScreenW = width;
+      mScreenH = height;
 
-    	float factor    = 0.15f*mScreenMin/OBJ_SIZE;
-      Static3D center = new Static3D( (float)OBJ_SIZE/2, (float)OBJ_SIZE/2, 0.0f );
-      Static3D moveVec= new Static3D( (width -factor*OBJ_SIZE)/2 ,(height-factor*OBJ_SIZE)/2 ,0);
+      fpsEffects.abortAllEffects();
+      fpsEffects.move(  new Static3D( -0.5f + (fpsW/2 + 5.0f)/width, -0.5f + (fpsH/2 + 5.0f)/height,0.0f) );
+      fpsEffects.scale( new Static3D( (float)fpsW/width, (float)fpsH/height, 1.0f) );
+
+      float q= (float)width/height;
+      float scale = 0.15f;
+      Static3D center = new Static3D(0,0,0);
+      Static3D factor = (q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)));
 
       for(int i=0; i<NUM_OBJECTS; i++)
         {
         mEffects[i].abortEffects(EffectTypes.MATRIX);
 
-        mEffects[i].move(moveVec);
-        mEffects[i].scale(factor);
         mEffects[i].quaternion(mQuatInt1, center);
         mEffects[i].quaternion(mQuatInt2, center);
         mEffects[i].move(mMoveDynamic[i]);
+        mEffects[i].scale(factor);
         }
 
       computeMoveVectors();
@@ -275,11 +280,13 @@ class MultiblurRenderer implements GLSurfaceView.Renderer
 
     private void computeMoveVectors()
       {
-      float size= 0.026f*OBJ_SIZE*mDistance;
+      float size = 2.6f*mDistance;
+      float sizeX= size/mScreenW;
+      float sizeY= size/mScreenH;
 
       for(int i=0; i<NUM_OBJECTS; i++)
         {
-        mMoveVector[i].set(size*MOVE_VEC[3*i], size*MOVE_VEC[3*i+1], size*MOVE_VEC[3*i+2]);
+        mMoveVector[i].set(sizeX*MOVE_VEC[3*i], sizeY*MOVE_VEC[3*i+1], sizeX*MOVE_VEC[3*i+2]);
         }
       }
 
diff --git a/src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java b/src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
index 2db3f0c..bb3308b 100644
--- a/src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
+++ b/src/main/java/org/distorted/examples/quaternion/QuaternionRenderer.java
@@ -98,13 +98,12 @@ class QuaternionRenderer implements GLSurfaceView.Renderer
     
   public void onSurfaceChanged(GL10 glUnused, int width, int height) 
     {
-    float qx = (float)width ;
-    float qy = (float)height;
+    float q= (float)width/height;
     float scale = 0.5f;
 
     mEffects.abortEffects(EffectTypes.MATRIX);
     mEffects.quaternion( mRot, new Static3D(0,0,0) );
-    mEffects.scale(  qx<qy ? (new Static3D(scale,scale*qx/qy,scale)) : (new Static3D(scale*qy/qx,scale,scale)) );
+    mEffects.scale(  q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)) );
 
     mScreen.resize(width, height);
     }
