当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.drawCircle方法代码示例

本文整理汇总了Java中android.graphics.Canvas.drawCircle方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.drawCircle方法的具体用法?Java Canvas.drawCircle怎么用?Java Canvas.drawCircle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.drawCircle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transform

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public Bitmap transform(Bitmap source) {
    int size = Math.min(source.getWidth(), source.getHeight());

    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;

    Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
    if (squaredBitmap != source) {
        source.recycle();
    }

    Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());

    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    BitmapShader shader = new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
    paint.setShader(shader);
    paint.setAntiAlias(true);

    float r = size / 2f;
    canvas.drawCircle(r, r, r, paint);

    squaredBitmap.recycle();
    return bitmap;
}
 
开发者ID:NarendraSickarwar,项目名称:FirebasePost,代码行数:27,代码来源:RoundedTransformation.java

示例2: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
  canvas.drawPaint(backgroundPaint);

  if (this.liveStrength == null) {
    // Nothing to draw yet...
    return;
  }

  float midX = canvas.getWidth() / 2f;
  float midY = canvas.getHeight() / 2f;
  float rad = Math.min(midX / 4f, midY);
  for (int i = 0; i < 4; i++) {
    float atX = midX + (i * 2 - 3) * rad; // i = [0, 1, 2, 3] -> [-3, -1, 1, 3]
    Paint paint = paintForStrength(liveStrength.getChannelStatus(i));
    canvas.drawCircle(atX, midY, rad * PADDING, paint);
  }
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:19,代码来源:ConnectionStrengthView.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
	super.onDraw(canvas);
	if (x != -1) {
		
		Paint paint = new Paint();
		paint.setAntiAlias(true);
		paint.setColor(makePressColor());
		canvas.drawCircle(x, y, radius, paint);
		if(radius > getHeight()/rippleSize)
			radius += rippleSpeed;
		if(radius >= getWidth()){
			x = -1;
			y = -1;
			radius = getHeight()/rippleSize;
			if(onClickListener != null&& clickAfterRipple)
				onClickListener.onClick(this);
		}
		invalidate();
	}		
	
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:23,代码来源:ButtonFlat.java

示例4: drawIcon

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void drawIcon(Canvas canvas, float fraction, Drawable drawable, int colorOfIcon,
                     WidthAndHeightOfView widthAndHeightOfView) {
    int centerX = widthAndHeightOfView.getWidth() / 2;
    int centerY = widthAndHeightOfView.getHeight() / 2 - 150;
    canvas.save();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    float newFraction = (fraction - 0.65f) / 0.35f;
    paint.setColor(Color.parseColor("#e53935"));
    canvas.drawCircle(centerX, centerY - 50, 100 * (1 - newFraction), paint);
    paint.setColor(Color.parseColor("#fdd835"));
    canvas.drawCircle(centerX -35, centerY + 35,100 * (1 - newFraction), paint);
    paint.setColor(Color.parseColor("#1e88e5"));
    canvas.drawCircle(centerX + 35, centerY + 35, 100 * (1 - newFraction), paint);
    canvas.restore();
    canvas.save();
    Path path = new Path();
    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    canvas.concat(matrix);
    path.addCircle(centerX, centerY, bitmap.getHeight() * 1.5f * newFraction, Path.Direction.CW);
    canvas.clipPath(path);
    canvas.drawBitmap(bitmap, centerX - bitmap.getWidth() / 2, centerY - bitmap.getHeight() / 2, paint);
    canvas.restore();
}
 
开发者ID:JoshuaRogue,项目名称:FancyView,代码行数:27,代码来源:RYBDrawStrategyStateTwo.java

示例5: circleCrop

import android.graphics.Canvas; //导入方法依赖的package包/类
private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
    if (source == null) return null;
    int size = Math.min(source.getWidth(), source.getHeight());
    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;
    // TODO this could be acquired from the pool too
    Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
    Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
    if (result == null) {
        result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    }
    float r = size / 2f;
    Canvas canvas = new Canvas(result);
    Paint paint = new Paint();
    paint.setColor(Color.parseColor("#F9F9F9"));
    paint.setStyle(Paint.Style.FILL);
    canvas.drawCircle(r, r, r, paint);
    paint.reset();
    paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
    paint.setAntiAlias(true);
    canvas.drawCircle(r, r, r, paint);
    return result;
}
 
开发者ID:YunzhanghuOpen,项目名称:redpacketui-open,代码行数:24,代码来源:CircleTransform.java

示例6: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * Draw the progress spinner
 */
public void draw(Canvas c, Rect bounds) {

    mCirclePaint.setColor(mBackgroundColor);
    mCirclePaint.setAlpha(mAlpha);

    c.drawCircle(bounds.exactCenterX(), bounds.exactCenterY(), bounds.width() / 2, mCirclePaint);

    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;
    mArcPaint.setColor(mColors[mColorIndex]);
    mArcPaint.setAlpha(mAlpha);
    c.drawArc(arcBounds, startAngle, sweepAngle, false, mArcPaint);
    drawTriangle(c, startAngle, sweepAngle, bounds);
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:22,代码来源:MaterialProgressDrawable.java

示例7: cropCircle

import android.graphics.Canvas; //导入方法依赖的package包/类
public Bitmap cropCircle(Bitmap bitmap) {
	Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
	Canvas canvas = new Canvas(output);

	final int color = 0xff424242;
	final Paint paint = new Paint();
	final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

	paint.setAntiAlias(true);
	canvas.drawARGB(0, 0, 0, 0);
	paint.setColor(color);
	canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
			bitmap.getWidth() / 2, paint);
	paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
	canvas.drawBitmap(bitmap, rect, rect, paint);
	return output;
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:18,代码来源:ButtonFloat.java

示例8: getCroppedBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
public Bitmap getCroppedBitmap(Bitmap bitmap) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
            bitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}
 
开发者ID:asif-patel,项目名称:ImageMagnifier,代码行数:19,代码来源:BrushView.java

示例9: toRound

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 转为圆形图片
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return 圆形图片
 */
public static Bitmap toRound(Bitmap src, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int radius = Math.min(width, height) >> 1;
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(width >> 1, height >> 1, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:25,代码来源:ImageUtils.java

示例10: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {

    float height = getMeasuredHeight();

    float outerRadius = badgeRadius * OUTER_RADIUS_MULTIPLIER;

    //draw background
    canvas.drawCircle(outerRadius, outerRadius, outerRadius, backgroundPaint);
    canvas.drawRect(outerRadius, 0, textWidth + (2 * space) + (2 * outerRadius), outerRadius * 2, backgroundPaint);
    canvas.drawCircle(textWidth + (2 * space) + (2 * outerRadius), outerRadius, outerRadius, backgroundPaint);

    //draw badge
    canvas.drawCircle(outerRadius, outerRadius, badgeRadius, badgePaint);

    canvas.drawText(text, (outerRadius * 2) + space, outerRadius + textPaint.descent() * 1.2f, textPaint);
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:18,代码来源:BadgeView.java

示例11: drawPoint

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawPoint(Canvas canvas) {
    int height = getHeight() - textSize * 4;
    int x = getWidth() / 2;
    int y = (int) (height - height * (temperatureDay - minTemp) * 1.0f / (maxTemp - minTemp)) + textSize * 2;
    int x2 = getWidth() / 2;
    int y2 = (int) (height - height * (temperatureNight - minTemp) * 1.0f / (maxTemp - minTemp)) + textSize * 2;
    xPointDay = x;
    yPointDay = y;
    xPointNight = x2;
    yPointNight = y2;
    mWidth = getWidth();
    canvas.drawCircle(x, y, radius, pointPaint);
    canvas.drawCircle(x2, y2, radius, pointPaint);
}
 
开发者ID:yangchong211,项目名称:YCWeather,代码行数:15,代码来源:TemperatureView.java

示例12: drawPress

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawPress(Canvas canvas) {

        if(mShapeType == 0){
            canvas.drawCircle(mWidth/2, mHeight/2, mWidth/2, mPressPaint);
        }else if (mShapeType == 1) {
            RectF rectF = new RectF(0, 0, mWidth, mHeight);
            canvas.drawRoundRect(rectF, mRadius, mRadius, mPressPaint);
        }
    }
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:10,代码来源:MLImageView.java

示例13: drawPointInterfere

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawPointInterfere(Canvas canvas){
    for (int i = 0; i < pointInterfereQuantity; i++) {
        bgPaint.setColor(randomColor());
        interferPoint=randomPoint();
        canvas.drawCircle(interferPoint.x,interferPoint.y,random.nextInt(3)+1,bgPaint);
    }

}
 
开发者ID:againstsky,项目名称:pictureverification,代码行数:9,代码来源:VerificationCodeView.java

示例14: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas, Paint paint) {
    float circleSpacing=4;
    for (int i = 0; i < 3; i++) {
        paint.setAlpha(alphaInts[i]);
        canvas.scale(scaleFloats[i],scaleFloats[i],getWidth()/2,getHeight()/2);
        canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2-circleSpacing,paint);
    }
}
 
开发者ID:magicbaby810,项目名称:SRecyclerView,代码行数:10,代码来源:BallScaleMultipleIndicator.java

示例15: drawPoint

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 画密码点
 */
private void drawPoint(Canvas canvas) {
    if (pointRadius > 0) {
        paint.setColor(codeColor);
        for (int i = 0; i < code.length(); i++) {
            final float left = unitWidth * i + dividerWidth * i + borderWidth;
            canvas.drawCircle(left + unitWidth / 2, getHeight() / 2, pointRadius, paint);
        }
    }
}
 
开发者ID:KungFuBrother,项目名称:WeChatPwd,代码行数:13,代码来源:CodeView.java


注:本文中的android.graphics.Canvas.drawCircle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。