RectF centerX - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for RectF centerX method.

This code example shows how to use the following methods:centerX, centerY, height, width
     * @param startAngle The starting angle of the arc in degrees 
     * @param angleExtent The angle extent of the arc in degrees 
     * @param useCenter If true, include the center of the oval in the arc, and close it if it is being stroked 
     */ 
    public ArcShape(float x, float y, float width, float height, float startAngle, float angleExtent, boolean useCenter) {
        this.mOval = new RectF(x, y, x + width, y + height);
        this.mStartAngle = startAngle;
        this.mAngleExtent = angleExtent;
        this.mPath = new Path();
        this.mStartPoint = new PointF();
        this.mEndPoint = new PointF();
        this.mUseCenter = useCenter;
        this.mRegion = new Region();
        update(); 
    } 
 
    /** 
     * Creates a new arc shap from specified location, size, double angles, and useCenter values. 
     * @param x The x-coordinate of upper-left corner of the arc 
     * @param y The y-coordinate of upper-left corner of the arc 

7
CodeRank
This code example shows how to use the following methods:centerX, centerY
	 *  
	 * @see android.graphics.drawable.Drawable#draw(android.graphics.Canvas) 
	 */ 
	@Override 
	public void draw( final Canvas canvas ) {
		final RectF rect = new RectF( getBounds() );
		canvas.drawCircle( rect.centerX(), rect.centerY(), mRadius, mPaint );
	} 
 
	/* 
	 * (non-Javadoc) 
	 *  
	 * @see android.graphics.drawable.Drawable#getOpacity() 
	 */ 
	@Override 
	public int getOpacity() { 
		return PixelFormat.OPAQUE;
	} 
 
	/* 
7
CodeRank
This code example shows how to use the following methods:centerX, centerY, width
7
CodeRank
This code example shows how to use the following methods:centerX, centerY, height, set, width
     * @param r rectangle to resize 
     * @param w new width aspect 
     * @param h new height aspect 
     */ 
    public static void fixAspectRatio(RectF r, float w, float h) {
        float scale = Math.min(r.width() / w, r.height() / h);
        float centX = r.centerX();
        float centY = r.centerY();
        float hw = scale * w / 2;
        float hh = scale * h / 2;
        r.set(centX - hw, centY - hh, centX + hw, centY + hh);
    } 
 
    /** 
     * Resizes rectangle to have a certain aspect ratio (center remains 
     * stationary) while constraining it to remain within the original rect. 
     * 
     * @param r rectangle to resize 
     * @param w new width aspect 
     * @param h new height aspect 
7
CodeRank
This code example shows how to use the following methods:centerX, centerY, height, width
 
public final class Util { 
    public static final boolean pointInOval(RectF oval, float x, float y) {
        float dx, dy, c, d;
 
        dx = x - oval.centerX();
        dy = y - oval.centerY();
 
        d = oval.height();
        c = d/oval.width();
 
        return dx*c*dx*c + dy*dy <= d*d/4;
    } 
} 
6
CodeRank
This code example shows how to use the following methods:centerX, centerY, contains, inset
	 *           the y 
	 * @return the hit 
	 */ 
	public int getHit( float x, float y ) {
 
		final RectF rect = new RectF( mDrawRect );
		rect.inset( -mPadding, -mPadding );
 
		final float pts[] = new float[] { x, y };
 
		final Matrix rotateMatrix = new Matrix();
		rotateMatrix.postTranslate( -rect.centerX(), -rect.centerY() );
		rotateMatrix.postRotate( -mRotation );
		rotateMatrix.postTranslate( rect.centerX(), rect.centerY() );
		rotateMatrix.mapPoints( pts );
 
		x = pts[0];
		y = pts[1];
 
		mContext.invalidate();

6
CodeRank
This code example shows how to use the following methods:centerX, centerY, width
	} 
 
	private Point alphaToPoint(final int alpha) {
 
		final RectF rect = mAlphaRect;
		final float width = rect.width();
 
		final Point p = new Point();
 
		p.x = (int) (width - alpha * width / 0xff + rect.left);
		p.y = (int) rect.top;
 
		return p;
 
	} 
 
	private int[] buildHueColorArray() { 
 
		final int[] hue = new int[361];
 

6
CodeRank
This code example shows how to use the following methods:centerX, centerY, height, offset, width
     * レンダリングエリアよりイメージエリアのほうが狭かったら、中心寄せに補正する。 
     */ 
    public void correctImageArea(boolean xCrrect, boolean yCorrect) {
 
        if (xCrrect) {
            if (imageArea.width() < renderArea.width()) {
                imageArea.offset(renderArea.centerX() - imageArea.centerX(), 0);
            } else { 
                if (imageArea.left > renderArea.left) {
                    imageArea.offset(renderArea.left - imageArea.left, 0);
                } else if (imageArea.right < renderArea.right) {
                    imageArea.offset(renderArea.right - imageArea.right, 0);
                } 
            } 
        } 
 
        if (yCorrect) {
            if (imageArea.height() < renderArea.height()) {
                imageArea.offset(0, renderArea.centerY() - imageArea.centerY());
            } else { 

6
CodeRank
This code example shows how to use the following methods:centerX, centerY, height, width
        } 
    } 
 
    public static void drawWallpaperSelectionFrame(Canvas canvas, RectF cropBounds, float spotX,
            float spotY, Paint p, Paint shadowPaint) {
        float sx = cropBounds.width() * spotX;
        float sy = cropBounds.height() * spotY;
        float cx = cropBounds.centerX();
        float cy = cropBounds.centerY();
        RectF r1 = new RectF(cx - sx / 2, cy - sy / 2, cx + sx / 2, cy + sy / 2);
        float temp = sx;
        sx = sy;
        sy = temp;
        RectF r2 = new RectF(cx - sx / 2, cy - sy / 2, cx + sx / 2, cy + sy / 2);
        canvas.save();
        canvas.clipRect(cropBounds);
        canvas.clipRect(r1, Region.Op.DIFFERENCE);
        canvas.clipRect(r2, Region.Op.DIFFERENCE);
        canvas.drawPaint(shadowPaint);
        canvas.restore();
6
CodeRank
This code example shows how to use the following methods:centerX
    /** 
     * Returns center x-coordinate of oval. 
     * @return center x-coordinate of oval 
     */ 
    public float getCenterX() { 
        return mOval.centerX();
    } 
     
    /** 
     * Returns minimum y-coordinate of oval. 
     * @return minimum y-coordinate of oval 
     */ 
    public float getMinY() { 
    	return getY(); 
    } 
     
    /** 
     * Returns maximum y-coordinate of oval. 
     * @return maximum y-coordinate of oval 
     */ 
6
CodeRank

Related RectF centerX Questions & Answers:

centerX Method Overview
See Code Examples for other Android RectF Methods: