@Override
  public void draw(Canvas canvas) {
    super.draw(canvas);
    if (mPaint == null) mPaint = new Paint();

    if (mShader != null) {
      mShaderBitmap =
          Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
      Canvas tempCanvas = new Canvas(mShaderBitmap);
      Paint paint = new Paint();
      paint.setShader(mShader);
      tempCanvas.drawPaint(paint);
    }
    if (mVerts != null) {
      canvas.drawBitmapMesh(mBitmap, 50, 5, mVerts, 0, null, 0, null);
      if (mShaderBitmap != null)
        canvas.drawBitmapMesh(mShaderBitmap, 50, 5, mVerts, 0, null, 0, null);
    } else canvas.drawBitmap(mBitmap, new Matrix(), mPaint);
  }
Пример #2
0
 private void drawBitmapMesh(Canvas canvas) {
   if (direction) {
     delta++;
     if (delta > 20) {
       direction = false;
     }
   } else {
     delta--;
     if (delta < -20) {
       direction = true;
     }
   }
   vertixs[8] = 200 + delta;
   vertixs[9] = 200 - delta;
   canvas.drawBitmapMesh(mBitmap, 2, 2, vertixs, 0, null, 0, mPaint);
   invalidate();
 }