private void createShader(){
  mDefaultAngularFrequency=2.0f * Math.PI / DEFAULT_WAVE_LENGTH_RATIO / getWidth();
  mDefaultAmplitude=getHeight() * DEFAULT_AMPLITUDE_RATIO;
  mDefaultWaterLevel=getHeight() * DEFAULT_WATER_LEVEL_RATIO;
  mDefaultWaveLength=getWidth();
  Bitmap bitmap=Bitmap.createBitmap(getWidth(),getHeight(),Bitmap.Config.ARGB_8888);
  Canvas canvas=new Canvas(bitmap);
  Paint wavePaint=new Paint();
  wavePaint.setStrokeWidth(2);
  wavePaint.setAntiAlias(true);
  final int endX=getWidth() + 1;
  final int endY=getHeight() + 1;
  float[] waveY=new float[endX];
  wavePaint.setColor(mBehindWaveColor);
  for (int beginX=0; beginX < endX; beginX++) {
    double wx=beginX * mDefaultAngularFrequency;
    float beginY=(float)(mDefaultWaterLevel + mDefaultAmplitude * Math.sin(wx));
    canvas.drawLine(beginX,beginY,beginX,endY,wavePaint);
    waveY[beginX]=beginY;
  }
  wavePaint.setColor(mFrontWaveColor);
  final int wave2Shift=(int)(mDefaultWaveLength / 4);
  for (int beginX=0; beginX < endX; beginX++) {
    canvas.drawLine(beginX,waveY[(beginX + wave2Shift) % endX],beginX,endY,wavePaint);
  }
  mWaveShader=new BitmapShader(bitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
  mViewPaint.setShader(mWaveShader);
}

private void createShader ( ) { mDefaultAngularFrequency = 2.0f * Math . PI / DEFAULT_WAVE_LENGTH_RATIO / getWidth ( ) ; mDefaultAmplitude = getHeight ( ) * DEFAULT_AMPLITUDE_RATIO ; mDefaultWaterLevel = getHeight ( ) * DEFAULT_WATER_LEVEL_RATIO ; mDefaultWaveLength = getWidth ( ) ; Bitmap bitmap = Bitmap . createBitmap ( getWidth ( ) , getHeight ( ) , Bitmap . Config . ARGB_8888 ) ; Canvas canvas = new Canvas ( bitmap ) ; Paint wavePaint = new Paint ( ) ; wavePaint . setStrokeWidth ( 2 ) ; wavePaint . setAntiAlias ( true ) ; final int endX = getWidth ( ) + 1 ; final int endY = getHeight ( ) + 1 ; float [ ] waveY = new float [ endX ] ; wavePaint . setColor ( mBehindWaveColor ) ; for ( int beginX = 0 ; beginX < endX ; beginX ++ ) { double wx = beginX * mDefaultAngularFrequency ; float beginY = ( float ) ( mDefaultWaterLevel + mDefaultAmplitude * Math . sin ( wx ) ) ; canvas . drawLine ( beginX , beginY , beginX , endY , wavePaint ) ; waveY [ beginX ] = beginY ; } wavePaint . setColor ( mFrontWaveColor ) ; final int wave2Shift = ( int ) ( mDefaultWaveLength / 4 ) ; for ( int beginX = 0 ; beginX < endX ; beginX ++ ) { canvas . drawLine ( beginX , waveY [ ( beginX + wave2Shift ) % endX ] , beginX , endY , wavePaint ) ; } mWaveShader = new BitmapShader ( bitmap , Shader . TileMode . REPEAT , Shader . TileMode . CLAMP ) ; mViewPaint . setShader ( mWaveShader ) ; }
create the shader with default waves which repeat horizontally , and clamp vertically
