提交 953b304d 编写于 作者: E ester.zhou

update ts-components-canvas-canvasgradient.md (8035)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 3e87bac0
# CanvasGradient
> **NOTE**<br>
> **NOTE**
>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
......@@ -17,12 +18,13 @@ Adds a color stop for the **CanvasGradient** object based on the specified offse
- Parameters
| Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
| offset | number | Yes | 0 | Proportion of the distance between the color stop and the start point to the total length. The value ranges from 0 to 1. |
| color | string | Yes | 'ffffff' | Gradient color to set. |
| offset | number | Yes | 0 | Proportion of the distance between the color stop and the start point to the total length. The value ranges from 0 to 1. |
| color | string | Yes | '#ffffff'| Gradient color to set. |
- Example
```
```ts
// xxx.ets
@Entry
@Component
struct Page45 {
......@@ -37,9 +39,9 @@ Adds a color stop for the **CanvasGradient** object based on the specified offse
.backgroundColor('#ffff00')
.onReady(() =>{
var grad = this.context.createLinearGradient(50,0, 300,100)
this.grad.addColorStop(0.0, 'red')
this.grad.addColorStop(0.5, 'white')
this.grad.addColorStop(1.0, 'green')
grad.addColorStop(0.0, 'red')
grad.addColorStop(0.5, 'white')
grad.addColorStop(1.0, 'green')
this.context.fillStyle = grad
this.context.fillRect(0, 0, 500, 500)
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册