Code example for RectF

Methods: contains, height, width

0
			mLastTouchedPanel = PANEL_HUE;
 
			mHue = pointToHue(event.getY());
 
			update = true;
		} else if (mSatValRect.contains(startX, startY)) {
 
			mLastTouchedPanel = PANEL_SAT_VAL;
 
			final float[] result = pointToSatVal(event.getX(), event.getY());
 
			mSat = result[0];
			mVal = result[1];
 
			update = true;
		} else if (mAlphaRect != null && mAlphaRect.contains(startX, startY)) {
 
			mLastTouchedPanel = PANEL_ALPHA;
 
			mAlpha = pointToAlpha((int) event.getX());
 
			update = true;
		} 
 
		return update;
	} 
 
	private int pointToAlpha(int x) {
 
		final RectF rect = mAlphaRect;
		final int width = (int) rect.width();
 
		if (x < rect.left) {
			x = 0;
		} else if (x > rect.right) {
			x = width;
		} else { 
			x = x - (int) rect.left;
		} 
 
		return 0xff - x * 0xff / width;
 
	} 
 
	private float pointToHue(float y) {
 
		final RectF rect = mHueRect;
 
		final float height = rect.height();
 
		if (y < rect.top) {
			y = 0f;
		} else if (y > rect.bottom) {
			y = height;
		} else { 
			y = y - rect.top;
		} 
 
		return 360f - y * 360f / height;
	} 
 
	private float[] pointToSatVal(float x, float y) {
 
		final RectF rect = mSatValRect;
		final float[] result = new float[2];
 
		final float width = rect.width();
		final float height = rect.height();
 
		if (x < rect.left) {
			x = 0f;
		} else if (x > rect.right) {
			x = width;