-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from XianZhengquan/release/v1.1.0
Release/v1.1.0
- Loading branch information
Showing
7 changed files
with
42 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
import { IRoundRectType } from '../types'; | ||
|
||
type DrawRoundRectType = (cxt: CanvasRenderingContext2D, props: Omit<IRoundRectType, 'x' | 'y' | 'backgroundColor' | 'callback' | 'type'>) => void | ||
type DrawRoundRectType = (ctx: CanvasRenderingContext2D, props: Omit<IRoundRectType, 'x' | 'y' | 'backgroundColor' | 'callback' | 'type'>) => void | ||
|
||
const drawRoundRectPath: DrawRoundRectType = (cxt, props) => { | ||
const drawRoundRectPath: DrawRoundRectType = (ctx, props) => { | ||
const { width, height, radius } = props; | ||
|
||
cxt.beginPath(); | ||
ctx.beginPath(); | ||
//从右下角顺时针绘制,弧度从0到1/2PI | ||
cxt.arc(width - radius, height - radius, radius, 0, Math.PI / 2); | ||
ctx.arc(width - radius, height - radius, radius, 0, Math.PI / 2); | ||
|
||
//矩形下边线 | ||
cxt.lineTo(radius, height); | ||
ctx.lineTo(radius, height); | ||
|
||
//左下角圆弧,弧度从1/2PI到PI | ||
cxt.arc(radius, height - radius, radius, Math.PI / 2, Math.PI); | ||
ctx.arc(radius, height - radius, radius, Math.PI / 2, Math.PI); | ||
|
||
//矩形左边线 | ||
cxt.lineTo(0, radius); | ||
ctx.lineTo(0, radius); | ||
|
||
//左上角圆弧,弧度从PI到3/2PI | ||
cxt.arc(radius, radius, radius, Math.PI, (Math.PI * 3) / 2); | ||
ctx.arc(radius, radius, radius, Math.PI, (Math.PI * 3) / 2); | ||
|
||
//上边线 | ||
cxt.lineTo(width - radius, 0); | ||
ctx.lineTo(width - radius, 0); | ||
|
||
//右上角圆弧 | ||
cxt.arc(width - radius, radius, radius, (Math.PI * 3) / 2, Math.PI * 2); | ||
ctx.arc(width - radius, radius, radius, (Math.PI * 3) / 2, Math.PI * 2); | ||
|
||
//右边线 | ||
cxt.lineTo(width, height - radius); | ||
cxt.closePath(); | ||
ctx.lineTo(width, height - radius); | ||
ctx.closePath(); | ||
}; | ||
|
||
export default drawRoundRectPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters