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


Java Path.addRect方法代码示例

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


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

示例1: booleanTest

import android.graphics.Path; //导入方法依赖的package包/类
private void booleanTest(Canvas canvas) {
        paint.setStyle(Paint.Style.FILL);                   // 设置画布模式为填充kk
        canvas.translate(mWidth / 2, mHeight / 2);

        Path path1 = new Path();
        Path path2 = new Path();
        Path path3 = new Path();
        Path path4 = new Path();

        path1.addCircle(0, 0, 200, Path.Direction.CW);
        path2.addRect(0, -200, 200, 200, Path.Direction.CW);
        path3.addCircle(0, -100, 100, Path.Direction.CW);
        path4.addCircle(0, 100, 100, Path.Direction.CCW);
//
        path1.op(path2, Path.Op.DIFFERENCE);
        path1.op(path3, Path.Op.UNION);
        path1.op(path4, Path.Op.DIFFERENCE);
        canvas.drawPath(path1, paint);


    }
 
开发者ID:lixiaodaoaaa,项目名称:ColumnAnimViewProject,代码行数:22,代码来源:CanvasTest2View.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: onDraw

import android.graphics.Path; //导入方法依赖的package包/类
@Override protected void onDraw(Canvas canvas) {
  super.onDraw(canvas);
  //无效果
  mEffects[0] = null;
  //拐角处变得圆滑
  mEffects[1] = new CornerPathEffect(30);
  //线段上就会产生许多杂点
  mEffects[2] = new DiscretePathEffect(3.0F, 5.0F);
  //绘制虚线
  mEffects[3] = new DashPathEffect(new float[] { 20, 10, 5, 10 }, 0);
  Path path = new Path();
  path.addRect(0, 0, 8, 8, Path.Direction.CCW);
  //设置点的图形,即方形点的虚线,圆形点的虚线
  mEffects[4] = new PathDashPathEffect(path, 12, 0, PathDashPathEffect.Style.ROTATE);
  //组合PathEffect
  mEffects[5] = new ComposePathEffect(mEffects[3], mEffects[1]);
  for (int i = 0; i < mEffects.length; i++) {
    mPaint.setPathEffect(mEffects[i]);
    canvas.drawPath(mPath, mPaint);
    canvas.translate(0, 200);
  }
}
 
开发者ID:liuguoquan727,项目名称:android-study,代码行数:23,代码来源:PathEffectView.java

示例4: drawAuxLines

import android.graphics.Path; //导入方法依赖的package包/类
private void drawAuxLines(Canvas canvas) {
    Path path = new Path();

    path.moveTo(B.x, B.y);
    path.addCircle(O.x, O.y, Math.abs(O.x), Path.Direction.CW);
    canvas.drawPath(path, mAuxPaint);

    path.moveTo(O.x, E.y);
    path.lineTo(O.x, F.y);
    path.moveTo(E.x, O.y);
    path.lineTo(F.x, O.y);
    path.addRect(E.x, E.y, F.x, F.y, Path.Direction.CW);
    canvas.drawPath(path, mAuxPaint);

    path.moveTo(O.x, O.y);
    path.lineTo(C.x, C.y);
    canvas.drawPath(path, mAuxPaint);
}
 
开发者ID:brucezz,项目名称:Jier,代码行数:19,代码来源:DrawBoard.java

示例5: testPathDirection

import android.graphics.Path; //导入方法依赖的package包/类
private void testPathDirection(Canvas canvas) {
    canvas.translate(mWidth / 2, mHeight / 2);  // 移动坐标系到屏幕中心

    Path path = new Path();

    path.addRect(-100, -100, 100, 100, Path.Direction.CCW);

    path.setLastPoint(-500, 500);// <-- 重置最后一个点的位置
    path.close();
    canvas.drawPath(path, paint);
    path.close();
}
 
开发者ID:lixiaodaoaaa,项目名称:ColumnAnimViewProject,代码行数:13,代码来源:CanvasTestView.java

示例6: testPathForCan

import android.graphics.Path; //导入方法依赖的package包/类
private void testPathForCan(Canvas canvas) {
        canvas.translate(mWidth / 2, mHeight / 2);  // 移动坐标系到屏幕中心
//        canvas.scale(1, -1);                         // <-- 注意 翻转y坐标轴

        Path path = new Path();
        Path src = new Path();

        path.addRect(-200, -200, 200, 200, Path.Direction.CW);
        src.addCircle(0, 0, 100, Path.Direction.CW);

        path.addPath(src, 0, 200);
        paint.setColor(Color.BLACK);           // 绘制合并后的路径
        canvas.drawPath(path, paint);
    }
 
开发者ID:lixiaodaoaaa,项目名称:ColumnAnimViewProject,代码行数:15,代码来源:CanvasTestView.java

示例7: fillTypeTest

import android.graphics.Path; //导入方法依赖的package包/类
private void fillTypeTest(Canvas canvas) {
        paint.setStyle(Paint.Style.FILL);                   // 设置画布模式为填充kk
        canvas.translate(mWidth / 2, mHeight / 2);          // 移动画布(坐标系)

        Path path = new Path();                                     // 创建Path

        path.setFillType(Path.FillType.INVERSE_WINDING);                   // 设置Path填充模式为 奇偶规则
//        path.setFillType(Path.FillType.INVERSE_EVEN_ODD);            // 反奇偶规则
        path.addRect(-400, -400, 400, 400, Path.Direction.CW);         // 给Path中添加一个矩形

        canvas.drawPath(path, paint);
    }
 
开发者ID:lixiaodaoaaa,项目名称:ColumnAnimViewProject,代码行数:13,代码来源:CanvasTest2View.java

示例8: clear

import android.graphics.Path; //导入方法依赖的package包/类
/**
 * This method initializes canvas.
 *
 * @return
 */
public void clear() {
  Path path = new Path();
  path.moveTo(0F, 0F);
  path.addRect(0F, 0F, 1000F, 1000F, Path.Direction.CCW);
  path.close();

  Paint paint = new Paint();
  paint.setColor(Color.WHITE);
  paint.setStyle(Paint.Style.FILL);

  if (this.historyPointer == this.pathLists.size()) {
    this.pathLists.add(path);
    this.paintLists.add(paint);
    this.historyPointer++;
  } else {
    // On the way of Undo or Redo
    this.pathLists.set(this.historyPointer, path);
    this.paintLists.set(this.historyPointer, paint);
    this.historyPointer++;

    for (int i = this.historyPointer, size = this.paintLists.size(); i < size; i++) {
      this.pathLists.remove(this.historyPointer);
      this.paintLists.remove(this.historyPointer);
    }
  }

  this.text = "";

  // Clear
  this.invalidate();
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:37,代码来源:CanvasView.java

示例9: draw

import android.graphics.Path; //导入方法依赖的package包/类
protected void draw(Canvas canvas) {
    canvas.save();
    Path path = new Path();
    outlinePaint.setStrokeWidth(outlineWidth);
    if (!hasFocus()) {
        outlinePaint.setColor(Color.BLACK);
        canvas.drawRect(drawRect, outlinePaint);
    } else {
        Rect viewDrawingRect = new Rect();
        viewContext.getDrawingRect(viewDrawingRect);

        path.addRect(new RectF(drawRect), Path.Direction.CW);
        outlinePaint.setColor(highlightColor);

        if (isClipPathSupported(canvas)) {
            canvas.clipPath(path, Region.Op.DIFFERENCE);
            canvas.drawRect(viewDrawingRect, outsidePaint);
        } else {
            drawOutsideFallback(canvas);
        }

        canvas.restore();
        canvas.drawPath(path, outlinePaint);

        if (showThirds) {
            drawThirds(canvas);
        }

        if (showCircle) {
            drawCircle(canvas);
        }

        if (handleMode == HandleMode.Always ||
                (handleMode == HandleMode.Changing && modifyMode == ModifyMode.Grow)) {
            drawHandles(canvas);
        }
    }
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:39,代码来源:HighlightView.java

示例10: getPath

import android.graphics.Path; //导入方法依赖的package包/类
@Override
protected Path getPath(Canvas canvas, Paint paint) {
  Path path = new Path();
  float x = ParserHelper.fromPercentageToFloat(mX, mCanvasWidth, 0, mScale);
  float y = ParserHelper.fromPercentageToFloat(mY, mCanvasHeight, 0, mScale);
  float w = ParserHelper.fromPercentageToFloat(mW, mCanvasWidth, 0, mScale);
  float h = ParserHelper.fromPercentageToFloat(mH, mCanvasHeight, 0, mScale);
  float rx = ParserHelper.fromPercentageToFloat(mRx, mCanvasWidth, 0, mScale);
  float ry = ParserHelper.fromPercentageToFloat(mRy, mCanvasHeight, 0, mScale);

  if (rx != 0 || ry != 0) {
    if (rx == 0) {
      rx = ry;
    } else if (ry == 0) {
      ry = rx;
    }

    if (rx > w / 2) {
      rx = w / 2;
    }

    if (ry > h / 2) {
      ry = h / 2;
    }
    path.addRoundRect(new RectF(x, y, x + w, y + h), rx, ry, Path.Direction.CW);
  } else {
    path.addRect(x, y, x + w, y + h, Path.Direction.CW);
  }
  return path;
}
 
开发者ID:weex-plugins,项目名称:weex-svg,代码行数:31,代码来源:WXSvgRect.java

示例11: getContentPath

import android.graphics.Path; //导入方法依赖的package包/类
public
@NonNull
Path getContentPath(int viewTopPadding,
                    int viewRightPadding,
                    int viewBottomPadding,
                    int viewLeftPadding,
                    @NonNull RectF contentBox) {
  RectF rectForBorderOutline = new RectF();
  Path contentClip = new Path();
  rectForBorderOutline.set(contentBox);
  if (mBorderRadius != null) {
    prepareBorderRadius();
    float topLeftRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_LEFT_RADIUS);
    float topRightRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_RIGHT_RADIUS);
    float bottomRightRadius = getBorderRadius(mOverlappingBorderRadius,
                                              BORDER_BOTTOM_RIGHT_RADIUS);
    float bottomLeftRadius = getBorderRadius(mOverlappingBorderRadius,
                                             BORDER_BOTTOM_LEFT_RADIUS);
    contentClip.addRoundRect(rectForBorderOutline,
                             new float[]{
                                 topLeftRadius - viewLeftPadding,
                                 topLeftRadius - viewTopPadding,
                                 topRightRadius - viewRightPadding,
                                 topRightRadius - viewTopPadding,
                                 bottomRightRadius - viewRightPadding,
                                 bottomRightRadius - viewBottomPadding,
                                 bottomLeftRadius - viewLeftPadding,
                                 bottomLeftRadius - viewBottomPadding
                             },
                             Path.Direction.CW);
  } else {
    contentClip.addRect(rectForBorderOutline, Path.Direction.CW);
  }
  return contentClip;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:36,代码来源:BorderDrawable.java

示例12: prepareBorderPath

import android.graphics.Path; //导入方法依赖的package包/类
private void prepareBorderPath(int topPadding,
                               int rightPadding,
                               int bottomPadding,
                               int leftPadding,
                               @NonNull RectF rectF,
                               @NonNull Path path) {
  if (mBorderRadius != null) {
    prepareBorderRadius(rectF);
    float topLeftRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_LEFT_RADIUS);
    float topRightRadius = getBorderRadius(mOverlappingBorderRadius, BORDER_TOP_RIGHT_RADIUS);
    float bottomRightRadius = getBorderRadius(mOverlappingBorderRadius,
                                              BORDER_BOTTOM_RIGHT_RADIUS);
    float bottomLeftRadius = getBorderRadius(mOverlappingBorderRadius,
                                             BORDER_BOTTOM_LEFT_RADIUS);
    path.addRoundRect(
        rectF,
        new float[]{
            topLeftRadius - leftPadding,
            topLeftRadius - topPadding,
            topRightRadius - rightPadding,
            topRightRadius - topPadding,
            bottomRightRadius - rightPadding,
            bottomRightRadius - bottomPadding,
            bottomLeftRadius - leftPadding,
            bottomLeftRadius - bottomPadding
        },
        Path.Direction.CW);
  } else {
    path.addRect(rectF, Path.Direction.CW);
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:32,代码来源:BorderDrawable.java

示例13: updateBounds

import android.graphics.Path; //导入方法依赖的package包/类
private void updateBounds() {
    final Rect b = getBounds();
    final int width = (int) ((float) b.width() * getLevel() / MAX_LEVEL);
    final float radius = b.height() / 2f;
    mVisibleRect.set(b.left, b.top, b.left + width, b.height());

    // draw round to head of progressbar. I know it looks stupid, don't blame me now.
    mPath = new Path();
    mPath.addRect(b.left, b.top, b.left + width - radius, b.height(), Path.Direction.CCW);
    mPath.addCircle(b.left + width - radius, radius, radius, Path.Direction.CCW);
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:12,代码来源:ShiftDrawable.java

示例14: drawRepeatBarline

import android.graphics.Path; //导入方法依赖的package包/类
void drawRepeatBarline(Canvas canvas, StaffLayout staffLayout, BarLayout.Barline barline, BarLayout.BarlineLoc loc) {
	final float thick = kThickBarlineThicknessTenths * staffLayout.tenthSize;
	final float thin = kThinBarlineThicknessTenths * staffLayout.tenthSize;
	final float gap = kBarlineSeparationTenths * staffLayout.tenthSize;
	final float dotGap = kRepeatDotsBarlineGap * staffLayout.tenthSize;
	final float dotRadius =  kRepeatDotRadius * staffLayout.tenthSize;
	final float dotOffset = kRepeatDotOffset * staffLayout.tenthSize;
	final float margin = kBarlineBackgroundMargin * staffLayout.tenthSize;

	// construct for repeat double barline - left or right
	Path path = new Path();
	Paint paint = new Paint();
	paint.setARGB(255, 0, 0, 255);
	RectF thickBarline = new RectF(barline.rect.centerX()-thick/2, barline.rect.top, barline.rect.centerX()+thick/2, barline.rect.bottom);
	path.addRect(thickBarline, Path.Direction.CW);
	float thinLeft;
	float dotCentrex;
	if (loc == BarLayout.BarlineLoc.left) {
		thinLeft = thickBarline.right + gap;
		dotCentrex = thinLeft + thin + dotGap + dotRadius;
	} else {
		thinLeft = thickBarline.left - gap - thin;
		dotCentrex = thinLeft - dotGap - dotRadius;
	}
	RectF thinBarline = new RectF(thinLeft, barline.rect.top, thinLeft + thin, barline.rect.bottom);
	path.addRect(thinBarline, Path.Direction.CW);
	// repeat dots on each staff
	for (StaffLayout.Staff staff : staffLayout.staves) {
		float centreStaffY = staff.staffRect.centerY();
		if (centreStaffY + dotOffset < getHeight()) { // ensure we don't add dots below bottom of view height
			path.addCircle(dotCentrex, centreStaffY - dotOffset, dotRadius, Path.Direction.CW);
			path.addCircle(dotCentrex, centreStaffY + dotOffset, dotRadius, Path.Direction.CW);
		}
	}
	// paint translucent white background
	Path bgPath = new Path();
	Paint bgPaint = new Paint();
	bgPaint.setARGB(180, 255, 255, 255);
	// background overlaps foreground by margin
	if (loc == BarLayout.BarlineLoc.left)
		bgPath.addRect(new RectF(thickBarline.left - margin, thickBarline.top-margin, dotCentrex+dotRadius+margin, thickBarline.bottom + margin), Path.Direction.CW);
	else
		bgPath.addRect(new RectF(dotCentrex - dotRadius - margin, thickBarline.top-margin, thickBarline.right + margin, thickBarline.bottom + margin), Path.Direction.CW);
	canvas.drawPath(bgPath, bgPaint);
	// paint repeat double barline in blue
	canvas.drawPath(path, paint);
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:48,代码来源:SystemView.java

示例15: drawEditFrame

import android.graphics.Path; //导入方法依赖的package包/类
private void drawEditFrame(Canvas canvas) {
    if (!mIsCropEnabled) return;

    if (mCropMode == CropMode.CIRCLE) {
        mPaintTransparent.setFilterBitmap(true);
        mPaintTransparent.setColor(mOverlayColor);
        mPaintTransparent.setStyle(Paint.Style.FILL);

        Path path = new Path();
        path.addRect(mImageRect.left, mImageRect.top, mImageRect.right, mImageRect.bottom, Path.Direction.CW);
        path.addCircle((mFrameRect.left + mFrameRect.right) / 2, (mFrameRect.top + mFrameRect.bottom) / 2, (mFrameRect.right - mFrameRect.left) / 2, Path.Direction.CCW);
        canvas.drawPath(path, mPaintTransparent);

    } else {
        mPaintTransparent.setFilterBitmap(true);
        mPaintTransparent.setColor(mOverlayColor);
        mPaintTransparent.setStyle(Paint.Style.FILL);

        canvas.drawRect(mImageRect.left, mImageRect.top, mImageRect.right, mFrameRect.top, mPaintTransparent);
        canvas.drawRect(mImageRect.left, mFrameRect.bottom, mImageRect.right, mImageRect.bottom, mPaintTransparent);
        canvas.drawRect(mImageRect.left, mFrameRect.top, mFrameRect.left, mFrameRect.bottom, mPaintTransparent);
        canvas.drawRect(mFrameRect.right, mFrameRect.top, mImageRect.right, mFrameRect.bottom, mPaintTransparent);
    }

    mPaintFrame.setAntiAlias(true);
    mPaintFrame.setFilterBitmap(true);
    mPaintFrame.setStyle(Paint.Style.STROKE);
    mPaintFrame.setColor(mFrameColor);
    mPaintFrame.setStrokeWidth(mFrameStrokeWeight);

    canvas.drawRect(mFrameRect.left, mFrameRect.top, mFrameRect.right, mFrameRect.bottom, mPaintFrame);

    if (mShowGuide) {
        mPaintFrame.setColor(mGuideColor);
        mPaintFrame.setStrokeWidth(mGuideStrokeWeight);
        float h1 = mFrameRect.left + (mFrameRect.right - mFrameRect.left) / 3.0f;
        float h2 = mFrameRect.right - (mFrameRect.right - mFrameRect.left) / 3.0f;
        float v1 = mFrameRect.top + (mFrameRect.bottom - mFrameRect.top) / 3.0f;
        float v2 = mFrameRect.bottom - (mFrameRect.bottom - mFrameRect.top) / 3.0f;

        canvas.drawLine(h1, mFrameRect.top, h1, mFrameRect.bottom, mPaintFrame);
        canvas.drawLine(h2, mFrameRect.top, h2, mFrameRect.bottom, mPaintFrame);
        canvas.drawLine(mFrameRect.left, v1, mFrameRect.right, v1, mPaintFrame);
        canvas.drawLine(mFrameRect.left, v2, mFrameRect.right, v2, mPaintFrame);
    }

    if (mShowHandle) {
        mPaintFrame.setStyle(Paint.Style.FILL);
        mPaintFrame.setColor(mHandleColor);
        canvas.drawCircle(mFrameRect.left, mFrameRect.top, mHandleSize, mPaintFrame);
        canvas.drawCircle(mFrameRect.right, mFrameRect.top, mHandleSize, mPaintFrame);
        canvas.drawCircle(mFrameRect.left, mFrameRect.bottom, mHandleSize, mPaintFrame);
        canvas.drawCircle(mFrameRect.right, mFrameRect.bottom, mHandleSize, mPaintFrame);
    }
}
 
开发者ID:liuyanggithub,项目名称:SuperSelector,代码行数:56,代码来源:CropImageView.java


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