private void buildPieces(){
  pieces=new Piece[pathArray.size()];
  Paint paint=new Paint();
  Matrix matrix=new Matrix();
  Canvas canvas=new Canvas();
  for (int i=0; i < pieces.length; i++) {
    int shadow=Utils.nextInt(Utils.dp2px(2),Utils.dp2px(9));
    Path path=pathArray.get(i);
    RectF r=new RectF();
    path.computeBounds(r,true);
    Bitmap pBitmap=Utils.createBitmapSafely((int)r.width() + shadow * 2,(int)r.height() + shadow * 2,Bitmap.Config.ARGB_4444,1);
    if (pBitmap == null) {
      pieces[i]=new Piece(-1,-1,null,shadow);
      continue;
    }
    pieces[i]=new Piece((int)r.left + mTouchPoint.x - shadow,(int)r.top + mTouchPoint.y - shadow,pBitmap,shadow);
    canvas.setBitmap(pieces[i].bitmap);
    BitmapShader mBitmapShader=new BitmapShader(mBitmap,Shader.TileMode.CLAMP,Shader.TileMode.CLAMP);
    matrix.reset();
    matrix.setTranslate(-r.left - offsetX + shadow,-r.top - offsetY + shadow);
    mBitmapShader.setLocalMatrix(matrix);
    paint.reset();
    Path offsetPath=new Path();
    offsetPath.addPath(path,-r.left + shadow,-r.top + shadow);
    paint.setStyle(Paint.Style.FILL);
    paint.setShadowLayer(shadow,0,0,0xff333333);
    canvas.drawPath(offsetPath,paint);
    paint.setShadowLayer(0,0,0,0);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.XOR));
    canvas.drawPath(offsetPath,paint);
    paint.setXfermode(null);
    paint.setShader(mBitmapShader);
    paint.setAlpha(0xcc);
    canvas.drawPath(offsetPath,paint);
  }
  Arrays.sort(pieces);
}

private void buildPieces ( ) { pieces = new Piece [ pathArray . size ( ) ] ; Paint paint = new Paint ( ) ; Matrix matrix = new Matrix ( ) ; Canvas canvas = new Canvas ( ) ; for ( int i = 0 ; i < pieces . length ; i ++ ) { int shadow = Utils . nextInt ( Utils . dp2px ( 2 ) , Utils . dp2px ( 9 ) ) ; Path path = pathArray . get ( i ) ; RectF r = new RectF ( ) ; path . computeBounds ( r , true ) ; Bitmap pBitmap = Utils . createBitmapSafely ( ( int ) r . width ( ) + shadow * 2 , ( int ) r . height ( ) + shadow * 2 , Bitmap . Config . ARGB_4444 , 1 ) ; if ( pBitmap == null ) { pieces [ i ] = new Piece ( - 1 , - 1 , null , shadow ) ; continue ; } pieces [ i ] = new Piece ( ( int ) r . left + mTouchPoint . x - shadow , ( int ) r . top + mTouchPoint . y - shadow , pBitmap , shadow ) ; canvas . setBitmap ( pieces [ i ] . bitmap ) ; BitmapShader mBitmapShader = new BitmapShader ( mBitmap , Shader . TileMode . CLAMP , Shader . TileMode . CLAMP ) ; matrix . reset ( ) ; matrix . setTranslate ( - r . left - offsetX + shadow , - r . top - offsetY + shadow ) ; mBitmapShader . setLocalMatrix ( matrix ) ; paint . reset ( ) ; Path offsetPath = new Path ( ) ; offsetPath . addPath ( path , - r . left + shadow , - r . top + shadow ) ; paint . setStyle ( Paint . Style . FILL ) ; paint . setShadowLayer ( shadow , 0 , 0 , 0xff333333 ) ; canvas . drawPath ( offsetPath , paint ) ; paint . setShadowLayer ( 0 , 0 , 0 , 0 ) ; paint . setXfermode ( new PorterDuffXfermode ( PorterDuff . Mode . XOR ) ) ; canvas . drawPath ( offsetPath , paint ) ; paint . setXfermode ( null ) ; paint . setShader ( mBitmapShader ) ; paint . setAlpha ( 0xcc ) ; canvas . drawPath ( offsetPath , paint ) ; } Arrays . sort ( pieces ) ; }
build the final bitmap - pieces to draw in animation
