【发布时间】:2015-12-20 08:35:18
【问题描述】:
我目前正在画布中绘制圆形和矩形,现在我想要删除部分圆形笔触,使其看起来与矩形相结合。
代码:
public void setup() {
mLinePaint = new Paint();
mLinePaint.setAntiAlias(true);
mLinePaint.setStyle(Paint.Style.STROKE);
mLinePaint.setColor(ContextCompat.getColor(getContext(), R.color.white));
mCirclePaint = new Paint();
mCirclePaint.setAntiAlias(true);
mCirclePaint.setStyle(Paint.Style.FILL_AND_STROKE);
mCirclePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
mCirclePaint.setColor(ContextCompat.getColor(getContext(), R.color.white));
mLineRect = new Rect(100, 0, 200, 300);
mBackgroundColor = ContextCompat.getColor(getContext(), R.color.colorPrimaryDark);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//the background color of the canvas
canvas.drawColor(mBackgroundColor);
//the rectangle line in the background only border
canvas.drawRect(mLineRect, mLinePaint);
canvas.drawCircle(viewWidth / 2, viewHeight / 2, LINE_HEIGTH * 2, mCirclePaint);
}
如上图所示圆形笔划仍未被截断,有没有办法截掉部分笔划?
【问题讨论】: