commit b4a73ea5aced1a29cbb07afa34b280f5cf73b843
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Tue Jul 5 12:14:52 2016 +0100

    Essentially revert the last commit :)

diff --git a/src/main/java/org/distorted/examples/check/CheckRenderer.java b/src/main/java/org/distorted/examples/check/CheckRenderer.java
index 44a5543..2177665 100644
--- a/src/main/java/org/distorted/examples/check/CheckRenderer.java
+++ b/src/main/java/org/distorted/examples/check/CheckRenderer.java
@@ -45,11 +45,14 @@ import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.opengl.GLES20;
 import android.opengl.GLSurfaceView;
+import android.util.Log;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 class CheckRenderer implements GLSurfaceView.Renderer 
 {
+    private static final String TAG = "CheckRenderer";
+
     private GLSurfaceView mView;
     private DistortedBitmap mSuccess;
     private int bmpHeight, bmpWidth;
@@ -138,13 +141,23 @@ class CheckRenderer implements GLSurfaceView.Renderer
       dSwirl.add(new Static2D(        0, bmpHeight/2));
       dSwirl.add(new Static2D( bmpWidth, bmpHeight/2));
 
-      mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
+      long swirlEffectID = mSuccess.swirl( new Static1D(30), dSwirl, new Static4D( 0,0,40,40) );
+
+      if( swirlEffectID<0 )
+        {
+        Log.e(TAG, "Failed to add Swirl effect!");
+        }
 
       Dynamic3D dDeform = new Dynamic3D(2000,0.0f);
       dDeform.add(new Static3D( 0,         0,0));
       dDeform.add(new Static3D( 0,-bmpHeight,0));
 
-      mSuccess.deform(dDeform, new Static2D(bmpWidth/2,0) );
+      long deformEffectID = mSuccess.deform(dDeform, new Static2D(bmpWidth/2,0) );
+
+      if( deformEffectID<0 )
+        {
+        Log.e(TAG, "Failed to add Deform effect!");
+        }
 
       // Now try adding 1 Fragment Effect. Likewise, will fail if maxFragmentEffects is <1.
       Static3D color = new Static3D(1,0,0);
@@ -152,7 +165,12 @@ class CheckRenderer implements GLSurfaceView.Renderer
       inter.add(new Static1D(0));
       inter.add(new Static1D(1));
 
-      mSuccess.chroma(inter, color);
+      long chromaEffectID = mSuccess.chroma(inter, color);
+
+      if( chromaEffectID<0 )
+        {
+        Log.e(TAG, "Failed to add Chroma effect!");
+        }
 
       try
         {
diff --git a/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java b/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java
index 4753c07..7faf78e 100644
--- a/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java
+++ b/src/main/java/org/distorted/examples/effects2d/Effects2DActivity.java
@@ -77,11 +77,11 @@ public class Effects2DActivity extends Activity implements AdapterView.OnItemSel
 
     ArrayList<Long> itemsID  = new ArrayList<>();
 
-    String[] itemsName = new String[] { getText(R.string.distort     ).toString(),
-                                        getText(R.string.sink        ).toString(),
-                                        getText(R.string.transparency).toString(),
-                                        getText(R.string.macroblock  ).toString(),
-                                        getText(R.string.chroma      ).toString()};
+    String[] itemsName = new String[] { getText(R.string.distort   ).toString(),
+                                        getText(R.string.sink      ).toString(),
+                                        getText(R.string.alpha     ).toString(),
+                                        getText(R.string.macroblock).toString(),
+                                        getText(R.string.chroma    ).toString()};
 
     String[] itemsType = new String[] {"VERTEX", "FRAGMENT"};
 
diff --git a/src/main/java/org/distorted/examples/fragment3d/Fragment3DActivity.java b/src/main/java/org/distorted/examples/fragment3d/Fragment3DActivity.java
index 693435d..9338c06 100644
--- a/src/main/java/org/distorted/examples/fragment3d/Fragment3DActivity.java
+++ b/src/main/java/org/distorted/examples/fragment3d/Fragment3DActivity.java
@@ -42,12 +42,11 @@ import org.distorted.library.DistortedCubes;
 import org.distorted.library.DistortedObject;
 import org.distorted.library.EffectNames;
 
-import java.util.ArrayList;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 public class Fragment3DActivity extends Activity
-                                implements View.OnClickListener,
+                                implements OnSeekBarChangeListener,
+                                           View.OnClickListener,
                                            AdapterView.OnItemSelectedListener
   {
   private static final int COLOR_OFF = 0xffffe81f;
@@ -55,6 +54,8 @@ public class Fragment3DActivity extends Activity
 
   private boolean firstScreen;
 
+  // fields needed for the first 'pick-a-shape' screen
+  //
   private int mNumCols = 3;
   private int mNumRows = 3;
   private NumberPicker mColsPicker, mRowsPicker;
@@ -64,8 +65,22 @@ public class Fragment3DActivity extends Activity
   private int mObjectType;
   private int mBitmap;
 
-  private ArrayList<Fragment3DEffect> mEffects = new ArrayList<>();
-  private DistortedBitmap mCenter = null;
+  // fields needed for the second 'apply fragment effects' screen
+  //
+  private SeekBar bar;
+  private TextView textChroma, textAlpha, textBrightness, textSaturation, textCenter;
+  private int chromaL, chromaR, chromaG, chromaB;
+  private int alphaL;
+  private int brightnessL;
+  private int saturationL;
+  private int centerX, centerY;
+
+  private float fchromaL, fchromaR, fchromaG, fchromaB;
+  private float falphaL;
+  private float fbrightnessL;
+  private float fsaturationL;
+  private float fcenterX, fcenterY;
+  private EffectNames[] effects = new EffectNames[4];
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
     
@@ -204,6 +219,7 @@ public class Fragment3DActivity extends Activity
       firstScreen = false;
       mObject = new DistortedBitmap(100,100,mNumCols);
       setContentView(R.layout.fragment3dlayout);
+      Default(null);
       }
     else
       {
@@ -232,7 +248,9 @@ public class Fragment3DActivity extends Activity
       str += mShape[i] ? "1" : "0";
 
     mObject = new DistortedCubes(mNumCols, str, 10);
+
     setContentView(R.layout.fragment3dlayout);
+    Default(null);
     }
 
 
@@ -263,72 +281,272 @@ public class Fragment3DActivity extends Activity
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // 'second screen' methods
 
-  private void removeAllViews()
+  public void Default(View view)
     {
-    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
+    effects[0] = EffectNames.CHROMA;
+    effects[1] = EffectNames.ALPHA;
+    effects[2] = EffectNames.BRIGHTNESS;
+    effects[3] = EffectNames.SATURATION;
+    
+    chromaL = 0;
+    chromaR = 0;
+    chromaG = 0;
+    chromaB = 0;
+
+    alphaL     = 0;
+    brightnessL= 0;
+    saturationL= 0;
+
+    centerX = 50;
+    centerY = 50;
+
+    textCenter = (TextView)findViewById(R.id.fragment3dcenterText);
+    computeCenter();
+    setCenterText();
 
+    setBar(R.id.fragment3dcenterX, centerX);
+    setBar(R.id.fragment3dcenterY, centerY);
+
+    addViews();
+    }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+  private void addViews()
+    {
+    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
+    
     layout.removeAllViews();
-    mEffects.clear();
-    mCenter = null;
+      
+    View chroma    = getLayoutInflater().inflate(R.layout.fragment3dchroma    , null);
+    View alpha     = getLayoutInflater().inflate(R.layout.fragment3dalpha     , null);
+    View brightness= getLayoutInflater().inflate(R.layout.fragment3dbrightness, null);
+    View saturation= getLayoutInflater().inflate(R.layout.fragment3dsaturation, null);
+     
+    for( int i=effects.length-1 ; i>=0 ; i-- )
+      {
+      switch(effects[i])
+        {
+        case CHROMA     : layout.addView(chroma    , 0); break;
+        case ALPHA      : layout.addView(alpha     , 0); break;
+        case BRIGHTNESS : layout.addView(brightness, 0); break;
+        case SATURATION : layout.addView(saturation, 0); break;
+        }
+      }
+      
+    textChroma    = (TextView)findViewById(R.id.fragment3dchromaText);
+    textAlpha     = (TextView)findViewById(R.id.fragment3dalphaText);
+    textBrightness= (TextView)findViewById(R.id.fragment3dbrightnessText);
+    textSaturation= (TextView)findViewById(R.id.fragment3dsaturationText);
+     
+    setChromaText();
+    setAlphaText();
+    setBrightnessText();
+    setSaturationText();
+      
+    setBar(R.id.fragment3dchromaBar1, chromaL);
+    setBar(R.id.fragment3dchromaBar2, chromaR);
+    setBar(R.id.fragment3dchromaBar3, chromaG);
+    setBar(R.id.fragment3dchromaBar4, chromaB);
+
+    setBar(R.id.fragment3dalphaBar1     , alphaL);
+    setBar(R.id.fragment3dbrightnessBar1, brightnessL);
+    setBar(R.id.fragment3dsaturationBar1, saturationL);
+
+    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
+    view.getRenderer().setOrder(effects);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  private void addView(EffectNames name)
+  private void moveUp(EffectNames name)
     {
-    Fragment3DEffect newInfo = new Fragment3DEffect(name);
-    LinearLayout layout = (LinearLayout)findViewById(R.id.fragment3dlayout);
-    newInfo.addView(layout);
-    mEffects.add(newInfo);
+    int len = effects.length-1;
+    int index = -1;
+
+    for(int i=0; i<=len; i++)
+      {
+      if( effects[i]==name )
+        {
+        index=i;
+        break;
+        }
+      }
+
+    if( index==0 )
+      {
+      for(int i=0; i<len; i++)
+        effects[i] = effects[i+1];
+
+      effects[len] = name;
+      }
+    else if( index>0 )
+      {
+      effects[index]   = effects[index-1];
+      effects[index-1] = name;
+      }
+
+    addViews();
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void ButtonChroma(View v)
+    {
+    moveUp(EffectNames.CHROMA);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void ButtonAlpha(View v)
+    {
+    moveUp(EffectNames.ALPHA);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void ButtonBrightness(View v)
+    {
+    moveUp(EffectNames.BRIGHTNESS);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void ButtonSaturation(View v)
+    {
+    moveUp(EffectNames.SATURATION);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setBar(int id, int value)
+    {
+    bar = (SeekBar)findViewById(id);
+    bar.setOnSeekBarChangeListener(this);
+    bar.setProgress(value);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void computeChroma()
+    {
+    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
+    Fragment3DRenderer renderer = view.getRenderer();
+
+    fchromaL = chromaL/100.0f;
+    fchromaR = chromaR*255/100.0f;
+    fchromaG = chromaG*255/100.0f;
+    fchromaB = chromaB*255/100.0f;
+
+    renderer.setChroma( fchromaL, fchromaR, fchromaG, fchromaB );
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void Remove(View v)
+  private void setChromaText()
     {
-    removeAllViews();
+    fchromaL = ((int)(100*fchromaL))/100.0f;
+    fchromaR = (float)((int)fchromaR);
+    fchromaG = (float)((int)fchromaG);
+    fchromaB = (float)((int)fchromaB);
+
+    textChroma.setText("chroma("+fchromaL+"( "+fchromaR+" , "+fchromaG+" , "+fchromaB+" )");
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void newChroma(View v)
+  private void computeAlpha()
     {
-    addView(EffectNames.CHROMA);
+    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
+
+    falphaL = alphaL/100.0f;
+
+    view.getRenderer().setAlpha(falphaL);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void newAlpha(View v)
+  private void setAlphaText()
     {
-    addView(EffectNames.ALPHA);
+    falphaL = ((int)(100*falphaL))/100.0f;
+
+    textAlpha.setText("alpha("+falphaL+")");
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void newBrightness(View v)
+  private void computeBrightness()
     {
-    addView(EffectNames.BRIGHTNESS);
+    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
+
+    fbrightnessL = brightnessL/100.0f;
+
+    view.getRenderer().setBrightness( fbrightnessL );
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void newSaturation(View v)
+  private void setBrightnessText()
     {
-    addView(EffectNames.SATURATION);
+    fbrightnessL = ((int)(100*fbrightnessL))/100.0f;
+
+    textBrightness.setText("brightness("+fbrightnessL+")");
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public DistortedBitmap getCenter()
+  private void computeSaturation()
+    {
+    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
+
+    fsaturationL = saturationL/100.0f;
+
+    view.getRenderer().setSaturation( fsaturationL );
+    }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setSaturationText()
     {
-    return mCenter;
+    fsaturationL = ((int)(100*fsaturationL))/100.0f;
+
+    textSaturation.setText("saturation("+fsaturationL+")");
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public void setCenter(DistortedBitmap center  )
+  private void computeCenter()
     {
-    mCenter = center;
+    Fragment3DSurfaceView view = (Fragment3DSurfaceView)findViewById(R.id.fragment3dSurfaceView);
+
+    fcenterX = centerX;
+    fcenterY = centerY;
+
+    view.getRenderer().setCenter( fcenterX, fcenterY );
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void setCenterText()
+    {
+    fcenterX = ((int)(100*fcenterX))/100.0f;
+    fcenterY = ((int)(100*fcenterY))/100.0f;
+
+    textCenter.setText("center("+fcenterX+","+fcenterY+")");
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float getCenterX()
+    {
+    return fcenterX;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float getCenterY()
+    {
+    return fcenterY;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -374,4 +592,30 @@ public class Fragment3DActivity extends Activity
     Distorted.onDestroy();
     super.onDestroy();
     }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
+    {
+    switch (bar.getId())
+      {
+      case R.id.fragment3dcenterX       : centerX    = progress; computeCenter()    ; setCenterText()    ; break;
+      case R.id.fragment3dcenterY       : centerY    = progress; computeCenter()    ; setCenterText()    ; break;
+      case R.id.fragment3dchromaBar1    : chromaL    = progress; computeChroma()    ; setChromaText()    ; break;
+      case R.id.fragment3dchromaBar2    : chromaR    = progress; computeChroma()    ; setChromaText()    ; break;
+      case R.id.fragment3dchromaBar3    : chromaG    = progress; computeChroma()    ; setChromaText()    ; break;
+      case R.id.fragment3dchromaBar4    : chromaB    = progress; computeChroma()    ; setChromaText()    ; break;
+      case R.id.fragment3dalphaBar1     : alphaL     = progress; computeAlpha()     ; setAlphaText()     ; break;
+      case R.id.fragment3dbrightnessBar1: brightnessL= progress; computeBrightness(); setBrightnessText(); break;
+      case R.id.fragment3dsaturationBar1: saturationL= progress; computeSaturation(); setSaturationText(); break;
+      }
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onStartTrackingTouch(SeekBar bar) { }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public void onStopTrackingTouch(SeekBar bar)  { }
   }
diff --git a/src/main/java/org/distorted/examples/fragment3d/Fragment3DEffect.java b/src/main/java/org/distorted/examples/fragment3d/Fragment3DEffect.java
deleted file mode 100644
index 57a8c7c..0000000
--- a/src/main/java/org/distorted/examples/fragment3d/Fragment3DEffect.java
+++ /dev/null
@@ -1,95 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted is free software: you can redistribute it and/or modify                             //
-// it under the terms of the GNU General Public License as published by                          //
-// the Free Software Foundation, either version 2 of the License, or                             //
-// (at your option) any later version.                                                           //
-//                                                                                               //
-// Distorted is distributed in the hope that it will be useful,                                  //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
-// GNU General Public License for more details.                                                  //
-//                                                                                               //
-// You should have received a copy of the GNU General Public License                             //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.examples.fragment3d;
-
-import android.widget.LinearLayout;
-import android.widget.SeekBar;
-import android.widget.TextView;
-
-import org.distorted.library.DistortedBitmap;
-import org.distorted.library.EffectNames;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-public class Fragment3DEffect implements SeekBar.OnSeekBarChangeListener
-
-  {
-  private static Fragment3DActivity activity;
-
-  private EffectNames name;
-  private float inter1, inter2, inter3, inter4;
-  private float regX, regY, regRX, regRY;
-
-  private TextView textEffect, textCenter;
-  private SeekBar[] mSpinRegion;
-  private SeekBar[] mSpinInter;
-
-  private DistortedBitmap mRegion;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public static void setActivity(Fragment3DActivity act)
-    {
-    activity = act;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public Fragment3DEffect(EffectNames name)
-    {
-    this.name = name;
-    mSpinInter = new SeekBar[name.getDimension()];
-    mSpinRegion= new SeekBar[4];
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void addView(LinearLayout layout)
-    {
-
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void setBar(int id, int value)
-    {
-    SeekBar bar = (SeekBar)activity.findViewById(id);
-    bar.setOnSeekBarChangeListener(this);
-    bar.setProgress(value);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
-    {
-    switch (bar.getId())
-      {
-      // TODO
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void onStartTrackingTouch(SeekBar bar) { }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public void onStopTrackingTouch(SeekBar bar)  { }
-  }
diff --git a/src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java b/src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java
index 14db0fd..b7224cb 100644
--- a/src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java
+++ b/src/main/java/org/distorted/examples/fragment3d/Fragment3DRenderer.java
@@ -61,9 +61,85 @@ class Fragment3DRenderer implements GLSurfaceView.Renderer
 
     private DynamicQuat mQuatInt1, mQuatInt2;
 
+    private EffectNames[] order;
+
+    private Dynamic2D mCenterInter;
+    private Dynamic3D mChromaInter, mMoveInter;
+    private Dynamic1D mChromaLevelInter, mAlphaInter, mBrightnessInter, mSaturationInter;
+
+    private Static2D mCenterPoint;
+    private Static3D mChromaPoint, mMovePoint;
+    private Static1D mChromaLevel, mAlphaPoint, mBrightnessPoint, mSaturationPoint;
+
     Static4D mQuat1, mQuat2;
     int mScreenMin;
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void setChroma(float level, float r, float g, float b)
+      {
+      mChromaLevel.set(level);
+      mChromaPoint.set(r, g, b);
+      }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void setAlpha(float level)
+      {
+      mAlphaPoint.set(level);
+      }
+     
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void setBrightness(float level)
+      {
+      mBrightnessPoint.set(level);
+      }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void setSaturation(float level)
+      {
+      mSaturationPoint.set(level);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void setCenter(float x, float y)
+      {
+      x = (0.012f*x-0.1f)*mObjWidth;
+      y = (0.012f*y-0.1f)*mObjHeight;
+
+      mCenterPoint.set(x,y);
+      mMovePoint.set(mFactorObj*x,mFactorObj*y,0);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void setOrder(EffectNames[] effects)
+      {
+      order = effects;
+      setFragmentEffects();
+      }
+      
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private void setFragmentEffects()
+      {
+      mObject.abortEffects(EffectTypes.FRAGMENT);
+
+      for( int i=0; i<=order.length-1 ; i++ )
+        {
+        switch(order[i])
+          {
+          case CHROMA    : mObject.chroma    ( mChromaLevelInter , mChromaInter) ; break;
+          case ALPHA     : mObject.alpha     ( mAlphaInter                     ) ; break;
+          case BRIGHTNESS: mObject.brightness( mBrightnessInter                ) ; break;
+          case SATURATION: mObject.saturation( mSaturationInter                ) ; break;
+          }
+        }
+      }
+    
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public Fragment3DRenderer(GLSurfaceView v)
@@ -71,10 +147,35 @@ class Fragment3DRenderer implements GLSurfaceView.Renderer
       mView = v;
 
       mObject = ((Fragment3DActivity)v.getContext()).getObject();
+      mCenter = new DistortedBitmap(SIZE, SIZE, 1);
 
       mObjWidth = mObject.getWidth();
       mObjHeight= mObject.getHeight();
 
+      mCenterPoint    = new Static2D(0,0);
+      mMovePoint      = new Static3D(0,0,0);
+      mChromaPoint    = new Static3D(0,0,0);
+      mChromaLevel    = new Static1D(0);
+      mAlphaPoint     = new Static1D(1);
+      mBrightnessPoint= new Static1D(1);
+      mSaturationPoint= new Static1D(0.5f);
+
+      mCenterInter     = new Dynamic2D();
+      mMoveInter       = new Dynamic3D();
+      mChromaInter     = new Dynamic3D();
+      mChromaLevelInter= new Dynamic1D();
+      mAlphaInter      = new Dynamic1D();
+      mBrightnessInter = new Dynamic1D();
+      mSaturationInter = new Dynamic1D();
+
+      mCenterInter.add(mCenterPoint);
+      mMoveInter.add(mMovePoint);
+      mChromaInter.add(mChromaPoint);
+      mChromaLevelInter.add(mChromaLevel);
+      mAlphaInter.add(mAlphaPoint);
+      mBrightnessInter.add(mBrightnessPoint);
+      mSaturationInter.add(mSaturationPoint);
+
       mQuat1 = new Static4D(0,0,0,1);  // unity
       mQuat2 = new Static4D(0,0,0,1);  // quaternions
 
@@ -95,9 +196,6 @@ class Fragment3DRenderer implements GLSurfaceView.Renderer
       long time = System.currentTimeMillis();
 
       mObject.draw(time);
-
-      mCenter = mView.
-
       mCenter.draw(time);
       }
 
@@ -123,14 +221,6 @@ class Fragment3DRenderer implements GLSurfaceView.Renderer
         mFactorCen = (0.15f*width)/centerSize;
         }
 
-
-      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
-
-      mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
-      mObject.scale(mFactorObj);
-      mObject.quaternion(mQuatInt1, rotateObj);
-      mObject.quaternion(mQuatInt2, rotateObj);
-
       Fragment3DActivity act = (Fragment3DActivity)mView.getContext();
       float cX = act.getCenterX();
       float cY = act.getCenterY();
@@ -140,6 +230,13 @@ class Fragment3DRenderer implements GLSurfaceView.Renderer
 
       mMovePoint.set(cX*mFactorObj,cY*mFactorObj,0);
 
+      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
+
+      mObject.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
+      mObject.scale(mFactorObj);
+      mObject.quaternion(mQuatInt1, rotateObj);
+      mObject.quaternion(mQuatInt2, rotateObj);
+
       Static3D rotateCen = new Static3D(width/2,height/2, 0);
 
       mCenter.quaternion(mQuatInt1, rotateCen);
diff --git a/src/main/res/layout/fragment3dalpha.xml b/src/main/res/layout/fragment3dalpha.xml
index e5ad659..aef0de2 100644
--- a/src/main/res/layout/fragment3dalpha.xml
+++ b/src/main/res/layout/fragment3dalpha.xml
@@ -1,41 +1,38 @@
 <?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/fragment3dRowAlpha"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:orientation="horizontal">
 
-            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                          android:id="@+id/fragment3dRowAlpha"
-                          android:layout_width="match_parent"
-                          android:layout_height="wrap_content"
-                          android:orientation="horizontal">
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="0.8"
+        android:orientation="vertical" >
 
-                <LinearLayout
-                    android:layout_width="0dp"
-                    android:layout_height="wrap_content"
-                    android:layout_weight="0.8"
-                    android:orientation="vertical" >
+        <TextView
+            android:id="@+id/fragment3dalphaText"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="5dp"
+            android:layout_marginStart="5dp"
+            android:layout_marginTop="3dp"
+            />
 
-                    <TextView
-                        android:id="@+id/fragment3dalphaText"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginStart="5dp"
-                        android:layout_marginTop="3dp"
-                        />
+        <SeekBar
+            android:id="@+id/fragment3dalphaBar1"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp" />
+    </LinearLayout>
 
-                    <SeekBar
-                        android:id="@+id/fragment3dalphaBar1"
-                        android:layout_width="fill_parent"
-                        android:layout_height="wrap_content"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginLeft="5dp"
-                        android:layout_marginRight="5dp" />
-
-                </LinearLayout>
-
-                <Button
-                    android:id="@+id/fragment3dUpAlpha"
-                    android:layout_width="60dp"
-                    android:layout_height="fill_parent"
-                    android:onClick="ButtonAlpha"
-                    android:text="@string/Up" />
-
-            </LinearLayout>
+    <Button
+        android:id="@+id/fragment3dUpAlpha"
+        android:layout_width="60dp"
+        android:layout_height="fill_parent"
+        android:onClick="ButtonAlpha"
+        android:text="@string/Up" />
+</LinearLayout>
diff --git a/src/main/res/layout/fragment3dbrightness.xml b/src/main/res/layout/fragment3dbrightness.xml
index 825f47d..6e686b6 100644
--- a/src/main/res/layout/fragment3dbrightness.xml
+++ b/src/main/res/layout/fragment3dbrightness.xml
@@ -1,43 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
 
-            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                          android:id="@+id/fragment3dRowBrightness"
-                          android:orientation="horizontal"
-                          android:layout_width="match_parent"
-                          android:layout_height="wrap_content" >
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/fragment3dRowBrightness"
+              android:orientation="horizontal"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content" >
 
-                <LinearLayout
-                    android:layout_width="0dp"
-                    android:layout_height="match_parent"
-                    android:layout_weight="0.70"
-                    android:orientation="vertical" >
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="0.70"
+        android:orientation="vertical" >
 
-                    <TextView
-                        android:id="@+id/fragment3dbrightnessText"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginStart="5dp"
-                        android:layout_marginTop="3dp"
-                        />
+        <TextView
+            android:id="@+id/fragment3dbrightnessText"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="5dp"
+            android:layout_marginStart="5dp"
+            android:layout_marginTop="3dp" />
 
-                    <SeekBar
-                        android:id="@+id/fragment3dbrightnessBar1"
-                        android:layout_width="fill_parent"
-                        android:layout_height="wrap_content"
-                        android:layout_gravity="end"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginLeft="5dp"
-                        android:layout_marginRight="5dp" />
+        <SeekBar
+            android:id="@+id/fragment3dbrightnessBar1"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:layout_marginEnd="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp" />
 
-                </LinearLayout>
+    </LinearLayout>
 
-                <Button
-                    android:id="@+id/fragment3dUpBrightness"
-                    android:layout_width="60dp"
-                    android:layout_height="fill_parent"
-                    android:onClick="ButtonBrightness"
-                    android:text="@string/Up" />
+    <Button
+        android:id="@+id/fragment3dUpBrightness"
+        android:layout_width="60dp"
+        android:layout_height="fill_parent"
+        android:onClick="ButtonBrightness"
+        android:text="@string/Up" />
 
-            </LinearLayout>
-           
+</LinearLayout>
diff --git a/src/main/res/layout/fragment3dchroma.xml b/src/main/res/layout/fragment3dchroma.xml
index 9efccbf..d3eae88 100644
--- a/src/main/res/layout/fragment3dchroma.xml
+++ b/src/main/res/layout/fragment3dchroma.xml
@@ -1,72 +1,72 @@
 <?xml version="1.0" encoding="utf-8"?>
-            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                          android:id="@+id/fragment3dRowChroma"
-                          android:orientation="horizontal"
-                          android:layout_width="match_parent"
-                          android:layout_height="wrap_content" >
 
-                <LinearLayout
-                    android:layout_width="0dp"
-                    android:layout_height="match_parent"
-                    android:layout_weight="0.70"
-                    android:orientation="vertical" >
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/fragment3dRowChroma"
+              android:orientation="horizontal"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content" >
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="0.70"
+        android:orientation="vertical" >
 
-                    <TextView
-                        android:id="@+id/fragment3dchromaText"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginStart="5dp"
-                        android:layout_marginTop="3dp"
-                        />
+        <TextView
+            android:id="@+id/fragment3dchromaText"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="5dp"
+            android:layout_marginStart="5dp"
+            android:layout_marginTop="3dp" />
 
-                    <SeekBar
-                        android:id="@+id/fragment3dchromaBar1"
-                        android:layout_width="fill_parent"
-                        android:layout_height="wrap_content"
-                        android:layout_gravity="end"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginLeft="5dp"
-                        android:layout_marginRight="5dp" />
+        <SeekBar
+            android:id="@+id/fragment3dchromaBar1"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:layout_marginEnd="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp" />
 
-                    <LinearLayout
-                        android:orientation="horizontal"
-                        android:layout_width="match_parent"
-                        android:layout_height="match_parent">
+        <LinearLayout
+            android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
 
-                        <SeekBar
-                            android:id="@+id/fragment3dchromaBar2"
-                            android:layout_width="fill_parent"
-                            android:layout_height="wrap_content"
-                            android:layout_marginLeft="5dp"
-                            android:layout_marginRight="5dp"
-                            android:layout_weight="0.33"/>
+            <SeekBar
+                android:id="@+id/fragment3dchromaBar2"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="5dp"
+                android:layout_marginRight="5dp"
+                android:layout_weight="0.33"/>
 
-                        <SeekBar
-                            android:id="@+id/fragment3dchromaBar3"
-                            android:layout_width="fill_parent"
-                            android:layout_height="wrap_content"
-                            android:layout_marginEnd="5dp"
-                            android:layout_marginLeft="5dp"
-                            android:layout_marginRight="5dp"
-                            android:layout_weight="0.33"/>
+            <SeekBar
+                android:id="@+id/fragment3dchromaBar3"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginEnd="5dp"
+                android:layout_marginLeft="5dp"
+                android:layout_marginRight="5dp"
+                android:layout_weight="0.33"/>
 
-                        <SeekBar
-                            android:id="@+id/fragment3dchromaBar4"
-                            android:layout_width="fill_parent"
-                            android:layout_height="wrap_content"
-                            android:layout_marginRight="5dp"
-                            android:layout_marginLeft="5dp"
-                            android:layout_weight="0.33"/>
-                    </LinearLayout>
+            <SeekBar
+                android:id="@+id/fragment3dchromaBar4"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginRight="5dp"
+                android:layout_marginLeft="5dp"
+                android:layout_weight="0.33"/>
 
-                </LinearLayout>
+        </LinearLayout>
 
-                <Button
-                    android:id="@+id/fragment3dUpChroma"
-                    android:layout_width="60dp"
-                    android:layout_height="fill_parent"
-                    android:onClick="ButtonChroma"
-                    android:text="@string/Up" />
+    </LinearLayout>
 
-            </LinearLayout>
+    <Button
+        android:id="@+id/fragment3dUpChroma"
+        android:layout_width="60dp"
+        android:layout_height="fill_parent"
+        android:onClick="ButtonChroma"
+        android:text="@string/Up" />
+
+</LinearLayout>
diff --git a/src/main/res/layout/fragment3dlayout.xml b/src/main/res/layout/fragment3dlayout.xml
index c959a5f..844ac60 100644
--- a/src/main/res/layout/fragment3dlayout.xml
+++ b/src/main/res/layout/fragment3dlayout.xml
@@ -13,42 +13,56 @@
     <LinearLayout
         android:orientation="horizontal"
         android:layout_width="match_parent"
-        android:layout_height="50dp">
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="5dp"
+        android:background="@android:color/holo_green_dark">
 
-        <Button
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/chroma"
-            android:id="@+id/newChroma"
-            android:onClick="newChroma"/>
+        <LinearLayout
+            android:orientation="vertical"
+            android:layout_width="0dp"
+            android:layout_height="match_parent"
+            android:layout_weight="0.8">
 
-        <Button
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/alpha"
-            android:id="@+id/newAlpha"
-            android:onClick="newAlpha"/>
+            <TextView
+                android:id="@+id/fragment3dcenterText"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginEnd="5dp"
+                android:layout_marginStart="5dp"
+                android:layout_marginTop="3dp"
+                />
 
-        <Button
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/brightness"
-            android:id="@+id/newBrigthness"
-            android:onClick="newBrightness"/>
+            <LinearLayout
+                android:orientation="horizontal"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                >
 
-        <Button
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/saturation"
-            android:id="@+id/newSaturation"
-            android:onClick="newSaturation"/>
+                <SeekBar
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/fragment3dcenterX"
+                    android:layout_weight="0.5"
+                    android:paddingLeft="5dp"
+                    android:paddingRight="3dp"/>
+
+                <SeekBar
+                    android:layout_width="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/fragment3dcenterY"
+                    android:layout_weight="0.5"
+                    android:paddingLeft="3dp"
+                    android:paddingRight="5dp"/>
+            </LinearLayout>
+
+        </LinearLayout>
 
         <Button
             android:id="@+id/buttonDefault"
-            android:layout_width="fill_parent"
+            android:layout_width="60dp"
             android:layout_height="wrap_content"
-            android:onClick="Remove"
-            android:text="@string/removebut"
+            android:onClick="Default"
+            android:text="@string/reset"
             android:layout_gravity="right"
             android:layout_marginTop="3dp"/>
     </LinearLayout>
diff --git a/src/main/res/layout/fragment3dsaturation.xml b/src/main/res/layout/fragment3dsaturation.xml
index 48020b1..1a7e905 100644
--- a/src/main/res/layout/fragment3dsaturation.xml
+++ b/src/main/res/layout/fragment3dsaturation.xml
@@ -1,41 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
-            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                          android:id="@+id/fragment3dRowSaturation"
-                          android:orientation="horizontal"
-                          android:layout_width="match_parent"
-                          android:layout_height="wrap_content" >
 
-                <LinearLayout
-                    android:layout_width="0dp"
-                    android:layout_height="match_parent"
-                    android:layout_weight="0.70"
-                    android:orientation="vertical" >
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:id="@+id/fragment3dRowSaturation"
+              android:orientation="horizontal"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content" >
 
-                    <TextView
-                        android:id="@+id/fragment3dsaturationText"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginStart="5dp"
-                        android:layout_marginTop="3dp"
-                        />
+    <LinearLayout
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_weight="0.70"
+        android:orientation="vertical" >
 
-                    <SeekBar
-                        android:id="@+id/fragment3dsaturationBar1"
-                        android:layout_width="fill_parent"
-                        android:layout_height="wrap_content"
-                        android:layout_gravity="end"
-                        android:layout_marginEnd="5dp"
-                        android:layout_marginLeft="5dp"
-                        android:layout_marginRight="5dp" />
+        <TextView
+            android:id="@+id/fragment3dsaturationText"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginEnd="5dp"
+            android:layout_marginStart="5dp"
+            android:layout_marginTop="3dp" />
 
-                </LinearLayout>
+        <SeekBar
+            android:id="@+id/fragment3dsaturationBar1"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="end"
+            android:layout_marginEnd="5dp"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp" />
 
-                <Button
-                    android:id="@+id/fragment3dUpSaturation"
-                    android:layout_width="60dp"
-                    android:layout_height="fill_parent"
-                    android:onClick="ButtonSaturation"
-                    android:text="@string/Up" />
+    </LinearLayout>
 
-            </LinearLayout>
+    <Button
+        android:id="@+id/fragment3dUpSaturation"
+        android:layout_width="60dp"
+        android:layout_height="fill_parent"
+        android:onClick="ButtonSaturation"
+        android:text="@string/Up" />
+
+</LinearLayout>
diff --git a/src/main/res/layout/movingeffectslayout.xml b/src/main/res/layout/movingeffectslayout.xml
index 799e1c3..c312344 100644
--- a/src/main/res/layout/movingeffectslayout.xml
+++ b/src/main/res/layout/movingeffectslayout.xml
@@ -64,7 +64,7 @@
             android:onClick="Transparency"
             android:paddingLeft="5dp"
             android:paddingRight="5dp"
-            android:text="@string/transparency" />
+            android:text="@string/alpha" />
 
         <Button
             android:id="@+id/movingeffectsMacro"
