Code example for Canvas

Methods: drawBitmapdrawRGBdrawRectrestoresavetranslate

0
        } 
 
        @Override 
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            canvas.drawRGB(255, 255, 255);
 
            canvas.save();
            canvas.translate(40.0f, 40.0f);
 
            drawBlendedBitmap(canvas, PorterDuff.Mode.DARKEN);
            drawBlendedBitmap(canvas, PorterDuff.Mode.LIGHTEN);
            drawBlendedBitmap(canvas, PorterDuff.Mode.MULTIPLY);
 
            canvas.restore();
 
            canvas.save();
            canvas.translate(40.0f + mTexWidth + 40.0f, 40.0f);
 
            drawBlendedBitmap(canvas, PorterDuff.Mode.SCREEN);
            drawBlendedBitmap(canvas, PorterDuff.Mode.ADD);
            drawBlendedBitmapInverse(canvas, PorterDuff.Mode.OVERLAY);
 
            canvas.restore();
        } 
 
        private void drawBlendedBitmap(Canvas canvas, PorterDuff.Mode mode) {
            mPaint.setShader(null);
            mPaint.setXfermode(null);
            canvas.drawBitmap(mTexture, 0.0f, 0.0f, mPaint);
 
            mPaint.setShader(mHorGradient);
            mPaint.setXfermode(new PorterDuffXfermode(mode));
            canvas.drawRect(0.0f, 0.0f, mTexWidth, mTexHeight, mPaint);
 
            canvas.translate(0.0f, 40.0f + mTexHeight);
        } 
 
        private void drawBlendedBitmapInverse(Canvas canvas, PorterDuff.Mode mode) {
            mPaint.setXfermode(null);
            mPaint.setShader(mHorGradient);
            canvas.drawRect(0.0f, 0.0f, mTexWidth, mTexHeight, mPaint);
 
            mPaint.setXfermode(new PorterDuffXfermode(mode));
            mPaint.setShader(null);
            canvas.drawBitmap(mTexture, 0.0f, 0.0f, mPaint);
 
            canvas.translate(0.0f, 40.0f + mTexHeight);
        } 
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java