Skip to content

Commit

Permalink
refactor(types): sync components types
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Sep 16, 2023
1 parent f82561d commit 19836b1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
22 changes: 20 additions & 2 deletions docs/apis/canvas/CanvasContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,18 @@ ctx.fill()
ctx.draw()
```
### reset
重置绘图上下文状态
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>
> [参考文档](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/reset)
```tsx
() => void
```
### restore
恢复之前保存的绘图上下文
Expand Down Expand Up @@ -1307,11 +1319,13 @@ ctx.stroke()
ctx.setFontSize(15)
ctx.setTextAlign('left')
ctx.fillText('textAlign=left', 150, 60)
await ctx.draw(true)
ctx.setTextAlign('center')
ctx.fillText('textAlign=center', 150, 80)
await ctx.draw(true)
ctx.setTextAlign('right')
ctx.fillText('textAlign=right', 150, 100)
ctx.draw()
await ctx.draw(true)
```
### setTextBaseline
Expand Down Expand Up @@ -1341,13 +1355,16 @@ ctx.stroke()
ctx.setFontSize(20)
ctx.setTextBaseline('top')
ctx.fillText('top', 5, 75)
await ctx.draw(true)
ctx.setTextBaseline('middle')
ctx.fillText('middle', 50, 75)
await ctx.draw(true)
ctx.setTextBaseline('bottom')
ctx.fillText('bottom', 120, 75)
await ctx.draw(true)
ctx.setTextBaseline('normal')
ctx.fillText('normal', 200, 75)
ctx.draw()
await ctx.draw(true)
```
### setTransform
Expand Down Expand Up @@ -1594,6 +1611,7 @@ ctx.draw()
| CanvasContext.moveTo | ✔️ | ✔️ | | |
| CanvasContext.quadraticCurveTo | ✔️ | ✔️ | | |
| CanvasContext.rect | ✔️ | ✔️ | | |
| CanvasContext.reset | | ✔️ | | |
| CanvasContext.restore | ✔️ | ✔️ | | |
| CanvasContext.rotate | ✔️ | ✔️ | | |
| CanvasContext.save | ✔️ | ✔️ | | |
Expand Down
14 changes: 12 additions & 2 deletions packages/taro/types/api/canvas/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,11 @@ declare module '../../index' {
/** 矩形路径的高度 */
height: number,
): void
/** 重置绘图上下文状态
* @supported h5
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/reset
*/
reset(): void
/** 恢复之前保存的绘图上下文
* @supported weapp, h5
* @example
Expand Down Expand Up @@ -1230,11 +1235,13 @@ declare module '../../index' {
* ctx.setFontSize(15)
* ctx.setTextAlign('left')
* ctx.fillText('textAlign=left', 150, 60)
* await ctx.draw(true)
* ctx.setTextAlign('center')
* ctx.fillText('textAlign=center', 150, 80)
* await ctx.draw(true)
* ctx.setTextAlign('right')
* ctx.fillText('textAlign=right', 150, 100)
* ctx.draw()
* await ctx.draw(true)
* ```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextAlign.html
*/
Expand All @@ -1254,13 +1261,16 @@ declare module '../../index' {
* ctx.setFontSize(20)
* ctx.setTextBaseline('top')
* ctx.fillText('top', 5, 75)
* await ctx.draw(true)
* ctx.setTextBaseline('middle')
* ctx.fillText('middle', 50, 75)
* await ctx.draw(true)
* ctx.setTextBaseline('bottom')
* ctx.fillText('bottom', 120, 75)
* await ctx.draw(true)
* ctx.setTextBaseline('normal')
* ctx.fillText('normal', 200, 75)
* ctx.draw()
* await ctx.draw(true)
* ```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextBaseline.html
*/
Expand Down

0 comments on commit 19836b1

Please sign in to comment.