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