private void createCompassRosePicture ( ) { // Paint design of north triangle (it's common to paint north in red color) final Paint northPaint = new Paint ( ) ; northPaint . setColor ( 0xFFA00000 ) ; northPaint . setAntiAlias ( true ) ; northPaint . setStyle ( Style . FILL ) ; northPaint . setAlpha ( 220 ) ; // Paint design of south triangle (black) final Paint southPaint = new Paint ( ) ; southPaint . setColor ( Color . BLACK ) ; southPaint . setAntiAlias ( true ) ; southPaint . setStyle ( Style . FILL ) ; southPaint . setAlpha ( 220 ) ; // Create a little white dot in the middle of the compass rose final Paint centerPaint = new Paint ( ) ; centerPaint . setColor ( Color . WHITE ) ; centerPaint . setAntiAlias ( true ) ; centerPaint . setStyle ( Style . FILL ) ; centerPaint . setAlpha ( 220 ) ; final int picBorderWidthAndHeight = ( int ) ( ( mCompassRadius + 5 ) * 2 * mScale ) ; final int center = picBorderWidthAndHeight / 2 ; if ( mCompassRoseBitmap != null ) mCompassRoseBitmap . recycle ( ) ; mCompassRoseBitmap = Bitmap . createBitmap ( picBorderWidthAndHeight , picBorderWidthAndHeight , Config . ARGB_8888 ) ; final Canvas canvas = new Canvas ( mCompassRoseBitmap ) ; // Triangle pointing north final Path pathNorth = new Path ( ) ; pathNorth . moveTo ( center , center - ( mCompassRadius - 3 ) * mScale ) ; pathNorth . lineTo ( center + 4 * mScale , center ) ; pathNorth . lineTo ( center - 4 * mScale , center ) ; pathNorth . lineTo ( center , center - ( mCompassRadius - 3 ) * mScale ) ; pathNorth . close ( ) ; canvas . drawPath ( pathNorth , northPaint ) ; // Triangle pointing south final Path pathSouth = new Path ( ) ; pathSouth . moveTo ( center , center + ( mCompassRadius - 3 ) * mScale ) ; pathSouth . lineTo ( center + 4 * mScale , center ) ; pathSouth . lineTo ( center - 4 * mScale , center ) ; pathSouth . lineTo ( center , center + ( mCompassRadius - 3 ) * mScale ) ; pathSouth . close ( ) ; canvas . drawPath ( pathSouth , southPaint ) ; // Draw a little white dot in the middle canvas . drawCircle ( center , center , 2 , centerPaint ) ; }
A conventional red and black compass needle .