当前位置: 首页>>代码示例>>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;未经允许,请勿转载。