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


Java Canvas.drawOval方法代码示例

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


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

示例1: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    float r = CENTER_X - mPaint.getStrokeWidth() * 0.5f;

    canvas.translate(CENTER_X, CENTER_X);

    canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
    canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);

    if (mTrackingCenter) {
        int c = mCenterPaint.getColor();
        mCenterPaint.setStyle(Paint.Style.STROKE);

        if (mHighlightCenter) {
            mCenterPaint.setAlpha(0xFF);
        } else {
            mCenterPaint.setAlpha(0x80);
        }
        canvas.drawCircle(0, 0,
                CENTER_RADIUS + mCenterPaint.getStrokeWidth(),
                mCenterPaint);

        mCenterPaint.setStyle(Paint.Style.FILL);
        mCenterPaint.setColor(c);
    }
}
 
开发者ID:feup-infolab,项目名称:labtablet,代码行数:27,代码来源:ColorPickerDialog.java

示例2: drawWeightHistory

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawWeightHistory(Canvas canvas) {
    Paint weightPaint = new Paint();
    weightPaint.setColor(Color.parseColor("#033b7d"));
    weightPaint.setStrokeWidth(3);

    int circleSize = appContext.getResources().getInteger(R.integer.sizeGraphCircle);

    for (Point weightPosition : weightHistory) {
        canvas.drawOval(
            scaleToXAxis(weightPosition.x),
            getHeight() - scaleToYAxis(weightPosition.y) - circleSize,
            scaleToXAxis(weightPosition.x) + circleSize,
            getHeight() - scaleToYAxis(weightPosition.y),
            weightPaint);
    }
}
 
开发者ID:alkazua,项目名称:Richi-Bahn,代码行数:17,代码来源:GraphView.java

示例3: toOvalBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * Create a new bitmap that has all pixels beyond the oval shape transparent.
 * Old bitmap is recycled.
 */
public static Bitmap toOvalBitmap(@NonNull Bitmap bitmap) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(output);

    int color = 0xff424242;
    Paint paint = new Paint();

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);

    RectF rect = new RectF(0, 0, width, height);
    canvas.drawOval(rect, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, 0, 0, paint);

    bitmap.recycle();

    return output;
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:28,代码来源:CropImage.java

示例4: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(@NonNull Canvas canvas) {
  if (mRebuildShader) {
    BitmapShader bitmapShader = new BitmapShader(mBitmap, mTileModeX, mTileModeY);
    if (mTileModeX == Shader.TileMode.CLAMP && mTileModeY == Shader.TileMode.CLAMP) {
      bitmapShader.setLocalMatrix(mShaderMatrix);
    }
    mBitmapPaint.setShader(bitmapShader);
    mRebuildShader = false;
  }

  if (mOval) {
    if (mBorderWidth > 0) {
      canvas.drawOval(mDrawableRect, mBitmapPaint);
      canvas.drawOval(mBorderRect, mBorderPaint);
    } else {
      canvas.drawOval(mDrawableRect, mBitmapPaint);
    }
  } else {
    if (any(mCornersRounded)) {
      float radius = mCornerRadius;
      if (mBorderWidth > 0) {
        canvas.drawRoundRect(mDrawableRect, radius, radius, mBitmapPaint);
        canvas.drawRoundRect(mBorderRect, radius, radius, mBorderPaint);
        redrawBitmapForSquareCorners(canvas);
        redrawBorderForSquareCorners(canvas);
      } else {
        canvas.drawRoundRect(mDrawableRect, radius, radius, mBitmapPaint);
        redrawBitmapForSquareCorners(canvas);
      }
    } else {
      canvas.drawRect(mDrawableRect, mBitmapPaint);
      if (mBorderWidth > 0) {
        canvas.drawRect(mBorderRect, mBorderPaint);
      }
    }
  }
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:39,代码来源:RoundedDrawable.java

示例5: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
	// All of our positions are using our internal coordinate system.
	// Instead of translating
	// them we let Canvas do the work for us.
	canvas.translate(mTranslationOffset, mTranslationOffset);

	// Draw the color wheel.
	canvas.drawOval(mColorWheelRectangle, mColorWheelPaint);

	float[] pointerPosition = calculatePointerPosition(mAngle);

	// Draw the pointer's "halo"
	canvas.drawCircle(pointerPosition[0], pointerPosition[1],
			mColorPointerHaloRadius, mPointerHaloPaint);

	// Draw the pointer (the currently selected color) slightly smaller on
	// top.
	canvas.drawCircle(pointerPosition[0], pointerPosition[1],
			mColorPointerRadius, mPointerColor);

	// Draw the halo of the center colors.
	canvas.drawCircle(0, 0, mColorCenterHaloRadius, mCenterHaloPaint);
	
	if (mShowCenterOldColor) {
		// Draw the old selected color in the center.
		canvas.drawArc(mCenterRectangle, 90, 180, true, mCenterOldPaint);

		// Draw the new selected color in the center.
		canvas.drawArc(mCenterRectangle, 270, 180, true, mCenterNewPaint);
	}
	else {
		// Draw the new selected color in the center.
		canvas.drawArc(mCenterRectangle, 0, 360, true, mCenterNewPaint);
	}
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:37,代码来源:ColorPicker.java

示例6: createCircleDrawable

import android.graphics.Canvas; //导入方法依赖的package包/类
protected Drawable createCircleDrawable(RectF circleRect, int color) {
    final Bitmap bitmap = Bitmap.createBitmap(mDrawableSize, mDrawableSize, Config.ARGB_8888);
    final Canvas canvas = new Canvas(bitmap);
    final Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setColor(color);
    canvas.drawOval(circleRect, paint);
    return new BitmapDrawable(getResources(), bitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:FloatingActionButton.java

示例7: getCircleBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
public static Bitmap getCircleBitmap(Bitmap bm) {

        if (bm == null) return null;

        int sice = Math.min((bm.getWidth()), (bm.getHeight()));

        Bitmap bitmap = ThumbnailUtils.extractThumbnail(bm, sice, sice);

        Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888);

        Canvas canvas = new Canvas(output);

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

        paint.setAntiAlias(true);
        paint.setDither(true);
        paint.setFilterBitmap(true);
        canvas.drawARGB(0, 0, 0, 0);
        paint.setColor(color);
        canvas.drawOval(rectF, paint);

        paint.setColor(Color.BLUE);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth((float) 4);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
        canvas.drawBitmap(bitmap, rect, rect, paint);
        return output;
    }
 
开发者ID:AppHero2,项目名称:Raffler-Android,代码行数:32,代码来源:Util.java

示例8: createMask

import android.graphics.Canvas; //导入方法依赖的package包/类
public Bitmap createMask() {
    Bitmap localBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_8888);
    Canvas localCanvas = new Canvas(localBitmap);
    Paint localPaint = new Paint(1);
    localPaint.setColor(-16777216);
    localCanvas.drawOval(new RectF(0.0f, 0.0f, (float) getWidth(), (float) getHeight()),
            localPaint);
    return localBitmap;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:CircularImage.java

示例9: drawIndicator

import android.graphics.Canvas; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void drawIndicator(Canvas canvas) {
    mPaint.setColor(indicatorHolder.getColor());
    mPaint.setAlpha(indicatorHolder.getAlpha());

    canvas.drawOval(
            indicatorHolder.getCenterX() - indicatorHolder.getWidth() / 2,
            indicatorHolder.getCenterY() - indicatorHolder.getHeight() / 2,
            indicatorHolder.getCenterX() + indicatorHolder.getWidth() / 2,
            indicatorHolder.getCenterY() + indicatorHolder.getHeight() / 2,
            mPaint
    );
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:14,代码来源:IndicatorView.java

示例10: draw

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

    for (int i = 1; i < mBallCount - 1; i++) {
        mPaint.setAlpha(MAX_ALPHA);
        canvas.drawCircle(mBallRadius * (i * 2 - 1) + mBallSideOffsets, mBallCenterY, mBallRadius, mPaint);

        mOvalRect.set(mBallRadius * (i * 2 - 2) + mBallSideOffsets, mHeight - mOvalVerticalRadius * 2,
                mBallRadius * (i * 2) + mBallSideOffsets, mHeight);
        mPaint.setAlpha(OVAL_ALPHA);
        canvas.drawOval(mOvalRect, mPaint);
    }

    //draw the first ball
    mPaint.setAlpha(MAX_ALPHA);
    canvas.drawCircle(mBallSideOffsets - mBallRadius - mLeftBallMoveXOffsets,
            mBallCenterY - mLeftBallMoveYOffsets, mBallRadius, mPaint);

    mOvalRect.set(mBallSideOffsets - mBallRadius - mBallRadius * mLeftOvalShapeRate - mLeftBallMoveXOffsets,
            mHeight - mOvalVerticalRadius - mOvalVerticalRadius * mLeftOvalShapeRate,
            mBallSideOffsets - mBallRadius + mBallRadius * mLeftOvalShapeRate - mLeftBallMoveXOffsets,
            mHeight - mOvalVerticalRadius + mOvalVerticalRadius * mLeftOvalShapeRate);
    mPaint.setAlpha(OVAL_ALPHA);
    canvas.drawOval(mOvalRect, mPaint);

    //draw the last ball
    mPaint.setAlpha(MAX_ALPHA);
    canvas.drawCircle(mBallRadius * (mBallCount * 2 - 3) + mBallSideOffsets + mRightBallMoveXOffsets,
            mBallCenterY - mRightBallMoveYOffsets, mBallRadius, mPaint);

    mOvalRect.set(mBallRadius * (mBallCount * 2 - 3) - mBallRadius * mRightOvalShapeRate + mBallSideOffsets + mRightBallMoveXOffsets,
            mHeight - mOvalVerticalRadius - mOvalVerticalRadius * mRightOvalShapeRate,
            mBallRadius * (mBallCount * 2 - 3) + mBallRadius * mRightOvalShapeRate + mBallSideOffsets + mRightBallMoveXOffsets,
            mHeight - mOvalVerticalRadius + mOvalVerticalRadius * mRightOvalShapeRate);
    mPaint.setAlpha(OVAL_ALPHA);
    canvas.drawOval(mOvalRect, mPaint);

    canvas.restoreToCount(saveCount);
}
 
开发者ID:ZhuoKeTeam,项目名称:JueDiQiuSheng,代码行数:41,代码来源:CollisionLoadingRenderer.java

示例11: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  //创建图片
  Bitmap bitmap = Bitmap.createBitmap(300, 300, Bitmap.Config.ARGB_8888);
  //生成图片内容
  Canvas canvas1 = new Canvas(bitmap);
  Paint paint = new Paint();
  //去锯齿
  paint.setAntiAlias(true);
  //设置颜色
  paint.setColor(Color.RED);
  canvas1.drawOval(100, 100, 200, 300, paint);
  //将图片绘制出来
  canvas.drawBitmap(bitmap, 0, 0, null);
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:16,代码来源:BitmapDemo.java

示例12: drawSunShadow

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawSunShadow(Canvas canvas) {
    mPaint.setColor(sunShadowColor);
    mPaint.setStyle(Paint.Style.FILL);
    mRectFSunShadow.set(getMeasuredWidth()/2-sunShadowWidth/2,getMeasuredHeight()- sunShadowHeight,
            getMeasuredWidth()/2+sunShadowWidth/2,getMeasuredHeight());
    canvas.drawOval(mRectFSunShadow,mPaint);
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:8,代码来源:WeatherView.java

示例13: drawLayers

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawLayers(Canvas canvas, float vx, float vy, List<Layer> layers) {
    if (layers != null) {
        Paint p = new Paint();
        for (Layer layer : layers) {
            if (layer.isVisible()) {
                if (layer instanceof LayerGroup) {
                    LayerGroup group = (LayerGroup) layer;
                    drawLayers(canvas, vx, vy, group.getLayers());
                } else if (layer instanceof ShapeLayer) {
                    ShapeLayer shapeLayer = (ShapeLayer) layer;
                    p.setColor(shapeLayer.getColorInt());
                    p.setAlpha(Math.round(layer.getCompOpacity() / 100f * 255));

                    // Use different canvas draw method depending on shape
                    if (shapeLayer instanceof RectLayer) {
                        p.setAntiAlias(false);
                        canvas.drawRect(
                                layer.getLeft() + vx,
                                layer.getTop() + vy,
                                layer.getRight() + vx,
                                layer.getBottom() + vy,
                                p
                        );
                    } else if (shapeLayer instanceof TriangleLayer) {
                        p.setAntiAlias(true);
                        Path path = new Path();
                        path.moveTo(layer.getLeft() + vx, layer.getBottom() + vy);
                        path.lineTo(layer.getRight() + vx, layer.getBottom() + vy);
                        path.lineTo(layer.getMidX() + vx, layer.getTop() + vy);
                        canvas.drawPath(path, p);
                    } else if (shapeLayer instanceof OvalLayer) {
                        p.setAntiAlias(true);
                        canvas.drawOval(
                                layer.getLeft() + vx,
                                layer.getTop() + vy,
                                layer.getRight() + vx,
                                layer.getBottom() + vy,
                                p
                        );
                    }
                }
            }
        }
    }
}
 
开发者ID:google,项目名称:spline,代码行数:46,代码来源:DocumentView.java

示例14: doDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
void doDraw(Canvas canvas, Paint paint) {
    mRectF.set(getBounds());
    canvas.drawOval(mRectF, paint);
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:6,代码来源:TrackOvalDrawable.java

示例15: drawNoService

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawNoService(Canvas canvas, int y, Paint paint) {
    float dotSize = textSize * 0.1f;
    canvas.drawOval(getWidth() * 0.4f - dotSize, y - textSize * 0.35f - dotSize, getWidth() * 0.4f + dotSize, y - textSize * 0.35f + dotSize, paint);
    canvas.drawOval(getWidth() * 0.6f - dotSize, y - textSize * 0.35f - dotSize, getWidth() * 0.6f + dotSize, y - textSize * 0.35f + dotSize, paint);

}
 
开发者ID:KameLong,项目名称:AOdia,代码行数:7,代码来源:TrainTimeView.java


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