當前位置: 首頁>>代碼示例>>Java>>正文


Java RectF.setEmpty方法代碼示例

本文整理匯總了Java中android.graphics.RectF.setEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java RectF.setEmpty方法的具體用法?Java RectF.setEmpty怎麽用?Java RectF.setEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.RectF的用法示例。


在下文中一共展示了RectF.setEmpty方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateDrawableBounds

import android.graphics.RectF; //導入方法依賴的package包/類
private void updateDrawableBounds(DrawableInfo drawableInfo) {
    final Drawable drawable = drawableInfo.mDrawable;

    final float radius = mSteinerCircleRadius;
    if (radius <= 0) {
        drawable.setBounds(0, 0, 0, 0);
        return;
    }


    final int dWidth = drawable.getIntrinsicWidth();
    final int dHeight = drawable.getIntrinsicHeight();

    final RectF bounds = mTempBounds;
    bounds.setEmpty();

    if (dWidth <= 0 || dHeight <= 0 || dWidth == dHeight || FitType.FIT == mFitType) {
        bounds.inset(-radius, -radius);
    } else {
        float scale;
        if (dWidth > dHeight) {
            scale = radius / (float) dHeight;
        } else {
            scale = radius / (float) dWidth;
        }
        bounds.inset(-dWidth * scale, -dHeight * scale);

        if (FitType.START == mFitType || FitType.END == mFitType) {
            int dir = FitType.START == mFitType ? 1 : -1;
            bounds.offset((bounds.width() * 0.5f - radius) * dir,
                    (bounds.height() * 0.5f - radius) * dir);
        }
    }

    bounds.offset(drawableInfo.mCenterX, drawableInfo.mCenterY);
    drawable.setBounds((int) bounds.left, (int) bounds.top,
            Math.round(bounds.right), Math.round(bounds.bottom));
}
 
開發者ID:YiiGuxing,項目名稱:CompositionAvatar,代碼行數:39,代碼來源:CompositionAvatarView.java

示例2: resetInstance

import android.graphics.RectF; //導入方法依賴的package包/類
@Override
protected RectF resetInstance(RectF obj) {
    obj.setEmpty();
    return obj;
}
 
開發者ID:ZhouKanZ,項目名稱:SweepRobot,代碼行數:6,代碼來源:PinchImageView.java

示例3: strokeTo

import android.graphics.RectF; //導入方法依賴的package包/類
public RectF strokeTo(CanvasLite c, float x, float y, float r) {
    final RectF dirty = tmpDirtyRectF;
    dirty.setEmpty();
    
    if (mLastR < 0) {
        // always draw the first point
        drawStrokePoint(c,x,y,r,dirty);
    } else {
        // connect the dots, la-la-la
        
        mLastLen = dist(mLastX, mLastY, x, y);
        float xi, yi, ri, frac;
        float d = 0;
        while (true) {
            if (d > mLastLen) {
                break;
            }
            frac = d == 0 ? 0 : (d / mLastLen);
            ri = lerp(mLastR, r, frac);
            xi = lerp(mLastX, x, frac);
            yi = lerp(mLastY, y, frac);
            drawStrokePoint(c,xi,yi,ri,dirty);

            // for very narrow lines we must step (not much more than) one radius at a time
            final float MIN = 1f;
            final float THRESH = 16f;
            final float SLOPE = 0.1f; // asymptote: the spacing will increase as SLOPE*x
            if (ri <= THRESH) {
                d += MIN;
            } else {
                d += Math.sqrt(SLOPE * Math.pow(ri - THRESH, 2) + MIN);
            }
        }
        
        /* 
        // for curved paths
        Path p = mWorkPath;
        p.reset();
        p.moveTo(mLastX, mLastY);
        p.lineTo(x, y);
        
        PathMeasure pm = mWorkPathMeasure;
        pm.setPath(p, false);
        mLastLen = pm.getLength();
        float d = 0;
        float posOut[] = new float[2];
        float ri;
        while (true) {
            if (d > mLastLen) {
                d = mLastLen;
            }
            pm.getPosTan(d, posOut, mTan);
            // denormalize
            mTan[0] *= mLastLen; mTan[1] *= mLastLen;

            ri = lerp(mLastR, r, d / mLastLen);
            c.drawCircle(posOut[0], posOut[1], ri, mPaint);
            dirty.union(posOut[0] - ri, posOut[1] - ri, posOut[0] + ri, posOut[1] + ri);

            if (d == mLastLen) break;
            d += Math.min(ri, WALK_STEP_PX); // for very narrow lines we must step one radius at a time
        }
        */
    }

    mLastX = x;
    mLastY = y;
    mLastR = r;
    
    return dirty;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:72,代碼來源:Slate.java


注:本文中的android.graphics.RectF.setEmpty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。