java类android.graphics.Path.Direction的实例源码

ClockDrawable.java 文件源码 项目:FiveMinsMore 阅读 21 收藏 0 点赞 0 评论 0
@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);

    rimRadius = Math.min(bounds.width(), bounds.height()) / 2f - rimPaint.getStrokeWidth();
    faceRadius = rimRadius - rimPaint.getStrokeWidth();
    screwRadius = rimPaint.getStrokeWidth() * 2;
    float hourHandLength = (float) (0.5 * faceRadius);
    float minuteHandLength = (float) (0.7 * faceRadius);
    float top = bounds.centerY() - screwRadius;

    hourHandPath.reset();
    hourHandPath.moveTo(bounds.centerX(), bounds.centerY());
    hourHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - hourHandLength, Direction.CCW);
    hourHandPath.close();

    minuteHandPath.reset();
    minuteHandPath.moveTo(bounds.centerX(), bounds.centerY());
    minuteHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - minuteHandLength, Direction.CCW);
    minuteHandPath.close();
}
OverlayView.java 文件源码 项目:boohee_v5.6 阅读 27 收藏 0 点赞 0 评论 0
public void setupCropBounds() {
    int height = (int) (((float) this.mThisWidth) / this.mTargetAspectRatio);
    int halfDiff;
    if (height > this.mThisHeight) {
        int width = (int) (((float) this.mThisHeight) * this.mTargetAspectRatio);
        halfDiff = (this.mThisWidth - width) / 2;
        this.mCropViewRect.set((float) (getPaddingLeft() + halfDiff), (float) getPaddingTop()
                , (float) ((getPaddingLeft() + width) + halfDiff), (float) (getPaddingTop() +
                        this.mThisHeight));
    } else {
        halfDiff = (this.mThisHeight - height) / 2;
        this.mCropViewRect.set((float) getPaddingLeft(), (float) (getPaddingTop() + halfDiff)
                , (float) (getPaddingLeft() + this.mThisWidth), (float) ((getPaddingTop() +
                        height) + halfDiff));
    }
    this.mGridPoints = null;
    this.mCircularPath.reset();
    this.mCircularPath.addOval(this.mCropViewRect, Direction.CW);
}
MaterialRippleLayout.java 文件源码 项目:boohee_v5.6 阅读 29 收藏 0 点赞 0 评论 0
public void draw(Canvas canvas) {
    boolean positionChanged = adapterPositionChanged();
    if (this.rippleOverlay) {
        if (!positionChanged) {
            this.rippleBackground.draw(canvas);
        }
        super.draw(canvas);
        if (!positionChanged) {
            if (this.rippleRoundedCorners != 0.0f) {
                Path clipPath = new Path();
                clipPath.addRoundRect(new RectF(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight()), this.rippleRoundedCorners, this.rippleRoundedCorners, Direction.CW);
                canvas.clipPath(clipPath);
            }
            canvas.drawCircle((float) this.currentCoords.x, (float) this.currentCoords.y, this.radius, this.paint);
            return;
        }
        return;
    }
    if (!positionChanged) {
        this.rippleBackground.draw(canvas);
        canvas.drawCircle((float) this.currentCoords.x, (float) this.currentCoords.y, this.radius, this.paint);
    }
    super.draw(canvas);
}
CircleIndicator.java 文件源码 项目:boohee_v5.6 阅读 52 收藏 0 点赞 0 评论 0
private void drawOutSideText(Canvas canvas) {
    Paint textPaint = new Paint();
    textPaint.setColor(this.mNormalGray);
    textPaint.setAntiAlias(true);
    textPaint.setTextSize(getResources().getDimension(R.dimen.out_indicator_size));
    int radius = getViewRadius() - this.mDividerWidth;
    Path path = new Path();
    path.addCircle((float) getCenterX(), (float) getCenterY(), (float) radius, Direction.CW);
    if (this.mDividerIndicator.size() != 0) {
        String content = BaseCircle.formatNumber(this.mStartIndicator);
        canvas.drawTextOnPath(content, path, ViewUtils.getCirclePathLength((float) radius,
                135.0f) - ((float) (ViewUtils.getTextWidth(textPaint, content) / 2)), 0.0f,
                textPaint);
        float perAngle = 270.0f / (this.mEndIndicator - this.mStartIndicator);
        for (IndicatorItem item : this.mDividerIndicator) {
            content = BaseCircle.formatNumber(item.end);
            canvas.drawTextOnPath(content, path, ViewUtils.getCirclePathLength((float)
                    radius, ((item.end - this.mStartIndicator) * perAngle) + 135.0f) - (
                    (float) (ViewUtils.getTextWidth(textPaint, content) / 2)), 0.0f, textPaint);
        }
    }
}
CircularProgressView.java 文件源码 项目:okwallet 阅读 17 收藏 0 点赞 0 评论 0
private void updatePath(final int w, final int h) {
    final float maxAbsSize = Math.min(w, h) / 2f;
    final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;

    path.reset();

    if (progress == 0) {
        path.close();
    } else if (progress < maxProgress) {
        final float angle = progress * 360 / maxProgress;
        final float x = w / 2f;
        final float y = h / 2f;

        path.moveTo(x, y);
        path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
        path.close();
    } else {
        path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
    }
}
RippleDrawable.java 文件源码 项目:MDPreference 阅读 25 收藏 0 点赞 0 评论 0
@Override
protected void onBoundsChange(Rect bounds) {        
    if(mBackgroundDrawable != null)
        mBackgroundDrawable.setBounds(bounds);

    mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
    mBackground.reset();

    switch (mMask.type) {
        case Mask.TYPE_OVAL:
            mBackground.addOval(mBackgroundBounds, Direction.CW);
            break;
        case Mask.TYPE_RECTANGLE:
            mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
            break;
    }
}
ClockDrawable.java 文件源码 项目:ClockDrawableAnimation 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void onBoundsChange(Rect bounds) {
    super.onBoundsChange(bounds);

    rimRadius = Math.min(bounds.width(), bounds.height()) / 2f - rimPaint.getStrokeWidth();
    faceRadius = rimRadius - rimPaint.getStrokeWidth();
    screwRadius = rimPaint.getStrokeWidth() * 2;
    float hourHandLength = (float) (0.5 * faceRadius);
    float minuteHandLength = (float) (0.7 * faceRadius);
    float top = bounds.centerY() - screwRadius;

    hourHandPath.reset();
    hourHandPath.moveTo(bounds.centerX(), bounds.centerY());
    hourHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - hourHandLength, Direction.CCW);
    hourHandPath.close();

    minuteHandPath.reset();
    minuteHandPath.moveTo(bounds.centerX(), bounds.centerY());
    minuteHandPath.addRect(bounds.centerX(), top, bounds.centerX(), top - minuteHandLength, Direction.CCW);
    minuteHandPath.close();
}
SmartArtPathBuilder.java 文件源码 项目:iOffice 阅读 19 收藏 0 点赞 0 评论 0
private static Path getFunnelPath(AutoShape shape, Rect rect)
{
    float width = 716f;
    float height = 536f;
    path.addOval(new RectF(28, 22, 688, 238), Direction.CCW);

    path.moveTo(0, 130);            
    path.arcTo(new RectF(0, 0, 716, 260), 180, 180);
    path.arcTo(new RectF(258, 444, 458, 536), 30, 150);
    path.close();

    sm.reset();
    sm.postScale(rect.width() / width, rect.height() / height);
    path.transform(sm);

    path.offset(rect.left, rect.top);

    return path;
}
BaseShapePathBuilder.java 文件源码 项目:iOffice 阅读 20 收藏 0 点赞 0 评论 0
private static Path getFramePath(AutoShape shape, Rect rect)
{
    float x = Math.min(rect.height(), rect.width()) * 0.1f;
    Float[] values = shape.getAdjustData();
    if (values != null && values.length >= 1)
    {
        if (values[0] != null)
        {
            x = Math.min(rect.height(), rect.width()) * values[0];
        }
    }

    rectF.set(rect.left, rect.top, rect.right, rect.bottom);
    path.addRect(rectF, Path.Direction.CW);
    rectF.set(rect.left + x, rect.top + x, rect.right - x, rect.bottom - x);
    path.addRect(rectF, Path.Direction.CCW);

    return path;
}
CircularProgressView.java 文件源码 项目:ombuds-android 阅读 17 收藏 0 点赞 0 评论 0
private void updatePath(final int w, final int h)
{
    final float maxAbsSize = Math.min(w, h) / 2f;
    final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;

    path.reset();

    if (progress == 0)
    {
        path.close();
    }
    else if (progress < maxProgress)
    {
        final float angle = progress * 360 / maxProgress;
        final float x = w / 2f;
        final float y = h / 2f;

        path.moveTo(x, y);
        path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
        path.close();
    }
    else
    {
        path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
    }
}
RippleDrawable.java 文件源码 项目:material-master 阅读 23 收藏 0 点赞 0 评论 0
@Override
protected void onBoundsChange(Rect bounds) {        
    if(mBackgroundDrawable != null)
        mBackgroundDrawable.setBounds(bounds);

    mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
    mBackground.reset();

    switch (mMask.type) {
        case Mask.TYPE_OVAL:
            mBackground.addOval(mBackgroundBounds, Direction.CW);
            break;
        case Mask.TYPE_RECTANGLE:
            mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
            break;
    }
}
RippleDrawable.java 文件源码 项目:material_fork 阅读 25 收藏 0 点赞 0 评论 0
@Override
protected void onBoundsChange(Rect bounds) {        
    if(mBackgroundDrawable != null)
        mBackgroundDrawable.setBounds(bounds);

    mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
    mBackground.reset();

    switch (mMask.type) {
        case Mask.TYPE_OVAL:
            mBackground.addOval(mBackgroundBounds, Direction.CW);
            break;
        case Mask.TYPE_RECTANGLE:
            mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
            break;
    }
}
PopupZoomer.java 文件源码 项目:365browser 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Sets the bitmap to be used for the zoomed view.
 */
public void setBitmap(Bitmap bitmap) {
    if (mZoomedBitmap != null) {
        mZoomedBitmap.recycle();
        mZoomedBitmap = null;
    }
    mZoomedBitmap = bitmap;

    // Round the corners of the bitmap so it doesn't stick out around the overlay.
    Canvas canvas = new Canvas(mZoomedBitmap);
    Path path = new Path();
    RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
    float overlayCornerRadius = getOverlayCornerRadius(getContext());
    path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
    canvas.clipPath(path, Op.XOR);
    Paint clearPaint = new Paint();
    clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    clearPaint.setColor(Color.TRANSPARENT);
    canvas.drawPaint(clearPaint);
}
RippleDrawable.java 文件源码 项目:Bound 阅读 25 收藏 0 点赞 0 评论 0
@Override
protected void onBoundsChange(Rect bounds) {
  if(mBackgroundDrawable != null)
    mBackgroundDrawable.setBounds(bounds);

  mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
  mBackground.reset();

  switch (mMask.type) {
    case Mask.TYPE_OVAL:
      mBackground.addOval(mBackgroundBounds, Direction.CW);
      break;
    case Mask.TYPE_RECTANGLE:
      mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
      break;
  }
}
RippleDrawable.java 文件源码 项目:Material-Components 阅读 28 收藏 0 点赞 0 评论 0
@Override
protected void onBoundsChange(Rect bounds) {        
    if(mBackgroundDrawable != null)
        mBackgroundDrawable.setBounds(bounds);

    mBackgroundBounds.set(bounds.left + mMask.left, bounds.top + mMask.top, bounds.right - mMask.right, bounds.bottom - mMask.bottom);
    mBackground.reset();

    switch (mMask.type) {
        case Mask.TYPE_OVAL:
            mBackground.addOval(mBackgroundBounds, Direction.CW);
            break;
        case Mask.TYPE_RECTANGLE:
            mBackground.addRoundRect(mBackgroundBounds, mMask.cornerRadius, Direction.CW);
            break;
    }
}
CircularProgressView.java 文件源码 项目:bither-android 阅读 17 收藏 0 点赞 0 评论 0
private void updatePath(final int w, final int h) {
    final float maxAbsSize = Math.min(w, h) / 2f;
    final float absSize = size < maxSize ? maxAbsSize * size / maxSize
            : maxAbsSize - 1;

    path.reset();

    if (progress == 0) {
        path.close();
    } else if (progress < maxProgress) {
        final float angle = progress * 360 / maxProgress;
        final float x = w / 2f;
        final float y = h / 2f;

        path.moveTo(x, y);
        path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y
                + absSize), 270, angle);
        path.close();
    } else {
        path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
    }
}
RoundedImageView.java 文件源码 项目:RoundedImageView 阅读 34 收藏 0 点赞 0 评论 0
@Override
    protected void onDraw(Canvas canvas) {
        float borderWidth = this.borderWidth;
        float roundWidth = this.roundWidth;
        if (borderWidth < 0) {
            borderWidth = ( getWidth() + getHeight() ) * .02f;
        }
        paint.setStrokeWidth( borderWidth );
        if (roundWidth < 0) {
            roundWidth = borderWidth * 2;
        }

        drawPath.reset();
//        drawRect.set( 0 + roundWidth / 2, 0 + roundWidth / 2, getWidth() - roundWidth / 2, getHeight() - roundWidth / 2 );
        drawRect.set( 0 + borderWidth / 2, 0 + borderWidth / 2, getWidth() - borderWidth / 2, getHeight() - borderWidth / 2 );
        drawPath.addRoundRect( drawRect, roundWidth, roundWidth, Direction.CCW );

        canvas.save();
        canvas.clipPath( drawPath );
        super.onDraw( canvas );
        canvas.restore();

        canvas.drawRoundRect( drawRect, roundWidth, roundWidth, paint );
    }
DrawPathDemoActivity.java 文件源码 项目:EffectiveAndroid 阅读 19 收藏 0 点赞 0 评论 0
@Override
        public void onDraw(Canvas canvas) {
            if (mCenter == null) {
                mCenter = new Point(getWidth()/2, getHeight()/2);
            }
            canvas.drawColor(Color.CYAN);
            float left = mCenter.x;
            float top = mCenter.y;
            float radius = 200;
            Path p = new Path();
            p.addRect(left, top, left+radius, top+radius, Direction.CW);
            p.addCircle(mCenter.x, mCenter.y, radius, Direction.CW);
            p.lineTo(mCenter.x + 2*radius, mCenter.y+2*radius);
            p.close();
            Paint paint = new Paint();
            paint.setColor(Color.RED);
            paint.setAntiAlias(true);
//            paint.setStyle(Style.FILL_AND_STROKE);
            canvas.drawPath(p, paint);
        }
CircularProgressView.java 文件源码 项目:templecoin-android-wallet 阅读 23 收藏 0 点赞 0 评论 0
private void updatePath(final int w, final int h)
{
    final float maxAbsSize = Math.min(w, h) / 2f;
    final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;

    path.reset();

    if (progress == 0)
    {
        path.close();
    }
    else if (progress < maxProgress)
    {
        final float angle = progress * 360 / maxProgress;
        final float x = w / 2f;
        final float y = h / 2f;

        path.moveTo(x, y);
        path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
        path.close();
    }
    else
    {
        path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
    }
}
PopupZoomer.java 文件源码 项目:android-chromium-view 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Sets the bitmap to be used for the zoomed view.
 */
public void setBitmap(Bitmap bitmap) {
    if (mZoomedBitmap != null) {
        mZoomedBitmap.recycle();
        mZoomedBitmap = null;
    }
    mZoomedBitmap = bitmap;

    // Round the corners of the bitmap so it doesn't stick out around the overlay.
    Canvas canvas = new Canvas(mZoomedBitmap);
    Path path = new Path();
    RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
    float overlayCornerRadius = getOverlayCornerRadius(getContext());
    path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
    canvas.clipPath(path, Op.XOR);
    Paint clearPaint = new Paint();
    clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    clearPaint.setColor(Color.TRANSPARENT);
    canvas.drawPaint(clearPaint);
}
PopupZoomer.java 文件源码 项目:android-chromium 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Sets the bitmap to be used for the zoomed view.
 */
public void setBitmap(Bitmap bitmap) {
    if (mZoomedBitmap != null) {
        mZoomedBitmap.recycle();
        mZoomedBitmap = null;
    }
    mZoomedBitmap = bitmap;

    // Round the corners of the bitmap so it doesn't stick out around the overlay.
    Canvas canvas = new Canvas(mZoomedBitmap);
    Path path = new Path();
    RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
    float overlayCornerRadius = getOverlayCornerRadius(getContext());
    path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
    canvas.clipPath(path, Op.XOR);
    Paint clearPaint = new Paint();
    clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    clearPaint.setColor(Color.TRANSPARENT);
    canvas.drawPaint(clearPaint);
}
PopupZoomer.java 文件源码 项目:chromium_webview 阅读 16 收藏 0 点赞 0 评论 0
/**
 * Sets the bitmap to be used for the zoomed view.
 */
public void setBitmap(Bitmap bitmap) {
    if (mZoomedBitmap != null) {
        mZoomedBitmap.recycle();
        mZoomedBitmap = null;
    }
    mZoomedBitmap = bitmap;

    // Round the corners of the bitmap so it doesn't stick out around the overlay.
    Canvas canvas = new Canvas(mZoomedBitmap);
    Path path = new Path();
    RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
    float overlayCornerRadius = getOverlayCornerRadius(getContext());
    path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
    canvas.clipPath(path, Op.XOR);
    Paint clearPaint = new Paint();
    clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    clearPaint.setColor(Color.TRANSPARENT);
    canvas.drawPaint(clearPaint);
}
QRCodeGenerator.java 文件源码 项目:FaceBarCodeDemo 阅读 25 收藏 0 点赞 0 评论 0
private void drawRoundRect(Canvas canvas, RectF rect, Paint paint,
        int radius, boolean leftTop, boolean rightTop, boolean leftBottom,
        boolean rightBottom) {
    float roundRadius[] = new float[8];
    roundRadius[0] = leftTop ? 0 : radius;
    roundRadius[1] = leftTop ? 0 : radius;
    roundRadius[2] = rightTop ? 0 : radius;
    roundRadius[3] = rightTop ? 0 : radius;
    roundRadius[4] = rightBottom ? 0 : radius;
    roundRadius[5] = rightBottom ? 0 : radius;
    roundRadius[6] = leftBottom ? 0 : radius;
    roundRadius[7] = leftBottom ? 0 : radius;

    Path path = new Path();
    path.addRoundRect(rect, roundRadius, Direction.CCW);
    canvas.drawPath(path, paint);
}
CircularProgressView.java 文件源码 项目:goldcoin-android 阅读 18 收藏 0 点赞 0 评论 0
private void updatePath(final int w, final int h)
{
    final float maxAbsSize = Math.min(w, h) / 2f;
    final float absSize = size < maxSize ? maxAbsSize * size / maxSize : maxAbsSize - 1;

    path.reset();

    if (progress == 0)
    {
        path.close();
    }
    else if (progress < maxProgress)
    {
        final float angle = progress * 360 / maxProgress;
        final float x = w / 2f;
        final float y = h / 2f;

        path.moveTo(x, y);
        path.arcTo(new RectF(x - absSize, y - absSize, x + absSize, y + absSize), 270, angle);
        path.close();
    }
    else
    {
        path.addCircle(w / 2f, h / 2f, absSize, Direction.CW);
    }
}
PopupZoomer.java 文件源码 项目:cordova-android-chromium 阅读 20 收藏 0 点赞 0 评论 0
/**
 * Sets the bitmap to be used for the zoomed view.
 */
public void setBitmap(Bitmap bitmap) {
    if (mZoomedBitmap != null) {
        mZoomedBitmap.recycle();
        mZoomedBitmap = null;
    }
    mZoomedBitmap = bitmap;

    // Round the corners of the bitmap so it doesn't stick out around the overlay.
    Canvas canvas = new Canvas(mZoomedBitmap);
    Path path = new Path();
    RectF canvasRect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
    float overlayCornerRadius = getOverlayCornerRadius(getContext());
    path.addRoundRect(canvasRect, overlayCornerRadius, overlayCornerRadius, Direction.CCW);
    canvas.clipPath(path, Op.XOR);
    Paint clearPaint = new Paint();
    clearPaint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    clearPaint.setColor(Color.TRANSPARENT);
    canvas.drawPaint(clearPaint);
}
CircleBackgroundMask.java 文件源码 项目:NoticeDog 阅读 23 收藏 0 点赞 0 评论 0
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    float dy = ((float) h) - 2.0f;
    float dx = (float) w;
    float padding = (float) getPaddingLeft();
    this.clipPath.reset();
    this.clipPath.addCircle(dx / 2.0f, dy / 2.0f, (dx / 2.0f) - padding, Direction.CW);
    this.clipPath.close();
}
RoundImageView.java 文件源码 项目:Tribe 阅读 37 收藏 0 点赞 0 评论 0
@Override
public void buildBoundPath(Path boundPath){
    boundPath.reset();

    final int width = getWidth();
    final int height = getHeight();
    radius = Math.min(radius, Math.min(width, height) * 0.5f);

    RectF rect = new RectF(0, 0, width, height);
    boundPath.addRoundRect(rect , radius, radius, Direction.CW);
}
RoundImageView.java 文件源码 项目:Tribe 阅读 26 收藏 0 点赞 0 评论 0
@Override
public void buildBorderPath(Path borderPath) {
    borderPath.reset();

    final float halfBorderWidth = getBorderWidth() * 0.5f;

    final int width = getWidth();
    final int height = getHeight();
    radius = Math.min(radius, Math.min(width, height) * 0.5f);

    RectF rect = new RectF(halfBorderWidth, halfBorderWidth,
            width - halfBorderWidth, height - halfBorderWidth);
    borderPath.addRoundRect(rect , radius, radius, Direction.CW);
}
SelectableRoundedImageView.java 文件源码 项目:boohee_v5.6 阅读 42 收藏 0 点赞 0 评论 0
public void draw(Canvas canvas) {
    canvas.save();
    if (!this.mBoundsConfigured) {
        configureBounds(canvas);
        if (this.mBorderWidth > 0.0f) {
            adjustBorderWidthAndBorderBounds(canvas);
            setBorderRadii();
        }
        this.mBoundsConfigured = true;
    }
    if (this.mOval) {
        if (this.mBorderWidth > 0.0f) {
            adjustCanvasForBorder(canvas);
            this.mPath.addOval(this.mBounds, Direction.CW);
            canvas.drawPath(this.mPath, this.mBitmapPaint);
            this.mPath.reset();
            this.mPath.addOval(this.mBorderBounds, Direction.CW);
            canvas.drawPath(this.mPath, this.mBorderPaint);
        } else {
            this.mPath.addOval(this.mBounds, Direction.CW);
            canvas.drawPath(this.mPath, this.mBitmapPaint);
        }
    } else if (this.mBorderWidth > 0.0f) {
        adjustCanvasForBorder(canvas);
        this.mPath.addRoundRect(this.mBounds, this.mRadii, Direction.CW);
        canvas.drawPath(this.mPath, this.mBitmapPaint);
        this.mPath.reset();
        this.mPath.addRoundRect(this.mBorderBounds, this.mBorderRadii, Direction.CW);
        canvas.drawPath(this.mPath, this.mBorderPaint);
    } else {
        this.mPath.addRoundRect(this.mBounds, this.mRadii, Direction.CW);
        canvas.drawPath(this.mPath, this.mBitmapPaint);
    }
    canvas.restore();
}
BaseCircle.java 文件源码 项目:boohee_v5.6 阅读 27 收藏 0 点赞 0 评论 0
protected void drawBackground(Canvas canvas) {
    Paint bgPaint = new Paint();
    bgPaint.setColor(this.mCircleBackground);
    int radius = getViewRadius() - ((this.mDividerWidth * 3) / 2);
    canvas.drawCircle((float) getCenterX(), (float) getCenterY(), (float) radius, bgPaint);
    Path path = new Path();
    path.addCircle((float) getCenterX(), (float) getCenterY(), (float) radius, Direction.CW);
    Paint paint = new Paint();
    paint.setColor(this.mCircleGray);
    paint.setAntiAlias(true);
    paint.setStyle(Style.STROKE);
    paint.setStrokeWidth(1.0f);
    canvas.drawPath(path, paint);
}


问题


面经


文章

微信
公众号

扫码关注公众号