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


Java Path.addOval方法代碼示例

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


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

示例1: rotatedOval

import android.graphics.Path; //導入方法依賴的package包/類
private Bitmap rotatedOval(Bitmap bitmap) {
    Bitmap bmp;
    float width = bitmap.getWidth();
    float height = bitmap.getHeight();

    bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Path oval = new Path();
    Matrix matrix = new Matrix();
    RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);

    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    canvas.drawPath(oval, paint);

    return bmp;
}
 
開發者ID:StylingAndroid,項目名稱:PresenterLite,代碼行數:25,代碼來源:ShapedImageView.java

示例2: onDraw

import android.graphics.Path; //導入方法依賴的package包/類
/**
 * Path同樣也給我們封裝好了一些路徑效果,例如圓形,矩形等等,跟canvas.drawXX比較類似,這裏就簡單介紹下
 *
 * addArc(float left, float top, float right, float bottom, float startAngle, float sweepAngle)
 * 添加弧線到路徑
 *
 * addCircle(float x, float y, float radius, Path.Direction dir) 添加圓到路徑
 *
 * addOval(float left, float top, float right, float bottom, Path.Direction dir) 添加橢圓到路徑
 *
 * addRect(float left, float top, float right, float bottom, Path.Direction dir) 添加矩形到路徑
 *
 * 上麵的Path.Direction dir參數用來指定繪製時是順時針還是逆時針,Path.Direction.CCW和Path.Direction.CW分別代表逆時針和順時針,
 * 順時針和逆時針主要的作用在於不同的時針方向也就決定了不同的路徑起始點和終點,其他的參數跟canvas.drawXX是一樣的
 */

@Override protected void onDraw(Canvas canvas) {
  //設置繪製風格
  setViewPaint();
  //構建path
  Path path = new Path();
  //添加弧形到path
  path.addArc(100, 100, 300, 300, 0, 270);
  //添加圓形到path
  path.addCircle(200, 500, 100, Path.Direction.CCW);
  //添加矩形到path
  path.addRect(100, 700, 300, 800, Path.Direction.CW);
  //添加橢圓到path
  path.addOval(100, 900, 300, 1000, Path.Direction.CCW);
  //繪製path
  canvas.drawPath(path, paint);
}
 
開發者ID:liuguoquan727,項目名稱:android-study,代碼行數:33,代碼來源:PathOther.java

示例3: clippedRotatedOval

import android.graphics.Path; //導入方法依賴的package包/類
private Bitmap clippedRotatedOval(Bitmap bitmap) {
    Bitmap bmp;
    float width = bitmap.getWidth();
    float height = bitmap.getHeight();

    bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Path oval = new Path();
    Matrix matrix = new Matrix();
    Region region = new Region();
    RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);

    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    region.setPath(oval, new Region((int) width / 2, 0, (int) width, (int) height));
    canvas.drawPath(region.getBoundaryPath(), paint);

    return bmp;
}
 
開發者ID:StylingAndroid,項目名稱:PresenterLite,代碼行數:27,代碼來源:ShapedImageView.java

示例4: getPath

import android.graphics.Path; //導入方法依賴的package包/類
@Override
protected Path getPath(Canvas canvas, Paint paint) {
  Path path = new Path();
  float cx = ParserHelper.fromPercentageToFloat(mCx, mCanvasWidth, 0, mScale);
  float cy = ParserHelper.fromPercentageToFloat(mCy, mCanvasHeight, 0, mScale);
  float rx = ParserHelper.fromPercentageToFloat(mRx, mCanvasWidth, 0, mScale);
  float ry = ParserHelper.fromPercentageToFloat(mRy, mCanvasHeight, 0, mScale);
  RectF oval = new RectF(cx - rx, cy - ry, cx + rx, cy + ry);
  path.addOval(oval, Path.Direction.CW);
  return path;
}
 
開發者ID:weex-plugins,項目名稱:weex-svg,代碼行數:12,代碼來源:WXSvgEllipse.java

示例5: heart

import android.graphics.Path; //導入方法依賴的package包/類
private Bitmap heart(Bitmap bitmap) {
    Bitmap bmp;
    float width = bitmap.getWidth();
    float height = bitmap.getHeight();

    bmp = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
    BitmapShader shader = new BitmapShader(bitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);

    Canvas canvas = new Canvas(bmp);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(shader);

    Path oval = new Path();
    Matrix matrix = new Matrix();
    Region region = new Region();
    RectF ovalRect = new RectF(width / OVAL_FACTOR, 0, width - (width / OVAL_FACTOR), height);

    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    region.setPath(oval, new Region((int) width / 2, 0, (int) width, (int) height));
    canvas.drawPath(region.getBoundaryPath(), paint);

    matrix.reset();
    oval.reset();
    oval.addOval(ovalRect, Path.Direction.CW);
    matrix.postRotate(-ROTATION, width / 2, height / 2);
    oval.transform(matrix, oval);
    region.setPath(oval, new Region(0, 0, (int) width / 2, (int) height));
    canvas.drawPath(region.getBoundaryPath(), paint);

    return bmp;
}
 
開發者ID:StylingAndroid,項目名稱:PresenterLite,代碼行數:35,代碼來源:ShapedImageView.java


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