maoruibin / maoruibin/maoruibin.github.com

绘制只有两个圆角的圆角矩形

Open
#29 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

trick View
Dominant language
HTML
Stars
22
Forks
4
PR merge metrics
No merged PRs in 30d

Description

canvas.save();
mChartPaint.setColor(color);
canvas.clipRect(rect.left, rect.top, rect.right, rect.bottom - roundRadius, Region.Op.INTERSECT);
canvas.drawRoundRect(rect, roundRadius, roundRadius, mChartPaint);
canvas.restore();

一般的 drawRoundRect 方法画出的圆角矩形为四个圆角,但是一些情况下,设计师设计出的 UI 可能只有顶部两个圆角,如下所示

image

这时,可以使用 clipRect 进行裁剪,巧妙做到绘制区域的裁剪

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file, test, or entry point is named. First determine whether this issue is intended to add or revise a blog post, using the supplied Java Canvas example and two-corner design image as the content reference. Done should be a published, accurate explanation after the maintainers confirm the scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.