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


Java Canvas.drawArc方法代碼示例

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


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

示例1: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float eatRightX = mPadding + eatErWidth + eatErPositionX;
    RectF rectF = new RectF(mPadding + eatErPositionX, mHigh / 2 - eatErWidth / 2, eatRightX, mHigh / 2 + eatErWidth / 2);
    canvas.drawArc(rectF, eatErStartAngle, eatErEndAngle
            , true, mPaint);
    canvas.drawCircle(mPadding + eatErPositionX + eatErWidth / 2,
            mHigh / 2 - eatErWidth / 4,
            beansWidth / 2, mPaintEye);

    int beansCount = (int) ((mWidth - mPadding * 2 - eatErWidth) / beansWidth / 2);
    for (int i = 0; i < beansCount; i++) {

        float x = beansCount * i + beansWidth / 2 + mPadding + eatErWidth;
        if (x > eatRightX) {
            canvas.drawCircle(x,
                    mHigh / 2, beansWidth / 2, mPaint);
        }
    }


}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:24,代碼來源:EatBeansView.java

示例2: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
/**
 * Draw the progress spinner
 */
public void draw(Canvas c, Rect bounds) {
    final RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);
    arcBounds.inset(mStrokeInset, mStrokeInset);

    final float startAngle = (mStartTrim + mRotation) * 360;
    final float endAngle = (mEndTrim + mRotation) * 360;
    float sweepAngle = endAngle - startAngle;

    mPaint.setColor(mColors[mColorIndex]);
    c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint);

    drawTriangle(c, startAngle, sweepAngle, bounds);

    if (mAlpha < 255) {
        mCirclePaint.setColor(mBackgroundColor);
        mCirclePaint.setAlpha(255 - mAlpha);
        c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2,
                mCirclePaint);
    }
}
 
開發者ID:aliumujib,項目名稱:SwipeToRefresh,代碼行數:25,代碼來源:MaterialProgressDrawable.java

示例3: drawOuter

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawOuter(Canvas canvas, int viewWidth) {
    if (mShowOuter) {
        float outerR = mBollRadius + mOuterPaint.getStrokeWidth() * 2;

        mRefreshStart += mOuterIsStart ? 3 : 10;
        mRefreshStop += mOuterIsStart ? 10 : 3;
        mRefreshStart = mRefreshStart % 360;
        mRefreshStop = mRefreshStop % 360;

        int swipe = mRefreshStop - mRefreshStart;
        swipe = swipe < 0 ? swipe + 360 : swipe;

        canvas.drawArc(new RectF(viewWidth / 2 - outerR, mBollY - outerR, viewWidth / 2 + outerR, mBollY + outerR),
                mRefreshStart, swipe, false, mOuterPaint);
        if (swipe >= TARGET_DEGREE) {
            mOuterIsStart = false;
        } else if (swipe <= 10) {
            mOuterIsStart = true;
        }
        invalidate();
    }

}
 
開發者ID:Brave-wan,項目名稱:SmartRefresh,代碼行數:24,代碼來源:CircleHeader.java

示例4: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int w = getMeasuredWidth()/num-10;
    mPath.setStyle(Paint.Style.FILL);
    canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, r, mPath);
    canvas.save();
    mPath.setStyle(Paint.Style.STROKE);//設置為空心
    mPath.setStrokeWidth(6);
    canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, r + 15, mPath);
    canvas.restore();

    mPantR.setStyle(Paint.Style.FILL);
    RectF oval = new RectF(getMeasuredWidth()/2-r, getMeasuredHeight()/2-r, getMeasuredWidth()/2+r, getMeasuredHeight()/2+r);// 設置個新的長方形,掃描測量
    canvas.drawArc(oval, stratAngle, endAngle, true, mPantR);
    canvas.save();
    mPantR.setStrokeWidth(6);
    mPantR.setStyle(Paint.Style.STROKE);
    RectF oval2 = new RectF(getMeasuredWidth()/2-r-outCir_value, getMeasuredHeight()/2-r-outCir_value, getMeasuredWidth()/2+r+outCir_value, getMeasuredHeight()/2+r+outCir_value);// 設置個新的長方形,掃描測量
    canvas.drawArc(oval2, stratAngle, endAngle, false, mPantR);
    canvas.restore();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:RoundProgressView.java

示例5: drawPacman

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawPacman(Canvas canvas,Paint paint){
    float x=getWidth()/2;
    float y=getHeight()/2;

    canvas.save();

    canvas.translate(x, y);
    canvas.rotate(degrees1);
    paint.setAlpha(255);
    RectF rectF1=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
    canvas.drawArc(rectF1, 0, 270, true, paint);

    canvas.restore();

    canvas.save();
    canvas.translate(x, y);
    canvas.rotate(degrees2);
    paint.setAlpha(255);
    RectF rectF2=new RectF(-x/1.7f,-y/1.7f,x/1.7f,y/1.7f);
    canvas.drawArc(rectF2,90,270,true,paint);
    canvas.restore();
}
 
開發者ID:magicbaby810,項目名稱:SRecyclerView,代碼行數:23,代碼來源:PacmanIndicator.java

示例6: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
/**
 * Draw the progress spinner
 */
public void draw(Canvas c, Rect bounds) {
    final RectF arcBounds = mTempBounds;
    arcBounds.set(bounds);
    arcBounds.inset(mStrokeInset, mStrokeInset);

    final float startAngle = (mStartTrim + mRotation) * 360;
    final float endAngle = (mEndTrim + mRotation) * 360;
    float sweepAngle = endAngle - startAngle;
    mPaint.setColor(mColors[mColorIndex]);
    c.drawArc(arcBounds, startAngle, sweepAngle, false, mPaint);

    drawTriangle(c, startAngle, sweepAngle, bounds);

    if (mAlpha < 255) {
        mCirclePaint.setColor(mBackgroundColor);
        mCirclePaint.setAlpha(255 - mAlpha);
        c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2,
                mCirclePaint);
    }
}
 
開發者ID:zhouphenix,項目名稱:Multi-SwipeToRefreshLayout,代碼行數:24,代碼來源:MaterialProgressDrawable.java

示例7: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {		
	if(!mClockwise) {
		canvas.scale(-1, 1, mArcRect.centerX(), mArcRect.centerY() );
	}
	
	// Draw the arcs
	final int arcStart = mStartAngle + mAngleOffset + mRotation;
	final int arcSweep = mSweepAngle;
	canvas.drawArc(mArcRect, arcStart, arcSweep, false, mArcPaint);
	canvas.drawArc(mArcRect, arcStart, mProgressSweep, false,
			mProgressPaint);

	if(mEnabled) {
		// Draw the thumb nail
		canvas.translate(mTranslateX - mThumbXPos, mTranslateY - mThumbYPos);
		mThumb.draw(canvas);
	}
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:20,代碼來源:SeekArc.java

示例8: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected synchronized void onDraw(Canvas canvas) {
	super.onDraw(canvas);
	
	int halfWidth = getWidth() / 2;
	int halfHeight = getHeight() /2;
	int radius = halfWidth < halfHeight ? halfWidth : halfHeight;
	float halfStrokeWidth = mStrokeWidth / 2;
	
	// 設置畫筆
	mPaint.setColor(mBackgroundColor);
	mPaint.setDither(true);
	mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
	mPaint.setAntiAlias(true);
	mPaint.setStrokeWidth(mStrokeWidth);
	mPaint.setStyle(Paint.Style.STROKE);	//設置圖形為空心
	
	// 畫背景
	canvas.drawCircle(halfWidth, halfHeight, radius - halfStrokeWidth, mPaint);
	
	// 畫當前進度的圓環
	mPaint.setColor(mPrimaryColor);	// 改變畫筆顏色
	mRectF.top = halfHeight - radius + halfStrokeWidth;
	mRectF.bottom = halfHeight + radius - halfStrokeWidth;
	mRectF.left = halfWidth - radius + halfStrokeWidth;
	mRectF.right = halfWidth + radius - halfStrokeWidth;
	canvas.drawArc(mRectF, -90, getRateOfProgress() * 360, false, mPaint);
	canvas.save();
}
 
開發者ID:lo625090140,項目名稱:lqrwechatrongcloud,代碼行數:30,代碼來源:CircularProgressBar.java

示例9: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, circleLength1, mPaint1);
    canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, circleLength2, mPaint2);
    if (flag == 1) {
        //FIXME: android4.x設備沒有此api
        canvas.drawArc(10, 10, getMeasuredWidth() - 10, getMeasuredHeight() - 10, -90, sweepAngle, false, mPaint3);
    }

}
 
開發者ID:AndroidEngineerChenXiaoshuang,項目名稱:CSVideo,代碼行數:11,代碼來源:StartRecordingView.java

示例10: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    //獲取view的邊界
    getDrawingRect(bounds);

    int size = bounds.height() > bounds.width() ? bounds.width() : bounds.height();
    float outerRadius = size / 2;

    //畫內部背景
    int circleColor = inCircleColors.getColorForState(getDrawableState(), 0);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(circleColor);
    canvas.drawCircle(bounds.centerX(), bounds.centerY(), outerRadius - outLineWidth, mPaint);

    //畫邊框圓
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(outLineWidth);
    mPaint.setColor(outLineColor);
    canvas.drawCircle(bounds.centerX(), bounds.centerY(), outerRadius - outLineWidth / 2, mPaint);

    //畫字
    Paint paint = getPaint();
    paint.setColor(getCurrentTextColor());
    paint.setAntiAlias(true);
    paint.setTextAlign(Paint.Align.CENTER);
    float textY = bounds.centerY() - (paint.descent() + paint.ascent()) / 2;
    canvas.drawText(getText().toString(), bounds.centerX(), textY, paint);

    //畫進度條
    mPaint.setColor(progressLineColor);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(progressLineWidth);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    int deleteWidth = progressLineWidth + outLineWidth;
    mArcRect.set(bounds.left + deleteWidth / 2, bounds.top + deleteWidth / 2, bounds.right - deleteWidth / 2, bounds.bottom - deleteWidth / 2);

    canvas.drawArc(mArcRect, 0, 360 * progress / 100, false, mPaint);
}
 
開發者ID:yangchong211,項目名稱:YCProgress,代碼行數:39,代碼來源:CircleProgressbar.java

示例11: onDraw

import android.graphics.Canvas; //導入方法依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawRoundRect(mRoundRect, mHeight / 2, mHeight / 2, mBackgroundPaint);
    canvas.drawArc(mArcRect, -90f, 360, true, mArcDarkPaint);
    canvas.drawArc(mArcRect, -90f - 360 * (1 - getProgressRate()), 360 * (1 - getProgressRate()), true, mArcLightPaint);
    if (isDark()) {
        canvas.drawBitmap(mLightningDarkBitmap, mWidth - mARCWidth - UIUtils.dip2fpx(22), mARCWidth, null);
    } else {
        canvas.drawBitmap(mLightningBitmap, mWidth - mARCWidth - UIUtils.dip2fpx(22), mARCWidth, null);
    }
}
 
開發者ID:vip001,項目名稱:BubbleBar,代碼行數:13,代碼來源:BubbleBarView.java

示例12: drawCircle

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawCircle(Canvas canvas) {
    initDrawStrokeCirclePaint();
    canvas.drawArc(this.mRectF, 202.0f, this.mSweepAngle, false, this.mPaint);
    initDrawAlphaStrokeCirclePaint();
    canvas.drawArc(this.mRectF, 202.0f, this.mSweepAngle - 360.0f, false, this.mPaint);
    initDrawInnerCirclePaint();
    canvas.drawArc(this.mInnerRectF, 0.0f, 360.0f, false, this.mPaint);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:9,代碼來源:AnimCheckBox.java

示例13: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
void draw(Canvas canvas) {
    canvas.save();
    canvas.rotate(-90, canvas.getWidth() / 2, canvas.getHeight() / 2);
    canvas.drawArc(boundingBox, 0, 360, false, paint);
    canvas.drawLines(marker, markerPaint);
    canvas.restore();
}
 
開發者ID:eltos,項目名稱:SimpleDialogFragments,代碼行數:8,代碼來源:ColorWheelView.java

示例14: drawProgress

import android.graphics.Canvas; //導入方法依賴的package包/類
/**
 * 繪製進度條
 */
private void drawProgress(Canvas canvas) {
    //繪製進度 根據設置的樣式進行繪製
    paint.setStrokeWidth(ringWidth);
    paint.setColor(ringProgressColor);

    //Stroke樣式
    RectF strokeOval = new RectF(centre - radius, centre - radius, centre + radius,
            centre + radius);
    //FIll樣式
    RectF fillOval = new RectF(centre - radius + ringWidth + padding,
            centre - radius + ringWidth + padding, centre + radius - ringWidth - padding,
            centre + radius - ringWidth - padding);

    switch (style) {
        case STROKE: {
            paint.setStyle(Paint.Style.STROKE);
            paint.setStrokeCap(Paint.Cap.ROUND);
            canvas.drawArc(strokeOval, -90, 360 * progress / max, false, paint);
            break;
        }
        case FILL: {
            paint.setStyle(Paint.Style.FILL_AND_STROKE);
            paint.setStrokeCap(Paint.Cap.ROUND);
            if (progress != 0) {
                canvas.drawArc(fillOval, -90, 360 * progress / max, true, paint);
            }
            break;
        }
    }
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:34,代碼來源:MathchProgressView.java

示例15: drawProgress

import android.graphics.Canvas; //導入方法依賴的package包/類
private void drawProgress(Canvas canvas) {
        if (mCurrentProgress >= TOTAL_PROGRESS) {
            mCurrentProgress = TOTAL_PROGRESS;
        }
        // 獲取當前進度位置
        mCurrentProgressPosition = mProgressWidth * mCurrentProgress / TOTAL_PROGRESS;

        // 當進度條在圓弧內
        if (mCurrentProgressPosition <= mArcRadius) {

            //單邊角度
            int angle = (int) Math.toDegrees(Math.acos((mArcRadius - mCurrentProgressPosition) /
                    (float) mArcRadius));
            //起始位置
            int startAngle = 180 - angle;
            //掃過的角度
            int sweepAngle = 2 * angle;
//            canvas.drawRect(mArcRectF, mOrangePaint);
            canvas.drawArc(mArcRectF, startAngle, sweepAngle, false, mOrangePaint);
        } else {

            canvas.drawArc(mArcRectF, 90, 180, false, mOrangePaint);
            mOrangeRectF.left = mArcRightLocation;
            mOrangeRectF.right = mCurrentProgressPosition;
            canvas.drawRect(mOrangeRectF, mOrangePaint);
        }
    }
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:28,代碼來源:LeafView.java


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