Code example for Paint

Methods: getColor, getStrokeWidth, setAlpha, setStyle

0
    private boolean mHighlightCenter;
 
    @Override  
    protected void onDraw(Canvas canvas) {
		float outer_radius = Math.min(getWidth(), getHeight())/2;
 		float touch_feedback_ring = center_radius + 2*mCenterPaint.getStrokeWidth();
        float r = (outer_radius + touch_feedback_ring) / 2;
         
        canvas.translate(getWidth()/2, getHeight()/2);
         
        mPaint.setStrokeWidth(outer_radius - touch_feedback_ring);
         
        // This is the main "color ring" 
        canvas.drawCircle(0, 0, r, mPaint);       
 
        // This is the center "activation button" circle 
        canvas.drawCircle(0, 0, center_radius, mCenterPaint);
         
        if (mTrackingCenter) {
            int c = mCenterPaint.getColor();
            mCenterPaint.setStyle(Paint.Style.STROKE);
             
            if (mHighlightCenter) {
                mCenterPaint.setAlpha(0xFF);
            } else { 
                mCenterPaint.setAlpha(0x80);
            } 
             
            // The skinny ring around the center to indicate that it is being pressed 
            canvas.drawCircle(0, 0,
            		center_radius + mCenterPaint.getStrokeWidth(),
                              mCenterPaint);
             
            mCenterPaint.setStyle(Paint.Style.FILL);
            mCenterPaint.setColor(c);
        } 
    }