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

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

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