Code example for Canvas

Methods: drawBitmap, drawRect, drawText, restoreToCount, rotate, save

0
		mMatrix.reset();
 
		if ( null != mShadowBitmap ) {
			bmp = mShadowBitmap.get();
			if ( null != bmp ) {
				canvas.drawBitmap( bmp, mMatrix, mPaint );
			} 
		} 
 
		// colored background 
		mPaint.setColor( mColor );
		canvas.drawRect( 17 / xRatio, 37 / yRatio, 145 / xRatio, 225 / yRatio, mPaint );
 
		int saveCount = canvas.save( Canvas.MATRIX_SAVE_FLAG );
		canvas.rotate( 90 );
 
		// SHORT TITLE 
		mPaint.setColor( Color.BLACK );
		mPaint.setTextSize( leftTextSize );
		canvas.drawText( mShortTitle, 66 / xRatio, -26 / yRatio, mPaint );
 
		// TITLE 
		mPaint.setTextSize( titleTextSize );
		canvas.drawText( mTitle, 69 / xRatio, -88 / yRatio, mPaint );
 
		// NUM EFFECTS 
		mPaint.setARGB( 255, 35, 31, 42 );
		canvas.drawRect( 135 / yRatio, -16 / xRatio, 216 / yRatio, -57 / xRatio, mPaint );
		mPaint.setColor( Color.WHITE );
		mPaint.setTextSize( leftTextSize );
		String text = mNumEffects + "fx";
		int numEffectsLength = String.valueOf( mNumEffects ).length();
		canvas.drawText( text, ( 160 - ( numEffectsLength * 10 ) ) / xRatio, -26 / yRatio, mPaint );
 
		// restore canvas 
		canvas.restoreToCount( saveCount );
 
		// cannister 
		if ( null != mEffectBitmap ) {
			bmp = mEffectBitmap.get();
			if ( null != bmp ) {
				canvas.drawBitmap( bmp, mMatrix, mPaint );
			} 
		} 
	} 
 
	@Override 
	public int getOpacity() { 
		return PixelFormat.TRANSLUCENT;