提交 bc8d7477 编写于 作者: H HelloCrease

update docs

Signed-off-by: NHelloCrease <lian15@huawei.com>
上级 0564e5e7
......@@ -4,9 +4,9 @@ The **\<svg>** component is a basic container. It can be used as the root node o
> **NOTE**
> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
>
> - The width and height must be defined for the **<svg>** parent component or **<svg>** component. Otherwise, the component is not drawn.
> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
>
> - The width and height must be defined for the **<svg>** parent component or **<svg>** component. Otherwise, the component is not drawn.
## Required Permissions
......@@ -15,21 +15,21 @@ None
## Child Components
The following are supported: [\<svg>](js-components-svg.md), [\<rect>](js-components-svg-rect.md), [\<circle>](js-components-svg-circle.md), [\<ellipse>](../arkui-js/js-components-svg-ellipse.md), [\<path>](js-components-svg-path.md), [\<line](../arkui-js/js-components-svg-line.md), [\<polygon>](../arkui-js/js-components-svg-polygon.md), [\<polyline>](js-components-svg-polyline.md), [\<text>](js-components-svg-text.md), [\<animate>](js-components-svg-animate.md), and [\<animateTransform>](js-components-svg-animateTransform.md).
The following are supported: [\<svg>](js-components-svg.md), [\<rect>](js-components-svg-rect.md), [\<circle>](js-components-svg-circle.md), [\<ellipse>](../arkui-js/js-components-svg-ellipse.md), [\<path>](js-components-svg-path.md), [\<line](../arkui-js/js-components-svg-line.md), [\<polygon>](../arkui-js/js-components-svg-polygon.md), [\<polyline>](js-components-svg-polyline.md), [\<text>](js-components-svg-text.md), [\<animate>](js-components-svg-animate.md), and [\<animateTransform>](js-components-svg-animatetransform.md).
## Attributes
The [universal attributes](../arkui-js/js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components.
| Name| Type| Default Value| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- |
| id | string | - | No| Unique ID of the component.|
| width | &lt;length&gt;\|&lt;percentage&gt; | - | No| Component width.|
| height | &lt;length&gt;\|&lt;percentage&gt; | - | No| Component height.|
| x | &lt;length&gt;\|&lt;percentage&gt; | - | No| X-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. |
| y | &lt;length&gt;\|&lt;percentage&gt; | | No| Y-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. |
| viewBox | string | - | No| View box of the current **\<svg>** component. The supported format is \<number number number number>. The four parameters indicate **min-x**, **min-y**, **width**, and **height**, respectively. The width and height of the view box are different from those of the **\<svg>** component. The view box is scaled in center-aligned mode. |
| Name | Type | Default Value | Mandatory | Description |
| ------- | ---------------------------------- | ------------- | --------- | ---------------------------------------- |
| id | string | - | No | Unique ID of the component. |
| width | &lt;length&gt;\|&lt;percentage&gt; | - | No | Component width. |
| height | &lt;length&gt;\|&lt;percentage&gt; | - | No | Component height. |
| x | &lt;length&gt;\|&lt;percentage&gt; | - | No | X-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. |
| y | &lt;length&gt;\|&lt;percentage&gt; | | No | Y-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. |
| viewBox | string | - | No | View box of the current **\<svg>** component. The supported format is \<number number number number>. The four parameters indicate **min-x**, **min-y**, **width**, and **height**, respectively. The width and height of the view box are different from those of the **\<svg>** component. The view box is scaled in center-aligned mode. |
## Example
......
......@@ -17,53 +17,53 @@ This component contains the child component **[\<GridItem>](ts-container-gridite
Grid(scroller?: Scroller)
**Parameters**
| Name | Type | Mandatory | Description |
| --------- | ---------------------------------------- | ---- | ----------------------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | No | Scroller, which can be bound to scrollable components.|
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | --------- | ---------------------------------------- |
| scroller | [Scroller](ts-container-scroll.md#scroller) | No | Scroller, which can be bound to scrollable components. |
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
| Name| Type| Description|
| -------- | -------- | -------- |
| columnsTemplate | string | Number of columns in the current grid layout. If this attribute is not set, one column is used by default.<br>For example, **'1fr 1fr 2fr'** indicates three columns, with the first column taking up 1/4 of the parent component's full width, the second column 1/4, and the third column 2/4. This attribute supports [auto-fill] (#auto-fill description).<br>Default value: **'1fr'**|
| rowsTemplate | string | Number of rows in the current grid layout. If this attribute is not set, one row is used by default.<br>For example, **'1fr 1fr 2fr'** indicates three rows, with the first row taking up 1/4 of the parent component's full height, the second row 1/4, and the third row 2/4. This attribute supports [auto-fill] (#auto-fill description).<br>Default value: **'1fr'**|
| columnsGap | Length | Gap between columns.<br>Default value: **0**|
| rowsGap | Length | Gap between rows.<br>Default value: **0**|
| scrollBar | [BarState](ts-appendix-enums.md#barstate) | Scrollbar status.<br>Default value: **BarState.Off**|
| scrollBarColor | string \| number \| Color | Color of the scrollbar.|
| scrollBarWidth | string \| number | Width of the scrollbar.|
| cachedCount | number | Number of grid items to be preloaded. For details, see [Minimizing White Blocks During Swiping](../../ui/ts-performance-improvement-recommendation.md#minimizing-white-blocks-during-swiping).<br>Default value: **1**|
| editMode <sup>8+</sup> | boolean | Whether to enter editing mode. In editing mode, the user can drag the **\<[GridItem](ts-container-griditem.md)>** in the **\<Grid>** component.<br>Default value: **false**|
| layoutDirection<sup>8+</sup> | [GridDirection](#griddirection8) | Main axis direction of the grid.<br>Default value: **GridDirection.Row**|
| maxCount<sup>8+</sup> | number | When **layoutDirection** is **Row** or **RowReverse**: maximum number of rows that can be displayed.<br>When **layoutDirection** is **Column** or **ColumnReverse**: maximum number of columns that can be displayed.<br>Default value: **1**|
| minCount<sup>8+</sup> | number | When **layoutDirection** is **Row** or **RowReverse**: minimum number of rows that can be displayed.<br>When **layoutDirection** is **Column** or **ColumnReverse**: minimum number of columns that can be displayed.<br>Default value: **1**|
| cellLength<sup>8+</sup> | number | When **layoutDirection** is **Row** or **RowReverse**: fixed height per row.<br>When **layoutDirection** is **Column** or **ColumnReverse**: fixed width per column.<br>Default value: **0**|
| multiSelectable<sup>8+</sup> | boolean | Whether to enable mouse frame selection.<br>Default value: **false**<br>- **false**: The mouse frame selection is disabled.<br>- **true**: The mouse frame selection is enabled.|
| supportAnimation<sup>8+</sup> | boolean | Whether to enable animation.<br>Default value: **false**|
| Name | Type | Description |
| ----------------------------- | ---------------------------------------- | ---------------------------------------- |
| columnsTemplate | string | Number of columns in the current grid layout. If this attribute is not set, one column is used by default.<br>For example, **'1fr 1fr 2fr'** indicates three columns, with the first column taking up 1/4 of the parent component's full width, the second column 1/4, and the third column 2/4. This attribute supports [auto-fill] (#auto-fill description).<br>Default value: **'1fr'** |
| rowsTemplate | string | Number of rows in the current grid layout. If this attribute is not set, one row is used by default.<br>For example, **'1fr 1fr 2fr'** indicates three rows, with the first row taking up 1/4 of the parent component's full height, the second row 1/4, and the third row 2/4. This attribute supports [auto-fill] (#auto-fill description).<br>Default value: **'1fr'** |
| columnsGap | Length | Gap between columns.<br>Default value: **0** |
| rowsGap | Length | Gap between rows.<br>Default value: **0** |
| scrollBar | [BarState](ts-appendix-enums.md#barstate) | Scrollbar status.<br>Default value: **BarState.Off** |
| scrollBarColor | string \| number \| Color | Color of the scrollbar. |
| scrollBarWidth | string \| number | Width of the scrollbar. |
| cachedCount | number | Number of grid items to be preloaded. For details, see [Minimizing White Blocks During Swiping](../../ui/ts-performance-improvement-recommendation.md#minimizing-white-blocks-during-swiping).<br>Default value: **1** |
| editMode <sup>8+</sup> | boolean | Whether to enter editing mode. In editing mode, the user can drag the **\<[GridItem](ts-container-griditem.md)>** in the **\<Grid>** component.<br>Default value: **false** |
| layoutDirection<sup>8+</sup> | [GridDirection](#griddirection8) | Main axis direction of the grid.<br>Default value: **GridDirection.Row** |
| maxCount<sup>8+</sup> | number | When **layoutDirection** is **Row** or **RowReverse**: maximum number of rows that can be displayed.<br>When **layoutDirection** is **Column** or **ColumnReverse**: maximum number of columns that can be displayed.<br>Default value: **1** |
| minCount<sup>8+</sup> | number | When **layoutDirection** is **Row** or **RowReverse**: minimum number of rows that can be displayed.<br>When **layoutDirection** is **Column** or **ColumnReverse**: minimum number of columns that can be displayed.<br>Default value: **1** |
| cellLength<sup>8+</sup> | number | When **layoutDirection** is **Row** or **RowReverse**: fixed height per row.<br>When **layoutDirection** is **Column** or **ColumnReverse**: fixed width per column.<br>Default value: **0** |
| multiSelectable<sup>8+</sup> | boolean | Whether to enable mouse frame selection.<br>Default value: **false**<br>- **false**: The mouse frame selection is disabled.<br>- **true**: The mouse frame selection is enabled. |
| supportAnimation<sup>8+</sup> | boolean | Whether to enable animation.<br>Default value: **false** |
## GridDirection<sup>8+</sup>
| Name | Description |
| ------ | -------------------------------------- |
| Row | Horizontal layout, where the child components are arranged from left to right as the main axis runs along the rows.|
| Column | Vertical layout, where the child components are arranged from top to bottom as the main axis runs down the columns.|
| RowReverse | Reverse horizontal layout, where the child components are arranged from right to left as the main axis runs along the rows.|
| ColumnReverse | Reverse vertical layout, where the child components are arranged from bottom up as the main axis runs down the columns.|
| Name | Description |
| ------------- | ---------------------------------------- |
| Row | Horizontal layout, where the child components are arranged from left to right as the main axis runs along the rows. |
| Column | Vertical layout, where the child components are arranged from top to bottom as the main axis runs down the columns. |
| RowReverse | Reverse horizontal layout, where the child components are arranged from right to left as the main axis runs along the rows. |
| ColumnReverse | Reverse vertical layout, where the child components are arranged from bottom up as the main axis runs down the columns. |
## Events
In addition to the [universal events](ts-universal-events-click.md), the following events are supported.
| Name| Description|
| -------- | -------- |
| onScrollIndex(event: (first: number) => void) | Triggered when the start item of the grid changes.<br>- **first**: index of the start item of the grid.|
| onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => (() => any) \| void) | Triggered when a grid item starts to be dragged.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: index of the dragged element.|
| onItemDragEnter(event: (event: ItemDragInfo) => void) | Triggered when the dragged item enters the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo).|
| onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void) | Triggered when the dragged item moves over the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: initial position of the dragged item.<br>- **insertIndex**: index of the position to which the dragged item will be dropped.|
| onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void) | Triggered when the dragged item exits the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: index of the dragged item.|
| onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) | Triggered when the dragged item is dropped on the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: initial position of the dragged item.<br>- **insertIndex**: index of the position to which the dragged item will be dropped.<br>- **isSuccess**: whether the dragged item is successfully dropped.|
| Name | Description |
| ---------------------------------------- | ---------------------------------------- |
| onScrollIndex(event: (first: number) => void) | Triggered when the start item of the grid changes.<br>- **first**: index of the start item of the grid. |
| onItemDragStart(event: (event: ItemDragInfo, itemIndex: number) => (() => any) \| void) | Triggered when a grid item starts to be dragged.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: index of the dragged element. |
| onItemDragEnter(event: (event: ItemDragInfo) => void) | Triggered when the dragged item enters the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo). |
| onItemDragMove(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number) => void) | Triggered when the dragged item moves over the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: initial position of the dragged item.<br>- **insertIndex**: index of the position to which the dragged item will be dropped. |
| onItemDragLeave(event: (event: ItemDragInfo, itemIndex: number) => void) | Triggered when the dragged item exits the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: index of the dragged item. |
| onItemDrop(event: (event: ItemDragInfo, itemIndex: number, insertIndex: number, isSuccess: boolean) => void) | Triggered when the dragged item is dropped on the drop target of the grid.<br>- **event**: See [ItemDragInfo](#itemdraginfo).<br>- **itemIndex**: initial position of the dragged item.<br>- **insertIndex**: index of the position to which the dragged item will be dropped.<br>- **isSuccess**: whether the dragged item is successfully dropped. |
## Notes About auto-fill
......@@ -77,10 +77,10 @@ The keywords **repeat** and **auto-fill** are used. **track-size** indicates the
## ItemDragInfo
| Name | Type | Description |
| ---------- | ---------- | ---------- |
| x | number | X-coordinate of the dragged item. |
| y | number | Y-coordinate of the dragged item. |
| Name | Type | Description |
| ---- | ------ | --------------------------------- |
| x | number | X-coordinate of the dragged item. |
| y | number | Y-coordinate of the dragged item. |
## Example
......@@ -144,7 +144,7 @@ struct GridExample {
}
```
![zh-cn_image_0000001219744183](figures/zh-cn_image_0000001219744183.gif)
![en-us_image_0000001219744183](figures/en-us_image_0000001219744183.gif)
**Example of auto-fill**
......
......@@ -17,45 +17,45 @@ Path(value?: { width?: number | string; height?: number | string; commands?: str
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------- | ---- | ----------------------------------- |
| width | number \| string | No | Width of the rectangle where the path is located.<br>Default value: **0** |
| height | number \| string | No | Height of the rectangle where the path is located.<br>Default value: **0** |
| commands | string | No | Command for drawing the path.<br>Default value: **''**|
| Name | Type | Mandatory | Description |
| -------- | ---------------- | --------- | ---------------------------------------- |
| width | number \| string | No | Width of the rectangle where the path is located.<br>Default value: **0** |
| height | number \| string | No | Height of the rectangle where the path is located.<br>Default value: **0** |
| commands | string | No | Command for drawing the path.<br>Default value: **''** |
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
| Name | Type | Default Value | Mandatory | Description |
| -------- | ----------------------------------- | ---- | ---- | ---------------------------------------- |
| commands | string | '' | No | Command for drawing the path. The unit is px. For details about how to convert the pixel units, see [Pixel Unit Conversion](../../ui/ts-pixel-units.md).|
| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No| Color of the fill area.|
| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | No| Opacity of the fill area.|
| stroke | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No| Stroke color.|
| strokeDashArray | Array&lt;Length&gt; | [] | No| Stroke dashes.|
| strokeDashOffset | number \| string | 0 | No| Offset of the start point for drawing the stroke.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | No| Cap style of the stroke.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | No| Join style of the stroke.|
| strokeMiterLimit | number \| string | 4 | No| Limit value when the sharp angle is drawn as a miter.|
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | No| Opacity of the stroke.|
| strokeWidth | Length | 1 | No| Width of the stroke.|
| antiAlias | boolean | true | No| Whether anti-aliasing is enabled.|
| Name | Type | Default Value | Mandatory | Description |
| ---------------- | ---------------------------------------- | ------------------- | --------- | ---------------------------------------- |
| commands | string | '' | No | Command for drawing the path. The unit is px. For details about how to convert the pixel units, see [Pixel Unit Conversion](../../ui/ts-pixel-units.md). |
| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No | Color of the fill area. |
| fillOpacity | number \| string \| [Resource](ts-types.md#resource) | 1 | No | Opacity of the fill area. |
| stroke | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No | Stroke color. |
| strokeDashArray | Array&lt;Length&gt; | [] | No | Stroke dashes. |
| strokeDashOffset | number \| string | 0 | No | Offset of the start point for drawing the stroke. |
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | No | Cap style of the stroke. |
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | No | Join style of the stroke. |
| strokeMiterLimit | number \| string | 4 | No | Limit value when the sharp angle is drawn as a miter. |
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource) | 1 | No | Opacity of the stroke. |
| strokeWidth | Length | 1 | No | Width of the stroke. |
| antiAlias | boolean | true | No | Whether anti-aliasing is enabled. |
The supported commands are as follows:
| Command | Attribute | Parameter | Description |
| ---- | -------------------------------- | ---------------------------------------- | ---------------------------------------- |
| M | moveto | (x y) | Starts a new subpath at the point specified by the given (x, y) coordinates. For example, `M 0 0` starts a new subpath at point (0, 0).|
| L | lineto | (x y) | Draws a line from the current point to the point specified by the given (x, y) coordinates. The specified point becomes the start point of the new subpath. For example, `L 50 50` draws a line from the current point to point (50, 50), which is the start point of the new subpath.|
| H | horizontal lineto | x | Draws a horizontal line from the current point. This command is equivalent to the **L** command where the y-coordinate is 0. For example, `H 50 ` draws a line from the current point to point (50, 0), which is the start point of the new subpath.|
| V | vertical lineto | y | Draws a vertical line from the current point. This command is equivalent to the **L** command where the x-coordinate is 0. For example, `V 50 ` draws a line from the current point to point (0, 50), which is the start point of the new subpath.|
| C | curveto | (x1 y1 x2 y2 x y) | Draws a cubic Bezier curve from the current point to the point specified by the given (x, y) coordinates, with (x1, y1) as the control point of the curve start point and (x2, y2) as the control point of the curve end point. For example, `C100 100 250 100 250 200 ` draws a cubic Bezier curve from the current point to point (250, 200), which is the start point of the new subpath.|
| S | smooth curveto | (x2 y2 x y) | Draws a cubic Bezier curve from the current point to the point specified by the given (x, y) coordinates, with (x2, y2) as the control point of the curve end point. If the previous command is **C** or **S**, the control point of the curve start point is the mapping of the control point of the curve end point in the previous command relative to the start point. For example, in `C100 100 250 100 250 200 S400 300 400 200`, the second segment of the cubic Bezier curve uses point (250, 300) as the control point of the curve start point. If there is no previous command or the previous command is not **C** or **S**, the control point of the curve start point coincides with the current point.|
| Q | quadratic Belzier curve | (x1 y1 x y) | Use (x1, y1) as the control point to draw a quadratic Bessel curve from the current point to (x, y). For example, Q400 50 600 300 indicates that a quadratic Bessel curve from the current point to the (600, 300) point is drawn, and the (600, 300) point is used as the starting point of the new subpath.|
| T | smooth quadratic Belzier curveto | (x y) | Draw a quadratic Bessel curve from the current point to (x, y). If the previous command is Q or T, the control point is the mapping of the end point control point of the previous command relative to the start point. For example, a control point of the second Bessel curve segment of the Q400 50 600 300 T1000 300 is (800, 350). If there is no previous command or the previous command is not Q or T, the first control point coincides with the current point.|
| A | elliptical Arc | (rx ry x-axis-rotation large-arc-flag sweep-flag x y) | Draws an elliptical arc from the current point to (x, y). The size and direction of an ellipse are defined by two radiuses (rx, ry) and x-axis-rotation, indicating how the entire ellipse rotates relative to the current coordinate system (in degrees). large-arc-flag and sweep-flag determine an arc drawing manner.|
| Z | closepath | none | Closes the current subpath by connecting the current path back to the initial point of the current subpath. |
| Command | Attribute | Parameter | Description |
| ------- | -------------------------------- | ---------------------------------------- | ---------------------------------------- |
| M | moveto | (x y) | Starts a new subpath at the point specified by the given (x, y) coordinates. For example, `M 0 0` starts a new subpath at point (0, 0). |
| L | lineto | (x y) | Draws a line from the current point to the point specified by the given (x, y) coordinates. The specified point becomes the start point of the new subpath. For example, `L 50 50` draws a line from the current point to point (50, 50), which is the start point of the new subpath. |
| H | horizontal lineto | x | Draws a horizontal line from the current point. This command is equivalent to the **L** command where the y-coordinate is 0. For example, `H 50 ` draws a line from the current point to point (50, 0), which is the start point of the new subpath. |
| V | vertical lineto | y | Draws a vertical line from the current point. This command is equivalent to the **L** command where the x-coordinate is 0. For example, `V 50 ` draws a line from the current point to point (0, 50), which is the start point of the new subpath. |
| C | curveto | (x1 y1 x2 y2 x y) | Draws a cubic Bezier curve from the current point to the point specified by the given (x, y) coordinates, with (x1, y1) as the control point of the curve start point and (x2, y2) as the control point of the curve end point. For example, `C100 100 250 100 250 200 ` draws a cubic Bezier curve from the current point to point (250, 200), which is the start point of the new subpath. |
| S | smooth curveto | (x2 y2 x y) | Draws a cubic Bezier curve from the current point to the point specified by the given (x, y) coordinates, with (x2, y2) as the control point of the curve end point. If the previous command is **C** or **S**, the control point of the curve start point is the mapping of the control point of the curve end point in the previous command relative to the start point. For example, in `C100 100 250 100 250 200 S400 300 400 200`, the second segment of the cubic Bezier curve uses point (250, 300) as the control point of the curve start point. If there is no previous command or the previous command is not **C** or **S**, the control point of the curve start point coincides with the current point. |
| Q | quadratic Belzier curve | (x1 y1 x y) | Use (x1, y1) as the control point to draw a quadratic Bessel curve from the current point to (x, y). For example, Q400 50 600 300 indicates that a quadratic Bessel curve from the current point to the (600, 300) point is drawn, and the (600, 300) point is used as the starting point of the new subpath. |
| T | smooth quadratic Belzier curveto | (x y) | Draw a quadratic Bessel curve from the current point to (x, y). If the previous command is Q or T, the control point is the mapping of the end point control point of the previous command relative to the start point. For example, a control point of the second Bessel curve segment of the Q400 50 600 300 T1000 300 is (800, 350). If there is no previous command or the previous command is not Q or T, the first control point coincides with the current point. |
| A | elliptical Arc | (rx ry x-axis-rotation large-arc-flag sweep-flag x y) | Draws an elliptical arc from the current point to (x, y). The size and direction of an ellipse are defined by two radiuses (rx, ry) and x-axis-rotation, indicating how the entire ellipse rotates relative to the current coordinate system (in degrees). large-arc-flag and sweep-flag determine an arc drawing manner. |
| Z | closepath | none | Closes the current subpath by connecting the current path back to the initial point of the current subpath. |
For example, commands('M0 20 L50 50 L50 100 Z') defines a triangle that starts from position (0, 20), draws a straight line from point (0, 20) to point (50, 50), draws a straight line from point (50, 50) to point (50, 100), and draws a closed path from point (50, 100) to point (0, 20) to form a closed triangle.
......@@ -67,26 +67,77 @@ For example, commands('M0 20 L50 50 L50 100 Z') defines a triangle that starts f
@Component
struct PathExample {
build() {
Column({ space: 5 }) {
Text('Straight line').fontSize(9).fontColor(0xCCCCCC).width('90%')
// Draw a straight line with a length of 900px and a width of 3vp.
Path().width(300).height(10).commands('M0 0 L900 0').stroke(Color.Black).strokeWidth(3)
Text('Straight line graph').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Path().width(100).height(100).commands('M150 0 L300 300 L0 300 Z')
Path().width(100).height(100).commands('M0 0 H300 V300 H0 Z')
Path().width(100).height(100).commands('M150 0 L0 150 L60 300 L240 300 L300 150 Z')
Column({ space: 10 }) {
Text('Straight line')
.fontSize(11)
.fontColor(0xCCCCCC)
.width('90%')
Path()
.width(300)
.height(10)
.commands('M0 0 L900 0')
.stroke(Color.Black)
.strokeWidth(3)
Text('Straight line graph')
.fontSize(11)
.fontColor(0xCCCCCC)
.width('90%')
Row({ space: 20 }) {
Path()
.width(100)
.height(100)
.commands('M150 0 L300 300 L0 300 Z')
.fillOpacity(0)
.stroke(Color.Black)
.strokeWidth(3)
Path()
.width(100)
.height(100)
.commands('M0 0 H300 V300 H0 Z')
.fillOpacity(0)
.stroke(Color.Black)
.strokeWidth(3)
Path()
.width(100)
.height(100)
.commands('M150 0 L0 150 L60 300 L240 300 L300 150 Z')
.fillOpacity(0)
.stroke(Color.Black)
.strokeWidth(3)
}.width('100%')
Text('Curve graphics').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Path().width(100).height(100).commands("M0 300 S150 0 300 300 Z")
Path().width(100).height(100).commands('M0 150 C0 150 150 0 300 150 L150 300 Z')
Text('Curve graphics').fontSize(11).fontColor(0xCCCCCC).width('90%')
Row({ space: 20 }) {
Path()
.width(100)
.height(100)
.commands("M0 300 S150 0 300 300 Z")
.fillOpacity(0)
.stroke(Color.Black)
.strokeWidth(3)
Path()
.width(100)
.height(100)
.commands('M0 150 C0 150 150 0 300 150 L150 300 Z')
.fillOpacity(0)
.stroke(Color.Black)
.strokeWidth(3)
Path()
.width(100)
.height(100)
.commands('M0 200 A30 20 20 0 0 250 200 Z')
.fillOpacity(0)
.stroke(Color.Black)
.strokeWidth(3)
}
}.width('100%').margin({ top: 5 })
}.width('100%')
.margin({ top: 5 })
}
}
```
![zh-cn_image_0000001219744193](figures/zh-cn_image_0000001219744193.png)
![en-us_image_0000001219744193.png](figures/en-us_image_0000001219744193.png)
......@@ -17,38 +17,38 @@ Not supported
Polygon(value?: {width?: string | number, height?: string | number})
- Parameters
| Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- |
| width | string \| number | No| 0 | Width.|
| height | string \| number | No| 0 | Height.|
| Name | Type | Mandatory | Default Value | Description |
| ------ | ---------------- | --------- | ------------- | ----------- |
| width | string \| number | No | 0 | Width. |
| height | string \| number | No | 0 | Height. |
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
| Name| Type| Default Value| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- |
| points | Array&lt;Point&gt; | [] | No| Vertex coordinates of the polygon.|
| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No| Color of the fill area.|
| fillOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | No| Opacity of the fill area.|
| stroke | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No| Stroke color.|
| strokeDashArray | Array&lt;Length&gt; | [] | No| Stroke dashes.|
| strokeDashOffset | number \| string | 0 | No| Offset of the start point for drawing the stroke.|
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | No| Cap style of the stroke.|
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | No| Join style of the stroke.|
| strokeMiterLimit | number \| string | 4 | No| Limit value when the sharp angle is drawn as a miter.|
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource)| 1 | No| Stroke opacity.|
| strokeWidth | Length | 1 | No| Stroke width.|
| antiAlias | boolean | true | No| Whether anti-aliasing is enabled.|
| Name | Type | Default Value | Mandatory | Description |
| ---------------- | ---------------------------------------- | ------------------- | --------- | ---------------------------------------- |
| points | Array&lt;Point&gt; | [] | No | Vertex coordinates of the polygon. |
| fill | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No | Color of the fill area. |
| fillOpacity | number \| string \| [Resource](ts-types.md#resource) | 1 | No | Opacity of the fill area. |
| stroke | [ResourceColor](ts-types.md#resourcecolor) | Color.Black | No | Stroke color. |
| strokeDashArray | Array&lt;Length&gt; | [] | No | Stroke dashes. |
| strokeDashOffset | number \| string | 0 | No | Offset of the start point for drawing the stroke. |
| strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | No | Cap style of the stroke. |
| strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | No | Join style of the stroke. |
| strokeMiterLimit | number \| string | 4 | No | Limit value when the sharp angle is drawn as a miter. |
| strokeOpacity | number \| string \| [Resource](ts-types.md#resource) | 1 | No | Stroke opacity. |
| strokeWidth | Length | 1 | No | Stroke width. |
| antiAlias | boolean | true | No | Whether anti-aliasing is enabled. |
## Point
Describes the coordinates of a point.
| Name | Type | Description |
| --------- | -------------------- | ------------------------------------------------------------ |
| Point | [number, number] | Coordinates of a point. The first parameter is the x-coordinate, and the second parameter is the y-coordinate (relative coordinate).|
| Name | Type | Description |
| ----- | ---------------- | ---------------------------------------- |
| Point | [number, number] | Coordinates of a point. The first parameter is the x-coordinate, and the second parameter is the y-coordinate (relative coordinate). |
## Example
......@@ -59,18 +59,22 @@ Describes the coordinates of a point.
@Component
struct PolygonExample {
build() {
Column({ space: 5 }) {
Flex({ justifyContent: FlexAlign.SpaceAround }) {
// Draw a triangle in a 100 x 100 rectangle. The start point is (0, 0), the end point is (100, 0), and the passing point is (50, 100).
Polygon({ width: 100, height: 100 }).points([[0, 0], [50, 100], [100, 0]])
// Draw a quadrilateral in a 100 x 100 rectangle. The start point is (0, 0), the end point is (100, 0), and the passing points are (0, 100) and (100, 100).
Polygon().width(100).height(100).points([[0, 0], [0, 100], [100, 100], [100, 0]])
// Draw a pentagon in a 100 x 100 rectangle. The start point is (50, 0), the end point is (100, 50), and the passing points are (0, 50), (20, 100), and (80, 100).
Polygon().width(100).height(100).points([[50, 0], [0, 50], [20, 100], [80, 100], [100, 50]])
}.width('100%')
}.margin({ top: 5 })
Column({ space: 10 }) {
Polygon({ width: 100, height: 100 })
.points([[0, 0], [50, 100], [100, 0]])
.fill(Color.Green)
Polygon().width(100).height(100)
.points([[0, 0], [0, 100], [100, 100], [100, 0]])
.fillOpacity(0)
.strokeWidth(5)
.stroke(Color.Blue)
Polygon().width(100).height(100)
.points([[50, 0], [0, 50], [20, 100], [80, 100], [100, 50]])
.fill(Color.Red)
.fillOpacity(0.6)
}.width('100%').margin({ top: 10 })
}
}
```
![en-us_image_0000001174582856](figures/en-us_image_0000001174582856.gif)
![en-us_image_0000001174582856.png](figures/en-us_image_0000001174582856.png)
......@@ -23,36 +23,36 @@ Matrix constructor, which is used to create a 4x4 matrix by using the input para
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------------------- | ---- | ------------------------------------------------------------ |
| array | Array&lt;number&gt; | Yes | A number array whose length is 16 (4 x 4). For details, see **array**.<br>Default value:<br>[1, 0, 0, 0,<br>0, 1, 0, 0,<br>0, 0, 1, 0,<br>0, 0, 0, 1] |
| Name | Type | Mandatory | Description |
| ----- | ------------------- | --------- | ---------------------------------------- |
| array | Array&lt;number&gt; | Yes | A number array whose length is 16 (4 x 4). For details, see **array**.<br>Default value:<br>[1, 0, 0, 0,<br>0, 1, 0, 0,<br>0, 0, 1, 0,<br>0, 0, 0, 1] |
**Return value**
| Type | Description |
| -------------- | ---------------------------- |
| Matrix4Transit | 4x4 matrix object created based on the input parameter.|
| Type | Description |
| -------------- | ---------------------------------------- |
| Matrix4Transit | 4x4 matrix object created based on the input parameter. |
**array**
| Name | Type | Mandatory | Description |
| ---- | ------ | ---- | -------------------- |
| m00 | number | Yes | Scaling value of the x-axis. Defaults to **1** for the identity matrix. |
| m01 | number | Yes | The second value, which is affected by the rotation of the x, y, and z axes. |
| m02 | number | Yes | The third value, which is affected by the rotation of the x, y, and z axes. |
| m03 | number | Yes | Meaningless. |
| m10 | number | Yes | The fifth value, which is affected by the rotation of the x, y, and z axes. |
| m11 | number | Yes | Scaling value of the y-axis. Defaults to **1** for the identity matrix. |
| m12 | number | Yes | The seventh value, which is affected by the rotation of the x, y, and z axes. |
| m13 | number | Yes | Meaningless. |
| m20 | number | Yes | The ninth value, which is affected by the rotation of the x, y, and z axes. |
| m21 | number | Yes | The tenth value, which is affected by the rotation of the x, y, and z axes. |
| m22 | number | Yes | Scaling value of the z-axis. Defaults to **1** for the identity matrix. |
| m23 | number | Yes | Meaningless. |
| m30 | number | Yes | Translation value of the x-axis, in px. Defaults to **0** for the identity matrix.|
| m31 | number | Yes | Translation value of the y-axis, in px. Defaults to **0** for the identity matrix.|
| m32 | number | Yes | Translation value of the z-axis, in px. Defaults to **0** for the identity matrix.|
| m33 | number | Yes | Valid in homogeneous coordinates, presenting the perspective projection effect. |
| Name | Type | Mandatory | Description |
| ---- | ------ | --------- | ---------------------------------------- |
| m00 | number | Yes | Scaling value of the x-axis. Defaults to **1** for the identity matrix. |
| m01 | number | Yes | The second value, which is affected by the rotation of the x, y, and z axes. |
| m02 | number | Yes | The third value, which is affected by the rotation of the x, y, and z axes. |
| m03 | number | Yes | Meaningless. |
| m10 | number | Yes | The fifth value, which is affected by the rotation of the x, y, and z axes. |
| m11 | number | Yes | Scaling value of the y-axis. Defaults to **1** for the identity matrix. |
| m12 | number | Yes | The seventh value, which is affected by the rotation of the x, y, and z axes. |
| m13 | number | Yes | Meaningless. |
| m20 | number | Yes | The ninth value, which is affected by the rotation of the x, y, and z axes. |
| m21 | number | Yes | The tenth value, which is affected by the rotation of the x, y, and z axes. |
| m22 | number | Yes | Scaling value of the z-axis. Defaults to **1** for the identity matrix. |
| m23 | number | Yes | Meaningless. |
| m30 | number | Yes | Translation value of the x-axis, in px. Defaults to **0** for the identity matrix. |
| m31 | number | Yes | Translation value of the y-axis, in px. Defaults to **0** for the identity matrix. |
| m32 | number | Yes | Translation value of the z-axis, in px. Defaults to **0** for the identity matrix. |
| m33 | number | Yes | Valid in homogeneous coordinates, presenting the perspective projection effect. |
**Example**
......@@ -87,9 +87,9 @@ Matrix initialization function. Can return an identity matrix object.
**Return value**
| Type | Description |
| -------------- | -------------- |
| Matrix4Transit | Identity matrix object.|
| Type | Description |
| -------------- | ----------------------- |
| Matrix4Transit | Identity matrix object. |
**Example**
......@@ -130,9 +130,9 @@ Matrix copy function, which is used to copy the current matrix object.
**Return value**
| Type | Description |
| -------------- | -------------------- |
| Matrix4Transit | Copy object of the current matrix.|
| Type | Description |
| -------------- | ---------------------------------- |
| Matrix4Transit | Copy object of the current matrix. |
**Example**
......@@ -176,15 +176,15 @@ Matrix overlay function, which is used to overlay the effects of two matrices to
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------ |
| matrix | Matrix4 | Yes | Matrix object to be overlaid.|
| Name | Type | Mandatory | Description |
| ------ | ------- | --------- | ----------------------------- |
| matrix | Matrix4 | Yes | Matrix object to be overlaid. |
**Return value**
| Type | Description |
| -------------- | ------------------ |
| Matrix4Transit | Object after matrix overlay.|
| Type | Description |
| -------------- | ---------------------------- |
| Matrix4Transit | Object after matrix overlay. |
**Example**
......@@ -227,9 +227,9 @@ Matrix inverse function. Can return an inverse matrix of the current matrix obje
**Return value**
| Type | Description |
| -------------- | ---------------------- |
| Matrix4Transit | Inverse matrix object of the current matrix.|
| Type | Description |
| -------------- | ---------------------------------------- |
| Matrix4Transit | Inverse matrix object of the current matrix. |
**Example**
......@@ -268,17 +268,17 @@ Matrix translation function, which is used to add the translation effect to the
**Parameter**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------- |
| x | number | No | Translation distance of the x-axis, in px.<br>Default value: **0**|
| y | number | No | Translation distance of the y-axis, in px.<br>Default value: **0**|
| z | number | No | Translation distance of the z-axis, in px.<br>Default value: **0**|
| Name | Type | Mandatory | Description |
| ---- | ------ | --------- | ---------------------------------------- |
| x | number | No | Translation distance of the x-axis, in px.<br>Default value: **0** |
| y | number | No | Translation distance of the y-axis, in px.<br>Default value: **0** |
| z | number | No | Translation distance of the z-axis, in px.<br>Default value: **0** |
**Return value**
| Type | Description |
| -------------- | ---------------------------- |
| Matrix4Transit | Matrix object after the translation effect is added.|
| Type | Description |
| -------------- | ---------------------------------------- |
| Matrix4Transit | Matrix object after the translation effect is added. |
**Example**
......@@ -312,19 +312,19 @@ Matrix scaling function, which is used to add the scaling effect to the x, y, an
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | --------------------------------- |
| x | number | No | Scaling multiple of the x-axis.<br>Default value: **1** |
| y | number | No | Scaling multiple of the y-axis.<br>Default value: **1** |
| z | number | No | Scaling multiple of the z-axis.<br>Default value: **1** |
| centerX | number | No | X coordinate of the center point.<br>Default value: **0**|
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0**|
| Name | Type | Mandatory | Description |
| ------- | ------ | --------- | ---------------------------------------- |
| x | number | No | Scaling multiple of the x-axis.<br>Default value: **1** |
| y | number | No | Scaling multiple of the y-axis.<br>Default value: **1** |
| z | number | No | Scaling multiple of the z-axis.<br>Default value: **1** |
| centerX | number | No | X coordinate of the center point.<br>Default value: **0** |
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0** |
**Return value**
| Type | Description |
| -------------- | ---------------------------- |
| Matrix4Transit | Matrix object after the scaling effect is added.|
| Type | Description |
| -------------- | ---------------------------------------- |
| Matrix4Transit | Matrix object after the scaling effect is added. |
**Example**
......@@ -346,7 +346,7 @@ struct Test {
}
```
![zh-cn_image_0000001219864131](figures/zh-cn_image_0000001219864131.png)
![en-us_image_0000001174422898.png](figures/en-us_image_0000001174422898.png)
### rotate
......@@ -358,20 +358,20 @@ Matrix rotation function, which is used to add the rotation effect to the x, y,
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | --------------------------------- |
| x | number | No | X coordinate of the rotation axis vector.<br>Default value: **1** |
| y | number | No | Y coordinate of the rotation axis vector.<br>Default value: **1** |
| z | number | No | Z coordinate of the rotation axis vector.<br>Default value: **1** |
| angle | number | No | Rotation angle.<br>Default value: **0** |
| centerX | number | No | X coordinate of the center point.<br>Default value: **0**|
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0**|
| Name | Type | Mandatory | Description |
| ------- | ------ | --------- | ---------------------------------------- |
| x | number | No | X coordinate of the rotation axis vector.<br>Default value: **1** |
| y | number | No | Y coordinate of the rotation axis vector.<br>Default value: **1** |
| z | number | No | Z coordinate of the rotation axis vector.<br>Default value: **1** |
| angle | number | No | Rotation angle.<br>Default value: **0** |
| centerX | number | No | X coordinate of the center point.<br>Default value: **0** |
| centerY | number | No | Y coordinate of the center point.<br>Default value: **0** |
**Return value**
| Type | Description |
| -------------- | ---------------------------- |
| Matrix4Transit | Matrix object after the rotation effect is added.|
| Type | Description |
| -------------- | ---------------------------------------- |
| Matrix4Transit | Matrix object after the rotation effect is added. |
**Example**
......@@ -405,15 +405,15 @@ Matrix point transformation function, which is used to apply the current transfo
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----- | ---- | ------------------ |
| point | Point | Yes | Point to be transformed.|
| Name | Type | Mandatory | Description |
| ----- | ----- | --------- | ------------------------ |
| point | Point | Yes | Point to be transformed. |
**Return value**
| Type | Description |
| ----- | ---------------- |
| Point | Point object after matrix transformation|
| Type | Description |
| ----- | ---------------------------------------- |
| Point | Point object after matrix transformation |
**Example**
......
......@@ -18,21 +18,21 @@ show(options?: TextPickerDialogOptions)
Shows a text picker in the given settings.
- TextPickerDialogOptions
| Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- |
| range | string[] \| [Resource](../../ui/ts-types.md#resource)| Yes| - | Data selection range of the picker.|
| selected | number | No| 0 | Index of the selected item in the range.|
| value | string | No | - | Value of the selected item. This parameter does not take effect when the **selected** parameter is set. If the value is not within the range, the first item in the range is used instead.|
| defaultPickerItemHeight | number \| string | No| - | Default height of an item in the picker.|
| onAccept | (value: TextPickerResult) => void | No| - | Callback invoked when the OK button in the dialog box is clicked.|
| onCancel | () => void | No| - | Callback invoked when the Cancel button in the dialog box is clicked.|
| onChange | (value: TextPickerResult) => void | No| - | Callback invoked when the selected item in the picker changes.|
| Name | Type | Mandatory | Default Value | Description |
| ----------------------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- |
| range | string[] \| [Resource](ts-types.md#resource) | Yes | - | Data selection range of the picker. |
| selected | number | No | 0 | Index of the selected item in the range. |
| value | string | No | - | Value of the selected item. This parameter does not take effect when the **selected** parameter is set. If the value is not within the range, the first item in the range is used instead. |
| defaultPickerItemHeight | number \| string | No | - | Default height of an item in the picker. |
| onAccept | (value: TextPickerResult) => void | No | - | Callback invoked when the OK button in the dialog box is clicked. |
| onCancel | () => void | No | - | Callback invoked when the Cancel button in the dialog box is clicked. |
| onChange | (value: TextPickerResult) => void | No | - | Callback invoked when the selected item in the picker changes. |
- TextPickerResult
| Name| Type| Description|
| -------- | -------- | -------- |
| value | string | Value of the selected item.|
| index | number | Index of the selected item in the range.|
| Name | Type | Description |
| ----- | ------ | ---------------------------------------- |
| value | string | Value of the selected item. |
| index | number | Index of the selected item in the range. |
## Example
......
......@@ -14,35 +14,35 @@ OffscreenCanvasRenderingContext2D(width: number, height: number, setting: Render
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------- | ---------------------------------------- | ---- | ---- | ------------------------------ |
| width | number | Yes | - | Width of the offscreen canvas. |
| height | number | Yes | - | Height of the offscreen canvas. |
| setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | Yes | - | See RenderingContextSettings.|
| Name | Type | Mandatory | Default Value | Description |
| ------- | ---------------------------------------- | --------- | ------------- | ------------------------------- |
| width | number | Yes | - | Width of the offscreen canvas. |
| height | number | Yes | - | Height of the offscreen canvas. |
| setting | [RenderingContextSettings](ts-canvasrenderingcontext2d.md#renderingcontextsettings) | Yes | - | See RenderingContextSettings. |
## Attributes
| Name | Type | Description |
| ----------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| [fillStyle](#fillstyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | Style to fill an area.<br>- When the type is **\<color>**, this parameter indicates the color of the filling area.<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API. |
| [lineWidth](#linewidth) | number | Line width. |
| [strokeStyle](#strokestyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | Stroke style.<br>- When the type is **\<color>**, this parameter indicates the stroke color.<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API. |
| [lineCap](#linecap) | CanvasLineCap | Style of the line endpoints. The options are as follows:<br>- **butt**: The endpoints of the line are squared off.<br>- **round**: The endpoints of the line are rounded.<br>- **square**: The endpoints of the line are squared off, and each endpoint has added a rectangle whose length is the same as the line thickness and whose width is half of the line thickness.<br>- Default value: **'butt'** |
| [lineJoin](#linejoin) | CanvasLineJoin | Style of the shape used to join line segments. The options are as follows:<br>- **round**: The intersection is a sector, whose radius at the rounded corner is equal to the line width.<br>- **bevel**: The intersection is a triangle. The rectangular corner of each line is independent.<br>- **miter**: The intersection has a miter corner by extending the outside edges of the lines until they meet. You can view the effect of this attribute in **miterLimit**.<br>- Default value: **'miter'** |
| [miterLimit](#miterlimit) | number | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet.<br>- Default value: **10** |
| [font](#font) | string | Font style.<br>Syntax: ctx.font='font-size font-family'<br>- (Optional) **font-size**: font size and row height. The unit can only be pixels.<br>(Optional) **font-family**: font family.<br>Syntax: ctx.font='font-style font-weight font-size font-family'<br>- (Optional) **font-style**: font style. Available values are **normal** and **italic**.<br>- (Optional) **font-weight**: font weight. Available values are as follows: **normal**, **bold**, **bolder**, **lighter**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**.<br>- (Optional) **font-size**: font size and row height. The unit can only be pixels.<br>- (Optional) **font-family**: font family. Available values are **sans-serif**, **serif**, and **monospace**.<br>Default value: **'normal normal 14px sans-serif'** |
| [textAlign](#textalign) | CanvasTextAlign | Text alignment mode. Available values are as follows:<br>- **left**: The text is left-aligned.<br>- **right**: The text is right-aligned.<br>- **center**: The text is center-aligned.<br>- **start**: The text is aligned with the start bound.<br>- **end**: The text is aligned with the end bound.<br>**NOTE**<br>In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**.<br>- Default value: **'left'** |
| [textBaseline](#textbaseline) | CanvasTextBaseline | Horizontal alignment mode of text. Available values are as follows:<br>- **alphabetic**: The text baseline is the normal alphabetic baseline.<br>- **top**: The text baseline is on the top of the text bounding box.<br>- **hanging**: The text baseline is a hanging baseline over the text.<br>- **middle**: The text baseline is in the middle of the text bounding box.<br>**'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.<br>- **bottom**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line.<br>- Default value: **'alphabetic'** |
| [globalAlpha](#globalalpha) | number | Opacity.<br>**0.0**: completely transparent.<br>**1.0**: completely opaque. |
| [lineDashOffset](#linedashoffset) | number | Offset of the dashed line. The precision is float.<br>- Default value: **0.0** |
| [globalCompositeOperation](#globalcompositeoperation) | string | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**.<br>- Default value: **'source-over'** |
| [shadowBlur](#shadowblur) | number | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float.<br>- Default value: **0.0** |
| [shadowColor](#shadowcolor) | string | Shadow color. |
| [shadowOffsetX](#shadowoffsetx) | number | X-axis shadow offset relative to the original object. |
| [shadowOffsetY](#shadowoffsety) | number | Y-axis shadow offset relative to the original object. |
| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite.<br>- Default value: **true** |
| imageSmoothingQuality | string | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**.<br>- Default value: **'low'** |
| Name | Type | Description |
| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- |
| [fillStyle](#fillstyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | Style to fill an area.<br>- When the type is **\<color>**, this parameter indicates the color of the filling area.<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API. |
| [lineWidth](#linewidth) | number | Line width. |
| [strokeStyle](#strokestyle) | string \| [CanvasGradient](ts-components-canvas-canvasgradient.md) \| [CanvasPattern](#canvaspattern) | Stroke style.<br>- When the type is **\<color>**, this parameter indicates the stroke color.<br>- When the type is **CanvasGradient**, this attribute indicates a gradient object, which is created using the **[createLinearGradient](#createlineargradient)** API.<br>- When the type is **CanvasPattern**, this attribute indicates a pattern, which is created using the **[createPattern](#createpattern)** API. |
| [lineCap](#linecap) | CanvasLineCap | Style of the line endpoints. The options are as follows:<br>- **butt**: The endpoints of the line are squared off.<br>- **round**: The endpoints of the line are rounded.<br>- **square**: The endpoints of the line are squared off, and each endpoint has added a rectangle whose length is the same as the line thickness and whose width is half of the line thickness.<br>- Default value: **'butt'** |
| [lineJoin](#linejoin) | CanvasLineJoin | Style of the shape used to join line segments. The options are as follows:<br>- **round**: The intersection is a sector, whose radius at the rounded corner is equal to the line width.<br>- **bevel**: The intersection is a triangle. The rectangular corner of each line is independent.<br>- **miter**: The intersection has a miter corner by extending the outside edges of the lines until they meet. You can view the effect of this attribute in **miterLimit**.<br>- Default value: **'miter'** |
| [miterLimit](#miterlimit) | number | Maximum miter length. The miter length is the distance between the inner corner and the outer corner where two lines meet.<br>- Default value: **10** |
| [font](#font) | string | Font style.<br>Syntax: ctx.font='font-size font-family'<br>- (Optional) **font-size**: font size and row height. The unit can only be pixels.<br>(Optional) **font-family**: font family.<br>Syntax: ctx.font='font-style font-weight font-size font-family'<br>- (Optional) **font-style**: font style. Available values are **normal** and **italic**.<br>- (Optional) **font-weight**: font weight. Available values are as follows: **normal**, **bold**, **bolder**, **lighter**, **100**, **200**, **300**, **400**, **500**, **600**, **700**, **800**, **900**.<br>- (Optional) **font-size**: font size and row height. The unit can only be pixels.<br>- (Optional) **font-family**: font family. Available values are **sans-serif**, **serif**, and **monospace**.<br>Default value: **'normal normal 14px sans-serif'** |
| [textAlign](#textalign) | CanvasTextAlign | Text alignment mode. Available values are as follows:<br>- **left**: The text is left-aligned.<br>- **right**: The text is right-aligned.<br>- **center**: The text is center-aligned.<br>- **start**: The text is aligned with the start bound.<br>- **end**: The text is aligned with the end bound.<br>**NOTE**<br>In the **ltr** layout mode, the value **'start'** equals **'left'**. In the **rtl** layout mode, the value **'start'** equals **'right'**.<br>- Default value: **'left'** |
| [textBaseline](#textbaseline) | CanvasTextBaseline | Horizontal alignment mode of text. Available values are as follows:<br>- **alphabetic**: The text baseline is the normal alphabetic baseline.<br>- **top**: The text baseline is on the top of the text bounding box.<br>- **hanging**: The text baseline is a hanging baseline over the text.<br>- **middle**: The text baseline is in the middle of the text bounding box.<br>**'ideographic'**: The text baseline is the ideographic baseline. If a character exceeds the alphabetic baseline, the ideographic baseline is located at the bottom of the excess character.<br>- **bottom**: The text baseline is at the bottom of the text bounding box. Its difference from the ideographic baseline is that the ideographic baseline does not consider letters in the next line.<br>- Default value: **'alphabetic'** |
| [globalAlpha](#globalalpha) | number | Opacity.<br>**0.0**: completely transparent.<br>**1.0**: completely opaque. |
| [lineDashOffset](#linedashoffset) | number | Offset of the dashed line. The precision is float.<br>- Default value: **0.0** |
| [globalCompositeOperation](#globalcompositeoperation) | string | Composition operation type. Available values are as follows: **'source-over'**, **'source-atop'**, **'source-in'**, **'source-out'**, **'destination-over'**, **'destination-atop'**, **'destination-in'**, **'destination-out'**, **'lighter'**, **'copy'**, and **'xor'**.<br>- Default value: **'source-over'** |
| [shadowBlur](#shadowblur) | number | Blur level during shadow drawing. A larger value indicates a more blurred effect. The precision is float.<br>- Default value: **0.0** |
| [shadowColor](#shadowcolor) | string | Shadow color. |
| [shadowOffsetX](#shadowoffsetx) | number | X-axis shadow offset relative to the original object. |
| [shadowOffsetY](#shadowoffsety) | number | Y-axis shadow offset relative to the original object. |
| [imageSmoothingEnabled](#imagesmoothingenabled) | boolean | Whether to adjust the image smoothness during image drawing. The value **true** means to enable this feature, and **false** means the opposite.<br>- Default value: **true** |
| imageSmoothingQuality | string | Image smoothness. The value can be **'low'**, **'medium'**, or **'high'**.<br>- Default value: **'low'** |
> **NOTE**
>
......@@ -464,19 +464,19 @@ struct LineDashOffset {
### globalCompositeOperation
| Name | Description |
| ---------------- | ------------------------ |
| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. |
| source-atop | Displays the new drawing on the top of the existing drawing. |
| source-in | Displays the new drawing inside the existing drawing. |
| source-out | Displays part of the new drawing that is outside of the existing drawing. |
| destination-over | Displays the existing drawing above the new drawing. |
| destination-atop | Displays the existing drawing on the top of the new drawing. |
| destination-in | Displays the existing drawing inside the new drawing. |
| destination-out | Displays the existing drawing outside the new drawing. |
| lighter | Displays both the new and existing drawing. |
| copy | Displays the new drawing and neglects the existing drawing. |
| xor | Combines the new drawing and existing drawing using the XOR operation.|
| Name | Description |
| ---------------- | ---------------------------------------- |
| source-over | Displays the new drawing above the existing drawing. This attribute is used by default. |
| source-atop | Displays the new drawing on the top of the existing drawing. |
| source-in | Displays the new drawing inside the existing drawing. |
| source-out | Displays part of the new drawing that is outside of the existing drawing. |
| destination-over | Displays the existing drawing above the new drawing. |
| destination-atop | Displays the existing drawing on the top of the new drawing. |
| destination-in | Displays the existing drawing inside the new drawing. |
| destination-out | Displays the existing drawing outside the new drawing. |
| lighter | Displays both the new and existing drawing. |
| copy | Displays the new drawing and neglects the existing drawing. |
| xor | Combines the new drawing and existing drawing using the XOR operation. |
```ts
// xxx.ets
......@@ -705,12 +705,12 @@ Fills a rectangle on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.|
| width | number | Yes | 0 | Width of the rectangle. |
| height | number | Yes | 0 | Height of the rectangle. |
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | --------- | ------------- | ---------------------------------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. |
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. |
| width | number | Yes | 0 | Width of the rectangle. |
| height | number | Yes | 0 | Height of the rectangle. |
**Example**
......@@ -752,12 +752,12 @@ Draws an outlined rectangle on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ------------ |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.|
| width | number | Yes | 0 | Width of the rectangle. |
| height | number | Yes | 0 | Height of the rectangle. |
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | --------- | ------------- | ---------------------------------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. |
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. |
| width | number | Yes | 0 | Width of the rectangle. |
| height | number | Yes | 0 | Height of the rectangle. |
**Example**
......@@ -798,12 +798,12 @@ Clears the content in a rectangle on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.|
| width | number | Yes | 0 | Width of the rectangle. |
| height | number | Yes | 0 | Height of the rectangle. |
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | --------- | ------------- | ---------------------------------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. |
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. |
| width | number | Yes | 0 | Width of the rectangle. |
| height | number | Yes | 0 | Height of the rectangle. |
**Example**
......@@ -846,12 +846,12 @@ Draws filled text on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------------- |
| text | string | Yes | "" | Text to draw. |
| x | number | Yes | 0 | X-coordinate of the lower left corner of the text.|
| y | number | Yes | 0 | Y-coordinate of the lower left corner of the text.|
| maxWidth | number | No | - | Maximum width allowed for the text.|
| Name | Type | Mandatory | Default Value | Description |
| -------- | ------ | --------- | ------------- | ---------------------------------------- |
| text | string | Yes | "" | Text to draw. |
| x | number | Yes | 0 | X-coordinate of the lower left corner of the text. |
| y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. |
| maxWidth | number | No | - | Maximum width allowed for the text. |
**Example**
......@@ -893,12 +893,12 @@ Draws a text stroke on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------------- |
| text | string | Yes | "" | Text to draw. |
| x | number | Yes | 0 | X-coordinate of the lower left corner of the text.|
| y | number | Yes | 0 | Y-coordinate of the lower left corner of the text.|
| maxWidth | number | No | - | Maximum width of the text to be drawn.|
| Name | Type | Mandatory | Default Value | Description |
| -------- | ------ | --------- | ------------- | ---------------------------------------- |
| text | string | Yes | "" | Text to draw. |
| x | number | Yes | 0 | X-coordinate of the lower left corner of the text. |
| y | number | Yes | 0 | Y-coordinate of the lower left corner of the text. |
| maxWidth | number | No | - | Maximum width of the text to be drawn. |
**Example**
......@@ -940,33 +940,33 @@ Returns a **TextMetrics** object used to obtain the width of specified text.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ---------- |
| text | string | Yes | "" | Text to be measured.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | -------------------- |
| text | string | Yes | "" | Text to be measured. |
**Return value**
| Type | Description |
| ----------- | ------- |
| TextMetrics | **TextMetrics** object.|
| Type | Description |
| ----------- | ----------------------- |
| TextMetrics | **TextMetrics** object. |
**TextMetrics**
| Name | Type | Description |
| ----- | ------ | ------- |
| width | number | Width of the text.|
| height | number | Height of the text.|
| actualBoundingBoxAscent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the top of the bounding rectangle used to render the text. The current value is **0**.|
| actualBoundingBoxDescent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the bottom of the bounding rectangle used to render the text. The current value is **0**.|
| actualBoundingBoxLeft | number | Distance parallel to the baseline from the alignment point determined by the **CanvasRenderingContext2D.textAlign** attribute to the left side of the bounding rectangle of the text. The current value is **0**.|
| actualBoundingBoxRight | number | Distance parallel to the baseline from the alignment point determined by the **CanvasRenderingContext2D.textAlign** attribute to the right side of the bounding rectangle of the text. The current value is **0**.|
| alphabeticBaseline | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the alphabetic baseline of the line box. The current value is **0**.|
| emHeightAscent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the top of the em square in the line box. The current value is **0**.|
| emHeightDescent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the bottom of the em square in the line box. The current value is **0**.|
| fontBoundingBoxAscent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the top of the highest bounding rectangle of all the fonts used to render the text. The current value is **0**.|
| fontBoundingBoxDescent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the bottom of the bounding rectangle of all the fonts used to render the text. The current value is **0**.|
| hangingBaseline | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the hanging baseline of the line box. The current value is **0**.|
| ideographicBaseline | number | Distance from the horizontal line indicated by the **CanvasRenderingContext2D.textBaseline** attribute to the ideographic baseline of the line box. The current value is **0**.|
| Name | Type | Description |
| ------------------------ | ------ | ---------------------------------------- |
| width | number | Width of the text. |
| height | number | Height of the text. |
| actualBoundingBoxAscent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the top of the bounding rectangle used to render the text. The current value is **0**. |
| actualBoundingBoxDescent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the bottom of the bounding rectangle used to render the text. The current value is **0**. |
| actualBoundingBoxLeft | number | Distance parallel to the baseline from the alignment point determined by the **CanvasRenderingContext2D.textAlign** attribute to the left side of the bounding rectangle of the text. The current value is **0**. |
| actualBoundingBoxRight | number | Distance parallel to the baseline from the alignment point determined by the **CanvasRenderingContext2D.textAlign** attribute to the right side of the bounding rectangle of the text. The current value is **0**. |
| alphabeticBaseline | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the alphabetic baseline of the line box. The current value is **0**. |
| emHeightAscent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the top of the em square in the line box. The current value is **0**. |
| emHeightDescent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the bottom of the em square in the line box. The current value is **0**. |
| fontBoundingBoxAscent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the top of the highest bounding rectangle of all the fonts used to render the text. The current value is **0**. |
| fontBoundingBoxDescent | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the bottom of the bounding rectangle of all the fonts used to render the text. The current value is **0**. |
| hangingBaseline | number | Distance from the horizontal line specified by the **CanvasRenderingContext2D.textBaseline** attribute to the hanging baseline of the line box. The current value is **0**. |
| ideographicBaseline | number | Distance from the horizontal line indicated by the **CanvasRenderingContext2D.textBaseline** attribute to the ideographic baseline of the line box. The current value is **0**. |
**Example**
......@@ -1009,9 +1009,9 @@ Strokes a path.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ---------------------------------------- | ---- | ---- | ------------ |
| path | [Path2D](ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ---------------------------------------- | --------- | ------------- | -------------------------- |
| path | [Path2D](ts-components-canvas-path2d.md) | No | null | A **Path2D** path to draw. |
**Example**
......@@ -1097,10 +1097,10 @@ Moves a drawing path to a target position on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------- |
| x | number | Yes | 0 | X-coordinate of the target position.|
| y | number | Yes | 0 | Y-coordinate of the target position.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ------------------------------------ |
| x | number | Yes | 0 | X-coordinate of the target position. |
| y | number | Yes | 0 | Y-coordinate of the target position. |
**Example**
......@@ -1144,10 +1144,10 @@ Connects the current point to a target position using a straight line.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------- |
| x | number | Yes | 0 | X-coordinate of the target position.|
| y | number | Yes | 0 | Y-coordinate of the target position.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ------------------------------------ |
| x | number | Yes | 0 | X-coordinate of the target position. |
| y | number | Yes | 0 | Y-coordinate of the target position. |
**Example**
......@@ -1233,16 +1233,16 @@ Creates a pattern for image filling based on a specified source image and repeti
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---------- | ---------------------------------------- | ---- | ---- | ---------------------------------------- |
| image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Source image. For details, see **ImageBitmap**. |
| repetition | string | Yes | "" | Repetition mode. The value can be **"repeat"**, **"repeat-x"**, **"repeat-y"**, or **"no-repeat"**.|
| Name | Type | Mandatory | Default Value | Description |
| ---------- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- |
| image | [ImageBitmap](ts-components-canvas-imagebitmap.md) | Yes | null | Source image. For details, see **ImageBitmap**. |
| repetition | string | Yes | "" | Repetition mode. The value can be **"repeat"**, **"repeat-x"**, **"repeat-y"**, or **"no-repeat"**. |
**Return value**
| Type | Description |
| ---------- | ---------------------------------------- |
| [CanvasPattern](#canvaspattern) | Created pattern for image filling based on a specified source image and repetition mode.|
| Type | Description |
| ------------------------------- | ---------------------------------------- |
| [CanvasPattern](#canvaspattern) | Created pattern for image filling based on a specified source image and repetition mode. |
**Example**
......@@ -1286,14 +1286,14 @@ Draws a cubic bezier curve on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | -------------- |
| cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve.|
| cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve.|
| cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve.|
| cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve.|
| x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. |
| y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. |
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ---------------------------------------- |
| cp1x | number | Yes | 0 | X-coordinate of the first parameter of the bezier curve. |
| cp1y | number | Yes | 0 | Y-coordinate of the first parameter of the bezier curve. |
| cp2x | number | Yes | 0 | X-coordinate of the second parameter of the bezier curve. |
| cp2y | number | Yes | 0 | Y-coordinate of the second parameter of the bezier curve. |
| x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. |
| y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. |
**Example**
......@@ -1337,12 +1337,12 @@ Draws a quadratic curve on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ----------- |
| cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter.|
| cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter.|
| x | number | Yes | 0 | X-coordinate of the end point on the bezier curve.|
| y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ---------------------------------------- |
| cpx | number | Yes | 0 | X-coordinate of the bezier curve parameter. |
| cpy | number | Yes | 0 | Y-coordinate of the bezier curve parameter. |
| x | number | Yes | 0 | X-coordinate of the end point on the bezier curve. |
| y | number | Yes | 0 | Y-coordinate of the end point on the bezier curve. |
**Example**
......@@ -1386,14 +1386,14 @@ Draws an arc on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------------- | ------- | ---- | ----- | ---------- |
| x | number | Yes | 0 | X-coordinate of the center point of the arc.|
| y | number | Yes | 0 | Y-coordinate of the center point of the arc.|
| radius | number | Yes | 0 | Radius of the arc. |
| startAngle | number | Yes | 0 | Start radian of the arc. |
| endAngle | number | Yes | 0 | End radian of the arc. |
| counterclockwise | boolean | No | false | Whether to draw the arc counterclockwise.|
| Name | Type | Mandatory | Default Value | Description |
| ---------------- | ------- | --------- | ------------- | ---------------------------------------- |
| x | number | Yes | 0 | X-coordinate of the center point of the arc. |
| y | number | Yes | 0 | Y-coordinate of the center point of the arc. |
| radius | number | Yes | 0 | Radius of the arc. |
| startAngle | number | Yes | 0 | Start radian of the arc. |
| endAngle | number | Yes | 0 | End radian of the arc. |
| counterclockwise | boolean | No | false | Whether to draw the arc counterclockwise. |
**Example**
......@@ -1436,13 +1436,13 @@ Draws an arc based on the radius and points on the arc.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | --------------- |
| x1 | number | Yes | 0 | X-coordinate of the first point on the arc.|
| y1 | number | Yes | 0 | Y-coordinate of the first point on the arc.|
| x2 | number | Yes | 0 | X-coordinate of the second point on the arc.|
| y2 | number | Yes | 0 | Y-coordinate of the second point on the arc.|
| radius | number | Yes | 0 | Radius of the arc. |
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | --------- | ------------- | ---------------------------------------- |
| x1 | number | Yes | 0 | X-coordinate of the first point on the arc. |
| y1 | number | Yes | 0 | Y-coordinate of the first point on the arc. |
| x2 | number | Yes | 0 | X-coordinate of the second point on the arc. |
| y2 | number | Yes | 0 | Y-coordinate of the second point on the arc. |
| radius | number | Yes | 0 | Radius of the arc. |
**Example**
......@@ -1485,16 +1485,16 @@ Draws an ellipse in the specified rectangular region on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------------- | ------- | ---- | ----- | ----------------- |
| x | number | Yes | 0 | X-coordinate of the ellipse center. |
| y | number | Yes | 0 | Y-coordinate of the ellipse center. |
| radiusX | number | Yes | 0 | Ellipse radius on the x-axis. |
| radiusY | number | Yes | 0 | Ellipse radius on the y-axis. |
| rotation | number | Yes | 0 | Rotation angle of the ellipse. The unit is radian. |
| startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse. The unit is radian.|
| endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse. The unit is radian.|
| counterclockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. |
| Name | Type | Mandatory | Default Value | Description |
| ---------------- | ------- | --------- | ------------- | ---------------------------------------- |
| x | number | Yes | 0 | X-coordinate of the ellipse center. |
| y | number | Yes | 0 | Y-coordinate of the ellipse center. |
| radiusX | number | Yes | 0 | Ellipse radius on the x-axis. |
| radiusY | number | Yes | 0 | Ellipse radius on the y-axis. |
| rotation | number | Yes | 0 | Rotation angle of the ellipse. The unit is radian. |
| startAngle | number | Yes | 0 | Angle of the start point for drawing the ellipse. The unit is radian. |
| endAngle | number | Yes | 0 | Angle of the end point for drawing the ellipse. The unit is radian. |
| counterclockwise | boolean | No | false | Whether to draw the ellipse in the counterclockwise direction. |
**Example**
......@@ -1537,12 +1537,12 @@ Creates a rectangle on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle.|
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle.|
| w | number | Yes | 0 | Width of the rectangle. |
| h | number | Yes | 0 | Height of the rectangle. |
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ---------------------------------------- |
| x | number | Yes | 0 | X-coordinate of the upper left corner of the rectangle. |
| y | number | Yes | 0 | Y-coordinate of the upper left corner of the rectangle. |
| w | number | Yes | 0 | Width of the rectangle. |
| h | number | Yes | 0 | Height of the rectangle. |
**Example**
......@@ -1663,9 +1663,9 @@ Rotates a canvas clockwise around its coordinate axes.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ---------------------------------------- |
| angle | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian.|
| Name | Type | Mandatory | Default Value | Description |
| ----- | ------ | --------- | ------------- | ---------------------------------------- |
| angle | number | Yes | 0 | Clockwise rotation angle. You can use **Math.PI / 180** to convert the angle to a radian. |
**Example**
......@@ -1707,10 +1707,10 @@ Scales the canvas based on scale factors.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ----------- |
| x | number | Yes | 0 | Horizontal scale factor.|
| y | number | Yes | 0 | Vertical scale factor.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ------------------------ |
| x | number | Yes | 0 | Horizontal scale factor. |
| y | number | Yes | 0 | Vertical scale factor. |
**Example**
......@@ -1761,14 +1761,14 @@ Defines a transformation matrix. To transform a graph, you only need to set para
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---------- | ------ | ---- | ---- | -------- |
| a | number | Yes | 0 |X-axis scale.|
| b | number | Yes | 0 |X-axis skew.|
| c | number | Yes | 0 |Y-axis skew.|
| d | number | Yes | 0 |Y-axis scale.|
| e | number | Yes | 0 |X-axis translation.|
| f | number | Yes | 0 |Y-axis translation.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ------------------- |
| a | number | Yes | 0 | X-axis scale. |
| b | number | Yes | 0 | X-axis skew. |
| c | number | Yes | 0 | Y-axis skew. |
| d | number | Yes | 0 | Y-axis scale. |
| e | number | Yes | 0 | X-axis translation. |
| f | number | Yes | 0 | Y-axis translation. |
**Example**
......@@ -1816,14 +1816,14 @@ Resets the existing transformation matrix and creates a new transformation matri
**Parameters**
| Parameters | Type | Mandatory | Default Value | Description |
| ---------- | ------ | ---- | ---- | -------- |
| a | number | Yes | 0 |X-axis scale.|
| b | number | Yes | 0 |X-axis skew.|
| c | number | Yes | 0 |Y-axis skew.|
| d | number | Yes | 0 |Y-axis scale.|
| e | number | Yes | 0 |X-axis translation.|
| f | number | Yes | 0 |Y-axis translation.|
| Parameters | Type | Mandatory | Default Value | Description |
| ---------- | ------ | --------- | ------------- | ------------------- |
| a | number | Yes | 0 | X-axis scale. |
| b | number | Yes | 0 | X-axis skew. |
| c | number | Yes | 0 | Y-axis skew. |
| d | number | Yes | 0 | Y-axis scale. |
| e | number | Yes | 0 | X-axis translation. |
| f | number | Yes | 0 | Y-axis translation. |
**Example**
......@@ -1857,7 +1857,7 @@ Resets the existing transformation matrix and creates a new transformation matri
}
```
![zh-cn_image_0000001193872526](figures/zh-cn_image_0000001193872526.png)
![en-us_image_0000001193872526](figures/en-us_image_0000001193872526.png)
### translate
......@@ -1868,10 +1868,10 @@ Moves the origin of the coordinate system.
**Parameters**
| Parameters | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | -------- |
| x | number | Yes | 0 | X-axis translation.|
| y | number | Yes | 0 | Y-axis translation.|
| Parameters | Type | Mandatory | Default Value | Description |
| ---------- | ------ | --------- | ------------- | ------------------- |
| x | number | Yes | 0 | X-axis translation. |
| y | number | Yes | 0 | Y-axis translation. |
**Example**
......@@ -1918,17 +1918,17 @@ Draws an image on the canvas.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------- | ---------------------------------------- | ---- | ---- | -------------------- |
| image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7)| Yes | null | Image resource. For details, see **ImageBitmap** or **PixelMap**.|
| sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image.|
| sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image.|
| sw | number | No | 0 | Target width to crop the source image. |
| sh | number | No | 0 | Target height to crop the source image. |
| dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. |
| dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas.|
| dw | number | No | 0 | Width of the drawing area. |
| dh | number | No | 0 | Height of the drawing area. |
| Name | Type | Mandatory | Default Value | Description |
| ----- | ---------------------------------------- | --------- | ------------- | ---------------------------------------- |
| image | [ImageBitmap](ts-components-canvas-imagebitmap.md) or [PixelMap](../apis/js-apis-image.md#pixelmap7) | Yes | null | Image resource. For details, see **ImageBitmap** or **PixelMap**. |
| sx | number | No | 0 | X-coordinate of the upper left corner of the rectangle used to crop the source image. |
| sy | number | No | 0 | Y-coordinate of the upper left corner of the rectangle used to crop the source image. |
| sw | number | No | 0 | Target width to crop the source image. |
| sh | number | No | 0 | Target height to crop the source image. |
| dx | number | Yes | 0 | X-coordinate of the upper left corner of the drawing area on the canvas. |
| dy | number | Yes | 0 | Y-coordinate of the upper left corner of the drawing area on the canvas. |
| dw | number | No | 0 | Width of the drawing area. |
| dh | number | No | 0 | Height of the drawing area. |
**Example**
......@@ -1971,10 +1971,10 @@ Creates an **ImageData** object based on the width and height. For details, see
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ------ | ------ | ---- | ---- | ------------- |
| sw | number | Yes | 0 | Width of the **ImageData** object.|
| sh | number | Yes | 0 | Height of the **ImageData** object.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ----------------------------------- |
| sw | number | Yes | 0 | Width of the **ImageData** object. |
| sh | number | Yes | 0 | Height of the **ImageData** object. |
### createImageData
......@@ -1985,15 +1985,15 @@ Creates an **ImageData** object based on the given existing **ImageData** object
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| --------- | ---------------------------------------- | ---- | ---- | ---------------- |
| imagedata | [ImageData](ts-components-canvas-imagebitmap.md) | Yes | null | **ImageData** object to copy.|
| Name | Type | Mandatory | Default Value | Description |
| --------- | ---------------------------------------- | --------- | ------------- | ----------------------------- |
| imagedata | [ImageData](ts-components-canvas-imagebitmap.md) | Yes | null | **ImageData** object to copy. |
**Return value**
| Type | Description |
| ---------- | ---------------------------------------- |
| [ImageData](ts-components-canvas-imagebitmap.md) | New **ImageData** object.|
| Type | Description |
| ---------------------------------------- | ------------------------- |
| [ImageData](ts-components-canvas-imagebitmap.md) | New **ImageData** object. |
### getPixelMap
......@@ -2003,18 +2003,18 @@ Obtains the **[PixelMap](../apis/js-apis-image.md#pixelmap7)** object created wi
**Parameters**
| Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- |
| sx | number | Yes| 0 | X-coordinate of the upper left corner of the output area.|
| sy | number | Yes| 0 | Y-coordinate of the upper left corner of the output area.|
| sw | number | Yes| 0 | Width of the output area.|
| sh | number | Yes| 0 | Height of the output area.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ---------------------------------------- |
| sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. |
| sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. |
| sw | number | Yes | 0 | Width of the output area. |
| sh | number | Yes | 0 | Height of the output area. |
**Return value**
| Type | Description |
| ---------- | ---------------------------------------- |
| [PixelMap](../apis/js-apis-image.md#pixelmap7) | **PixelMap** object.|
| Type | Description |
| ---------------------------------------- | -------------------- |
| [PixelMap](../apis/js-apis-image.md#pixelmap7) | **PixelMap** object. |
### getImageData
......@@ -2025,18 +2025,18 @@ Obtains the **[ImageData](ts-components-canvas-imagebitmap.md)** object created
**Parameters**
| Parameters | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | --------------- |
| sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area.|
| sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area.|
| sw | number | Yes | 0 | Width of the output area. |
| sh | number | Yes | 0 | Height of the output area. |
| Parameters | Type | Mandatory | Default Value | Description |
| ---------- | ------ | --------- | ------------- | ---------------------------------------- |
| sx | number | Yes | 0 | X-coordinate of the upper left corner of the output area. |
| sy | number | Yes | 0 | Y-coordinate of the upper left corner of the output area. |
| sw | number | Yes | 0 | Width of the output area. |
| sh | number | Yes | 0 | Height of the output area. |
**Return value**
| Type | Description |
| ---------- | ---------------------------------------- |
| [ImageData](ts-components-canvas-imagebitmap.md) | New **ImageData** object.|
| Type | Description |
| ---------------------------------------- | ------------------------- |
| [ImageData](ts-components-canvas-imagebitmap.md) | New **ImageData** object. |
### putImageData
......@@ -2049,15 +2049,15 @@ Puts the [ImageData](ts-components-canvas-imagebitmap.md) onto a rectangular are
**Parameters**
| Parameters | Type | Mandatory | Default Value | Description |
| ----------- | ------ | ---- | ------------ | ----------------------------- |
| imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. |
| dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. |
| dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. |
| dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image.|
| dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image.|
| dirtyWidth | number | No | Width of the **ImageData** object| Width of the rectangular area to crop the source image. |
| dirtyHeight | number | No | Height of the **ImageData** object| Height of the rectangular area to crop the source image. |
| Parameters | Type | Mandatory | Default Value | Description |
| ----------- | ------ | --------- | ---------------------------------- | ---------------------------------------- |
| imagedata | Object | Yes | null | **ImageData** object with pixels to put onto the canvas. |
| dx | number | Yes | 0 | X-axis offset of the rectangular area on the canvas. |
| dy | number | Yes | 0 | Y-axis offset of the rectangular area on the canvas. |
| dirtyX | number | No | 0 | X-axis offset of the upper left corner of the rectangular area relative to that of the source image. |
| dirtyY | number | No | 0 | Y-axis offset of the upper left corner of the rectangular area relative to that of the source image. |
| dirtyWidth | number | No | Width of the **ImageData** object | Width of the rectangular area to crop the source image. |
| dirtyHeight | number | No | Height of the **ImageData** object | Height of the rectangular area to crop the source image. |
**Example**
......@@ -2104,9 +2104,9 @@ Sets the dash line style.
**Parameters**
| Parameter | Type | Description |
| -------- | ----- | -------------------- |
| segments | number[] | An array of numbers that specify distances to alternately draw a line and a gap.|
| Parameter | Type | Description |
| --------- | -------- | ---------------------------------------- |
| segments | number[] | An array of numbers that specify distances to alternately draw a line and a gap. |
**Example**
......@@ -2137,7 +2137,7 @@ struct SetLineDash {
}
}
```
![zh-cn_image_000000127777772](figures/zh-cn_image_000000127777772.png)
![en-us_image_000000127777772](figures/en-us_image_000000127777772.png)
### getLineDash
......@@ -2148,9 +2148,9 @@ Obtains the dash line style.
**Return value**
| Type | Description |
| ----- | ------------------------ |
| number[] | An array describing the interval of alternate line segments and length of spacing.|
| Type | Description |
| -------- | ---------------------------------------- |
| number[] | An array describing the interval of alternate line segments and length of spacing. |
**Example**
......@@ -2194,9 +2194,9 @@ Displays the specified **ImageBitmap** object.
**Parameters**
| Parameters | Type | Description |
| ------ | ----------- | ------------------ |
| bitmap | [ImageData](ts-components-canvas-imagebitmap.md) | **ImageBitmap** object to display.|
| Parameters | Type | Description |
| ---------- | ---------------------------------------- | ---------------------------------- |
| bitmap | [ImageData](ts-components-canvas-imagebitmap.md) | **ImageBitmap** object to display. |
**Example**
......@@ -2226,7 +2226,7 @@ Displays the specified **ImageBitmap** object.
}
}
```
![zh-cn_image_000000127777773](figures/zh-cn_image_000000127777773.png)
![en-us_image_000000127777773](figures/en-us_image_000000127777773.png)
### toDataURL
......@@ -2236,16 +2236,16 @@ Generates a URL containing image display information.
**Parameters**
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ---------------------------------------- |
| type | string | No | Image format. The default value is **image/png**. |
| quality | number | No | Image quality, which ranges from 0 to 1, when the image format is **image/jpeg** or **image/webp**. If the set value is beyond the value range, the default value **0.92** is used.|
| Name | Type | Mandatory | Description |
| ------- | ------ | --------- | ---------------------------------------- |
| type | string | No | Image format. The default value is **image/png**. |
| quality | number | No | Image quality, which ranges from 0 to 1, when the image format is **image/jpeg** or **image/webp**. If the set value is beyond the value range, the default value **0.92** is used. |
**Return value**
| Type | Description |
| ------ | --------- |
| string | Image URL.|
| Type | Description |
| ------ | ----------- |
| string | Image URL. |
**Example**
......@@ -2283,9 +2283,9 @@ Creates an **ImageBitmap** object on the most recently rendered image of the **O
**Return value**
| Type | Description |
| ---------------------------------------- | --------------- |
| [ImageData](ts-components-canvas-imagebitmap.md)| Pixel data rendered on the **OffscreenCanvas**.|
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| [ImageData](ts-components-canvas-imagebitmap.md) | Pixel data rendered on the **OffscreenCanvas**. |
**Example**
......@@ -2394,12 +2394,12 @@ Creates a linear gradient.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | -------- |
| x0 | number | Yes | 0 | X-coordinate of the start point.|
| y0 | number | Yes | 0 | Y-coordinate of the start point.|
| x1 | number | Yes | 0 | X-coordinate of the end point.|
| y1 | number | Yes | 0 | Y-coordinate of the end point.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | -------------------------------- |
| x0 | number | Yes | 0 | X-coordinate of the start point. |
| y0 | number | Yes | 0 | Y-coordinate of the start point. |
| x1 | number | Yes | 0 | X-coordinate of the end point. |
| y1 | number | Yes | 0 | Y-coordinate of the end point. |
**Example**
......@@ -2446,14 +2446,14 @@ Creates a linear gradient.
**Parameters**
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | ---- | ---- | ----------------- |
| x0 | number | Yes | 0 | X-coordinate of the center of the start circle. |
| y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. |
| r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number.|
| x1 | number | Yes | 0 | X-coordinate of the center of the end circle. |
| y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. |
| r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number.|
| Name | Type | Mandatory | Default Value | Description |
| ---- | ------ | --------- | ------------- | ---------------------------------------- |
| x0 | number | Yes | 0 | X-coordinate of the center of the start circle. |
| y0 | number | Yes | 0 | Y-coordinate of the center of the start circle. |
| r0 | number | Yes | 0 | Radius of the start circle, which must be a non-negative finite number. |
| x1 | number | Yes | 0 | X-coordinate of the center of the end circle. |
| y1 | number | Yes | 0 | Y-coordinate of the center of the end circle. |
| r1 | number | Yes | 0 | Radius of the end circle, which must be a non-negative finite number. |
**Example**
......
......@@ -4,9 +4,9 @@
> **说明:**
> - 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> - svg父组件或者svg组件需要定义宽高值,否则不进行绘制。
> - 该组件从API version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
>
> - svg父组件或者svg组件需要定义宽高值,否则不进行绘制。
## 权限列表
......@@ -15,21 +15,21 @@
## 子组件
支持[svg](js-components-svg.md)[rect](js-components-svg-rect.md)[circle](js-components-svg-circle.md)[ellipse](../arkui-js/js-components-svg-ellipse.md)[path](js-components-svg-path.md)[line](../arkui-js/js-components-svg-line.md)[polygon](../arkui-js/js-components-svg-polygon.md)[polyline](js-components-svg-polyline.md)[text](js-components-svg-text.md)[animate](js-components-svg-animate.md)[animateTransform](js-components-svg-animateTransform.md)
支持[svg](js-components-svg.md)[rect](js-components-svg-rect.md)[circle](js-components-svg-circle.md)[ellipse](../arkui-js/js-components-svg-ellipse.md)[path](js-components-svg-path.md)[line](../arkui-js/js-components-svg-line.md)[polygon](../arkui-js/js-components-svg-polygon.md)[polyline](js-components-svg-polyline.md)[text](js-components-svg-text.md)[animate](js-components-svg-animate.md)[animateTransform](js-components-svg-animatetransform.md)
## 属性
支持Svg组件[通用属性](../arkui-js/js-components-svg-common-attributes.md)和以下属性,设置的通用属性会传递给子组件。
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| id | string | - | 否 | 组件的唯一标识。 |
| width | &lt;length&gt;\|&lt;percentage&gt; | - | 否 | 设置组件的宽度。 |
| height | &lt;length&gt;\|&lt;percentage&gt; | - | 否 | 设置组件的高度。 |
| x | &lt;length&gt;\|&lt;percentage&gt; | - | 否 | 设置当前svg的x轴坐标,根svg节点无效。 |
| y | &lt;length&gt;\|&lt;percentage&gt; | | 否 | 设置当前svg的y轴坐标,根svg节点无效。 |
| viewBox | string | - | 否 | 设置当前svg的视口。支持的格式为&lt;number&nbsp;number&nbsp;number&nbsp;number&gt;,4个参数分别表示min-x,&nbsp;min-y,&nbsp;width&nbsp;and&nbsp;height,viewBox的宽高和svg的宽高不一致,会以中心对齐进行缩放。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ------- | ---------------------------------- | ---- | ---- | ---------------------------------------- |
| id | string | - | 否 | 组件的唯一标识。 |
| width | &lt;length&gt;\|&lt;percentage&gt; | - | 否 | 设置组件的宽度。 |
| height | &lt;length&gt;\|&lt;percentage&gt; | - | 否 | 设置组件的高度。 |
| x | &lt;length&gt;\|&lt;percentage&gt; | - | 否 | 设置当前svg的x轴坐标,根svg节点无效。 |
| y | &lt;length&gt;\|&lt;percentage&gt; | | 否 | 设置当前svg的y轴坐标,根svg节点无效。 |
| viewBox | string | - | 否 | 设置当前svg的视口。支持的格式为&lt;number&nbsp;number&nbsp;number&nbsp;number&gt;,4个参数分别表示min-x,&nbsp;min-y,&nbsp;width&nbsp;and&nbsp;height,viewBox的宽高和svg的宽高不一致,会以中心对齐进行缩放。 |
## 示例
......
......@@ -26,7 +26,7 @@ Web(options: { src: ResourceStr, controller: WebController })
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ---------- | ------------------------------- | ---- | ------- |
| src | [ResourceStr](ts-types.md) | 是 | 网页资源地址。 |
| src | [ResourceStr](ts-types.md) | 是 | 网页资源地址。 |
| controller | [WebController](#webcontroller) | 否 | 控制器。 |
**示例:**
......@@ -83,8 +83,8 @@ domStorageAccess(domStorageAccess: boolean)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------------- | ------- | ---- | ---- | ------------------------------------ |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------------- | ------- | ---- | ----- | ------------------------------------ |
| domStorageAccess | boolean | 是 | false | 设置是否开启文档对象模型存储接口(DOM Storage API)权限。 |
**示例:**
......@@ -108,12 +108,12 @@ domStorageAccess(domStorageAccess: boolean)
fileAccess(fileAccess: boolean)
设置是否开启应用中文件系统的访问,默认启用。[$rawfile(filepath/filename)](../../ui/ts-resource-access.md)中rawfile路径的文件不受该属性影响而限制访问。
设置是否开启应用中文件系统的访问,默认启用。[$rawfile(filepath/filename)](../../quick-start/resource-categories-and-access.md)中rawfile路径的文件不受该属性影响而限制访问。
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------- | ------- | ---- | ---- | ---------------------------------------- |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------- | ------- | ---- | ---- | ---------------------- |
| fileAccess | boolean | 是 | true | 设置是否开启应用中文件系统的访问,默认启用。 |
**示例:**
......@@ -137,7 +137,7 @@ fileAccess(fileAccess: boolean)
fileFromUrlAccess(fileFromUrlAccess: boolean)
设置是否允许通过网页中的JavaScript脚本访问应用文件系统中的内容,默认未启用。[$rawfile(filepath/filename)](../../ui/ts-resource-access.md)中rawfile路径的文件不受该属性影响而限制访问。
设置是否允许通过网页中的JavaScript脚本访问应用文件系统中的内容,默认未启用。[$rawfile(filepath/filename)](../../quick-start/resource-categories-and-access.md)中rawfile路径的文件不受该属性影响而限制访问。
**参数:**
......@@ -199,12 +199,12 @@ javaScriptProxy(javaScriptProxy: { object: object, name: string, methodList: Arr
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------- | --------------- | ---- | ---- | ------------------------- |
| object | object | 是 | - | 参与注册的对象。只能声明方法,不能声明属性。 |
| name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。 |
| methodList | Array\<string\> | 是 | - | 参与注册的应用侧JavaScript对象的方法。 |
| controller | [WebController](#webcontroller) | 否 | - | 控制器。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------- | ------------------------------- | ---- | ---- | ------------------------- |
| object | object | 是 | - | 参与注册的对象。只能声明方法,不能声明属性。 |
| name | string | 是 | - | 注册对象的名称,与window中调用的对象名一致。 |
| methodList | Array\<string\> | 是 | - | 参与注册的应用侧JavaScript对象的方法。 |
| controller | [WebController](#webcontroller) | 否 | - | 控制器。 |
**示例:**
......@@ -277,8 +277,8 @@ mixedMode(mixedMode: MixedMode)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | --------------------------- | ---- | ---- | --------- |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | --------------------------- | ---- | -------------- | --------- |
| mixedMode | [MixedMode](#mixedmode枚举说明) | 是 | MixedMode.None | 要设置的混合内容。 |
**示例:**
......@@ -394,8 +394,8 @@ databaseAccess(databaseAccess: boolean)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------------- | ------- | ---- | ---- | ----------------- |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------------- | ------- | ---- | ----- | ----------------- |
| databaseAccess | boolean | 是 | false | 设置是否开启数据库存储API权限。 |
**示例:**
......@@ -423,9 +423,9 @@ geolocationAccess(geolocationAccess: boolean)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------------- | ------- | ---- | ---- | ----------------- |
| geolocationAccess | boolean | 是 | true | 设置是否开启获取地理位置权限。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----------------- | ------- | ---- | ---- | --------------- |
| geolocationAccess | boolean | 是 | true | 设置是否开启获取地理位置权限。 |
**示例:**
......@@ -452,9 +452,9 @@ mediaPlayGestureAccess(access: boolean)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | ------ | ---- | ---- | --------- |
| access | boolean | 是 | true | 设置视频播放是否需要用户手动点击。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | ------- | ---- | ---- | ----------------- |
| access | boolean | 是 | true | 设置视频播放是否需要用户手动点击。 |
**示例:**
......@@ -482,8 +482,8 @@ cacheMode(cacheMode: CacheMode)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | --------------------------- | ---- | ---- | --------- |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | --------------------------- | ---- | ----------------- | --------- |
| cacheMode | [CacheMode](#cachemode枚举说明) | 是 | CacheMode.Default | 要设置的缓存模式。 |
**示例:**
......@@ -512,9 +512,9 @@ textZoomRatio(textZoomRatio: number)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------------ | ------ | ---- | ---- | --------------- |
| textZoomRatio | number | 是 | 100 | 要设置的页面的文本缩放百分比。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------------- | ------ | ---- | ---- | --------------- |
| textZoomRatio | number | 是 | 100 | 要设置的页面的文本缩放百分比。 |
**示例:**
......@@ -572,9 +572,9 @@ webDebuggingAccess(webDebuggingAccess: boolean)
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | ------ | ---- | ---- | --------- |
| webDebuggingAccess | boolean | 是 | false | 设置是否启用网页调试功能。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------------------ | ------- | ---- | ----- | ------------- |
| webDebuggingAccess | boolean | 是 | false | 设置是否启用网页调试功能。 |
**示例:**
......@@ -1155,9 +1155,9 @@ onRefreshAccessedHistory(callback: (event?: { url: string, isRefreshed: boolean
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ----------- | ------- | --------------------------------- |
| url | string | 访问的url。 |
| 参数名 | 参数类型 | 参数描述 |
| ----------- | ------- | ---------------------------------------- |
| url | string | 访问的url。 |
| isRefreshed | boolean | true表示该页面是被重新加载的(调用[refresh](#refresh)接口),false表示该页面是新加载的。 |
**示例:**
......@@ -1227,8 +1227,8 @@ onShowFileSelector(callback: (event?: { result: FileSelectorResult, fileSelector
**返回值:**
| 类型 | 说明 |
| ------- | ----------------------------------- |
| 类型 | 说明 |
| ------- | ---------------------------------------- |
| boolean | 当返回值为true时,用户可以调用系统提供的弹窗能力。当返回值为false时,触发Web默认弹窗。 |
**示例:**
......@@ -1321,8 +1321,8 @@ onInterceptRequest(callback: (event?: { request: WebResourceRequest}) => WebReso
**返回值:**
| 类型 | 说明 |
| ---------------------------------------- | --------------------------- |
| 类型 | 说明 |
| ---------------------------------------- | ---------------------------------------- |
| [WebResourceResponse](#webresourceresponse) | 返回响应数据则按照响应数据加载,无响应数据则返回null表示按照原来的方式加载。 |
**示例:**
......@@ -1449,10 +1449,10 @@ onSslErrorEventReceive(callback: (event: { handler: SslErrorHandler, error: SslE
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | ---------------- |
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | -------------- |
| handler | [SslErrorHandler](#sslerrorhandler9) | 通知Web组件用户操作行为。 |
| error | [SslError](#sslerror9枚举说明) | 错误码。 |
| error | [SslError](#sslerror9枚举说明) | 错误码。 |
**示例:**
......@@ -1502,13 +1502,13 @@ onClientAuthenticationRequest(callback: (event: {handler : ClientAuthenticationH
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | ---------------- |
| handler | [ClientAuthenticationHandler](#clientauthenticationhandler9) | 通知Web组件用户操作行为。|
| host | string | 请求证书服务器的主机名。 |
| port | number | 请求证书服务器的端口号。 |
| keyTypes| Array<string> | 可接受的非对称秘钥类型。 |
| issuers | Array<string> | 与私钥匹配的证书可接受颁发者。|
| 参数名 | 参数类型 | 参数描述 |
| -------- | ---------------------------------------- | --------------- |
| handler | [ClientAuthenticationHandler](#clientauthenticationhandler9) | 通知Web组件用户操作行为。 |
| host | string | 请求证书服务器的主机名。 |
| port | number | 请求证书服务器的端口号。 |
| keyTypes | Array<string> | 可接受的非对称秘钥类型。 |
| issuers | Array<string> | 与私钥匹配的证书可接受颁发者。 |
**示例:**
```ts
......@@ -1557,9 +1557,9 @@ onPermissionRequest(callback: (event?: { request: PermissionRequest }) => void)
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | ---------------- |
| request | [PermissionRequest](#permissionrequest9) | 通知Web组件用户操作行为。 |
| 参数名 | 参数类型 | 参数描述 |
| ------- | ---------------------------------------- | -------------- |
| request | [PermissionRequest](#permissionrequest9) | 通知Web组件用户操作行为。 |
**示例:**
......@@ -1606,15 +1606,15 @@ onContextMenuShow(callback: (event?: { param: WebContextMenuParam, result: WebCo
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | ---------------- |
| param | [WebContextMenuParam](#webcontextmenuparam9) | 菜单相关参数。 |
| result | [WebContextMenuResult](#webcontextmenuresult9) | 菜单相应事件传入内核。 |
| 参数名 | 参数类型 | 参数描述 |
| ------ | ---------------------------------------- | ----------- |
| param | [WebContextMenuParam](#webcontextmenuparam9) | 菜单相关参数。 |
| result | [WebContextMenuResult](#webcontextmenuresult9) | 菜单相应事件传入内核。 |
**返回值:**
| 类型 | 说明 |
| ------ | -------------------- |
| 类型 | 说明 |
| ------- | ------------------------ |
| boolean | 自定义菜单返回true,默认菜单返回false。 |
**示例:**
......@@ -1646,10 +1646,10 @@ onScroll(callback: (event: {xOffset: number, yOffset: number}) => void)
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------------------------------------ | ---------------- |
| xOffset | number | 水平滚动条滚动所在位置。 |
| yOffset | number | 竖直滚动条滚动所在位置。 |
| 参数名 | 参数类型 | 参数描述 |
| ------- | ------ | ------------ |
| xOffset | number | 水平滚动条滚动所在位置。 |
| yOffset | number | 竖直滚动条滚动所在位置。 |
**示例:**
......@@ -1679,10 +1679,10 @@ onGeolocationShow(callback: (event?: { origin: string, geolocation: JsGeolocatio
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ----------- | ------------------------------- | ---------------- |
| 参数名 | 参数类型 | 参数描述 |
| ----------- | ------------------------------- | -------------- |
| origin | string | 指定源的字符串索引。 |
| geolocation | [JsGeolocation](#jsgeolocation) | 通知Web组件用户操作行为。|
| geolocation | [JsGeolocation](#jsgeolocation) | 通知Web组件用户操作行为。 |
**示例:**
......@@ -2183,10 +2183,10 @@ confirm(priKeyFile : string, certChainFile : string): void
**参数:**
| 参数名 | 参数类型 | 必填 | 参数描述 |
| -------- | ------ | ---- | ---------- |
| priKeyFile | string | 是 | 存放私钥的文件,包含路径和文件名。|
| certChainFile | string | 是 | 存放证书链的文件,包含路径和文件名。|
| 参数名 | 参数类型 | 必填 | 参数描述 |
| ------------- | ------ | ---- | ------------------ |
| priKeyFile | string | 是 | 存放私钥的文件,包含路径和文件名。 |
| certChainFile | string | 是 | 存放证书链的文件,包含路径和文件名。 |
### cancel<sup>9+</sup>
......@@ -2218,9 +2218,9 @@ getOrigin(): string
**返回值:**
| 类型 | 说明 |
| ------- | --------------------- |
| string | 当前请求权限网页的来源。 |
| 类型 | 说明 |
| ------ | ------------ |
| string | 当前请求权限网页的来源。 |
### getAccessibleResource<sup>9+</sup>
......@@ -2230,8 +2230,8 @@ getAccessibleResource(): Array\<string\>
**返回值:**
| 类型 | 说明 |
| --------------- | ----------------------- |
| 类型 | 说明 |
| --------------- | ------------- |
| Array\<string\> | 网页所请求的权限资源列表。 |
### grant<sup>9+</sup>
......@@ -2242,9 +2242,9 @@ grant(resources: Array\<string\>): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | --------------- | ---- | ----- | ---------------------- |
| resources | Array\<string\> | 是 | - | 网页所请求的权限资源列表。|
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | --------------- | ---- | ---- | ------------- |
| resources | Array\<string\> | 是 | - | 网页所请求的权限资源列表。 |
## WebContextMenuParam<sup>9+</sup>
......@@ -2258,8 +2258,8 @@ x(): number
**返回值:**
| 类型 | 说明 |
| --------------- | ----------------------- |
| 类型 | 说明 |
| ------ | ------------------ |
| number | 显示正常返回非负整数,否则返回-1。 |
### y<sup>9+</sup>
......@@ -2270,8 +2270,8 @@ y(): number
**返回值:**
| 类型 | 说明 |
| --------------- | ----------------------- |
| 类型 | 说明 |
| ------ | ------------------ |
| number | 显示正常返回非负整数,否则返回-1。 |
### getLinkUrl<sup>9+</sup>
......@@ -2282,8 +2282,8 @@ getLinkUrl(): string
**返回值:**
| 类型 | 说明 |
| --------------- | ----------------------- |
| 类型 | 说明 |
| ------ | ------------------------- |
| string | 如果长按位置是链接,返回经过安全检查的url链接。 |
### getUnfilterendLinkUrl<sup>9+</sup>
......@@ -2294,8 +2294,8 @@ getUnfilterendLinkUrl(): string
**返回值:**
| 类型 | 说明 |
| --------------- | ----------------------- |
| 类型 | 说明 |
| ------ | --------------------- |
| string | 如果长按位置是链接,返回原始的url链接。 |
### getSourceUrl<sup>9+</sup>
......@@ -2306,8 +2306,8 @@ getSourceUrl(): string
**返回值:**
| 类型 | 说明 |
| --------------- | ----------------------- |
| 类型 | 说明 |
| ------ | ------------------------ |
| string | 如果选中的元素有src属性,返回src的url。 |
### existsImageContents<sup>9+</sup>
......@@ -2318,8 +2318,8 @@ existsImageContents(): boolean
**返回值:**
| 类型 | 说明 |
| --------------- | ----------------------- |
| 类型 | 说明 |
| ------- | ------------------------- |
| boolean | 长按位置中有图片返回true,否则返回false。 |
## WebContextMenuResult<sup>9+</sup>
......@@ -2350,11 +2350,11 @@ invoke(origin: string, allow: boolean, retain: boolean): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| --------- | ------- | ---- | ----- | ---------------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| allow | boolean | 是 | - | 设置的地理位置权限状态。 |
| retain | boolean | 是 | - | 是否允许将地理位置权限状态保存到系统中。可通过[GeolocationPermissions](#geolocationpermissions9)接口管理保存到系统的地理位置权限。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | ------- | ---- | ---- | ---------------------------------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| allow | boolean | 是 | - | 设置的地理位置权限状态。 |
| retain | boolean | 是 | - | 是否允许将地理位置权限状态保存到系统中。可通过[GeolocationPermissions](#geolocationpermissions9)接口管理保存到系统的地理位置权限。 |
## WebController
......@@ -3362,8 +3362,8 @@ createWebMessagePorts(): Array\<WebMessagePort\>
**返回值:**
| 类型 | 说明 |
| ------------------------------- | ------------- |
| 类型 | 说明 |
| ---------------------------------------- | ---------- |
| Array\<[WebMessagePort](#webmessageport9)\> | web信息端口列表。 |
**示例:**
......@@ -3396,10 +3396,10 @@ postMessage(options: { message: WebMessageEvent, uri: string}): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---------- | --------------- | ---- | ---- | ------------------------- |
| message | [WebMessageEvent](#webmessageevent9) | 是 | - |要发送的信息,包含数据和信息端口 。 |
| uri | string | 是 | - | 接收该信息的URI。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------- | ------------------------------------ | ---- | ---- | ------------------ |
| message | [WebMessageEvent](#webmessageevent9) | 是 | - | 要发送的信息,包含数据和信息端口 。 |
| uri | string | 是 | - | 接收该信息的URI。 |
**示例:**
......@@ -3507,8 +3507,8 @@ getUrl(): string
**返回值:**
| 类型 | 说明 |
| ------------------------------- | ------------- |
| 类型 | 说明 |
| ------ | ----------- |
| string | 当前页面的url地址。 |
**示例:**
......@@ -3641,14 +3641,14 @@ getCookie(url: string): string
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| url | string | 是 | - | 要获取的cookie所属的url。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---- | ------ | ---- | ---- | ----------------- |
| url | string | 是 | - | 要获取的cookie所属的url。 |
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| 类型 | 说明 |
| ------ | ----------------- |
| string | 指定url对应的cookie的值。 |
**示例:**
......@@ -3684,12 +3684,12 @@ setCookie(url: string, value: string): boolean
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| url | string | 是 | - | 要设置的cookie所属的url。 |
| value | string | 是 | - | 要设置的cookie的值。 |
| value | string | 是 | - | 要设置的cookie的值。 |
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| 类型 | 说明 |
| ------- | ------------- |
| boolean | 设置cookie是否成功。 |
**示例:**
......@@ -3756,8 +3756,8 @@ saveCookieAsync(): Promise\<boolean>
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| 类型 | 说明 |
| ----------------- | --------------------------- |
| Promise\<boolean> | Promise实例,用于获取cookie是否成功保存。 |
**示例:**
......@@ -3795,9 +3795,9 @@ saveCookieAsync(callback: AsyncCallback\<boolean>): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| callback | AsyncCallback\<boolean> | 是 | - | 返回cookie是否成功保存的布尔值作为回调函数的入参。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | ----------------------- | ---- | ---- | ---------------------------- |
| callback | AsyncCallback\<boolean> | 是 | - | 返回cookie是否成功保存的布尔值作为回调函数的入参。 |
**示例:**
......@@ -3830,8 +3830,8 @@ isCookieAllowed(): boolean
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| 类型 | 说明 |
| ------- | ------------------- |
| boolean | 是否拥有发送和接收cookie的权限。 |
**示例:**
......@@ -3864,9 +3864,9 @@ putAcceptCookieEnabled(accept: boolean): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| accept | boolean | 是 | - | 设置是否拥有发送和接收cookie的权限。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | ------- | ---- | ---- | --------------------- |
| accept | boolean | 是 | - | 设置是否拥有发送和接收cookie的权限。 |
**示例:**
......@@ -3897,8 +3897,8 @@ isThirdCookieAllowed(): boolean
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| 类型 | 说明 |
| ------- | ---------------------- |
| boolean | 是否拥有发送和接收第三方cookie的权限。 |
**示例:**
......@@ -3931,9 +3931,9 @@ putAcceptThirdPartyCookieEnabled(accept: boolean): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| accept | boolean | 是 | - | 设置是否拥有发送和接收第三方cookie的权限。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | ------- | ---- | ---- | ------------------------ |
| accept | boolean | 是 | - | 设置是否拥有发送和接收第三方cookie的权限。 |
**示例:**
......@@ -3964,8 +3964,8 @@ existCookie(): boolean
**返回值:**
| 类型 | 说明 |
| ------- | -------------------- |
| 类型 | 说明 |
| ------- | ----------- |
| boolean | 是否存在cookie。 |
**示例:**
......@@ -4208,9 +4208,9 @@ static allowGeolocation(origin: string): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | ---- | ----- | ------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | ------ | ---- | ---- | ---------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
**示例:**
......@@ -4242,9 +4242,9 @@ static deleteGeolocation(origin: string): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | ---- | ----- | ------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | ------ | ---- | ---- | ---------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
**示例:**
......@@ -4303,10 +4303,10 @@ static getAccessibleGeolocation(origin: string, callback: AsyncCallback\<boolean
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | ---- | ----- | ------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| callback | AsyncCallback\<boolean\> | 是 | - | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | ------------------------ | ---- | ---- | ---------------------------------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| callback | AsyncCallback\<boolean\> | 是 | - | 返回指定源的地理位置权限状态。获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 |
**示例:**
......@@ -4344,14 +4344,14 @@ static getAccessibleGeolocation(origin: string): Promise\<boolean\>
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | ---- | ----- | ------------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------ | ------ | ---- | ---- | ---------- |
| origin | string | 是 | - | 指定源的字符串索引。 |
**返回值:**
| 类型 | 说明 |
| ------------------ | ------------------------------------ |
| 类型 | 说明 |
| ------------------ | ---------------------------------------- |
| Promise\<boolean\> | Promise实例,用于获取指定源的权限状态,获取成功,true表示已授权,false表示拒绝访问。获取失败,表示不存在指定源的权限状态。 |
**示例:**
......@@ -4388,9 +4388,9 @@ static getStoredGeolocation(callback: AsyncCallback\<Array\<string\>\>): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | ---- | ----- | ------------- |
| callback | AsyncCallback\<Array\<string\>\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------------------------------- | ---- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<string\>\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 |
**示例:**
......@@ -4428,14 +4428,14 @@ static getStoredGeolocation(): Promise\<Array\<string\>\>
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | ---- | ----- | ------------- |
| callback | AsyncCallback\<Array\<string\>\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------------------------------- | ---- | ---- | -------------------- |
| callback | AsyncCallback\<Array\<string\>\> | 是 | - | 返回已存储地理位置权限状态的所有源信息。 |
**返回值:**
| 类型 | 说明 |
| -------------------------- | ------------------------------------ |
| 类型 | 说明 |
| -------------------------- | -------------------------------- |
| Promise\<Array\<string\>\> | Promise实例,用于获取已存储地理位置权限状态的所有源信息。 |
**示例:**
......@@ -4796,8 +4796,8 @@ searchAllAsync(searchString: string): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---- | ------ | ---- | ---- | --------------------- |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------------ | ------ | ---- | ---- | ------- |
| searchString | string | 是 | - | 查找的关键字。 |
**示例:**
......@@ -4869,8 +4869,8 @@ searchNext(forward: boolean): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---- | ------ | ---- | ---- | --------------------- |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------- | ------- | ---- | ---- | ----------- |
| forward | boolean | 是 | - | 从前向后或者逆向查找。 |
......@@ -4903,11 +4903,11 @@ onSearchResultReceive(callback: (event?: {activeMatchOrdinal: number, numberOfMa
**参数:**
| 参数名 | 参数类型 | 参数描述 |
| ------------------ | ------------- | ----------------------------------- |
| activeMatchOrdinal | number | 当前匹配的查找项的序号(从0开始)。 |
| numberOfMatches | number | 所有匹配到的关键词的个数。 |
| isDoneCounting | boolean | 当次页内查找操作是否结束。该方法可能会回调多次,直到isDoneCounting为true为止。 |
| 参数名 | 参数类型 | 参数描述 |
| ------------------ | ------- | ---------------------------------------- |
| activeMatchOrdinal | number | 当前匹配的查找项的序号(从0开始)。 |
| numberOfMatches | number | 所有匹配到的关键词的个数。 |
| isDoneCounting | boolean | 当次页内查找操作是否结束。该方法可能会回调多次,直到isDoneCounting为true为止。 |
**示例:**
......@@ -5004,18 +5004,18 @@ onRenderExited接口返回的渲染进程退出的具体原因。
onSslErrorEventReceive接口返回的SSL错误的具体原因。
| 名称 | 描述 |
| -------------- | ----------------- |
| Invalid | 一般错误。 |
| HostMismatch | 主机名不匹配。 |
| DateInvalid | 证书日期无效。 |
| Untrusted | 证书颁发机构不受信任。 |
| 名称 | 描述 |
| ------------ | ----------- |
| Invalid | 一般错误。 |
| HostMismatch | 主机名不匹配。 |
| DateInvalid | 证书日期无效。 |
| Untrusted | 证书颁发机构不受信任。 |
## ProtectedResourceType<sup>9+</sup>枚举说明
| 名称 | 描述 | 备注 |
| --------- | -------------- | -------------- |
| MidiSysex | MIDI SYSEX资源。| 目前仅支持权限事件上报,MIDI设备的使用还未支持。|
| 名称 | 描述 | 备注 |
| --------- | ------------- | -------------------------- |
| MidiSysex | MIDI SYSEX资源。 | 目前仅支持权限事件上报,MIDI设备的使用还未支持。 |
## WebAsyncController
......@@ -5083,8 +5083,8 @@ storeWebArchive(baseName: string, autoName: boolean): Promise<string>
**返回值:**
| 类型 | 说明 |
| ---------------------------------------- | ---------------------------------------- |
| 类型 | 说明 |
| --------------- | -------------------------------- |
| Promise<string> | Promise实例,保存成功返回文件路径,保存失败返回null。 |
**示例:**
......@@ -5130,9 +5130,9 @@ postMessageEvent(message: WebMessageEvent): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| message | [WebMessageEvent](#webmessageevent9) | 是 | - | 要发送的消息。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ------- | ------------------------------------ | ---- | ---- | ------- |
| message | [WebMessageEvent](#webmessageevent9) | 是 | - | 要发送的消息。 |
**示例:**
......@@ -5165,9 +5165,9 @@ onMessageEvent(callback: (result: string) => void): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| callback | function | 是 | - | 接收消息的回调函数。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| -------- | -------- | ---- | ---- | ---------- |
| callback | function | 是 | - | 接收消息的回调函数。 |
**示例:**
......@@ -5205,8 +5205,8 @@ getData(): string
**返回值:**
| 类型 | 说明 |
| ------------------------------- | ------------- |
| 类型 | 说明 |
| ------ | -------------- |
| string | 当前该类型对象中存放的消息。 |
**示例:**
......@@ -5237,9 +5237,9 @@ setData(data: string): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| data | string | 是 | - | 要发送的消息。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ---- | ------ | ---- | ---- | ------- |
| data | string | 是 | - | 要发送的消息。 |
**示例:**
......@@ -5271,8 +5271,8 @@ getPorts(): Array\<WebMessagePort\>
**返回值:**
| 类型 | 说明 |
| ------------------------------- | ------------- |
| 类型 | 说明 |
| ---------------------------------------- | ---------------- |
| Array\<[WebMessagePort](#webmessageport9)\> | 当前该类型对象中存放的消息端口。 |
**示例:**
......@@ -5305,9 +5305,9 @@ setPorts(ports: Array\<WebMessagePort\>): void
**参数:**
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ------ | ---- | ---- | ----------------- |
| ports | Array\<[WebMessagePort](#webmessageport9)\> | 是 | - | 要发送的消息端口。 |
| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 |
| ----- | ---------------------------------------- | ---- | ---- | --------- |
| ports | Array\<[WebMessagePort](#webmessageport9)\> | 是 | - | 要发送的消息端口。 |
**示例:**
......
......@@ -9,26 +9,26 @@
## 事件
| 名称 | 支持冒泡 | 描述 |
| ------------------------------------------------------------ | -------- | ------------------------------------------------------------ |
| onHover(event:&nbsp;(isHover?:&nbsp;boolean)&nbsp;=&gt;&nbsp;void) | 否 | 鼠标进入或退出组件时触发该回调。<br/>isHover:表示鼠标是否悬浮在组件上,鼠标进入时为true,&nbsp;退出时为false。 |
| onMouse(event:&nbsp;(event?:&nbsp;MouseEvent)&nbsp;=&gt;&nbsp;void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上悬浮移动时,触发该回调,event返回值包含触发事件时的时间戳、鼠标按键、动作、鼠标位置在整个屏幕上的坐标和相对于当前组件的坐标。 |
| 名称 | 支持冒泡 | 描述 |
| ---------------------------------------- | ---- | ---------------------------------------- |
| onHover(event:&nbsp;(isHover?:&nbsp;boolean)&nbsp;=&gt;&nbsp;void) | 否 | 鼠标进入或退出组件时触发该回调。<br/>isHover:表示鼠标是否悬浮在组件上,鼠标进入时为true,&nbsp;退出时为false。 |
| onMouse(event:&nbsp;(event?:&nbsp;MouseEvent)&nbsp;=&gt;&nbsp;void) | 是 | 当前组件被鼠标按键点击时或者鼠标在组件上悬浮移动时,触发该回调,event返回值包含触发事件时的时间戳、鼠标按键、动作、鼠标位置在整个屏幕上的坐标和相对于当前组件的坐标。 |
## MouseEvent对象说明
| 名称 | 属性类型 | 描述 |
| --------- | ------------------------------- | -------------------- |
| screenX | number | 鼠标位置相对于应用窗口左上角的x轴坐标。 |
| screenY | number | 鼠标位置相对于应用窗口左上角的y轴坐标。 |
| x | number | 鼠标位置相对于当前组件左上角的x轴坐标。 |
| y | number | 鼠标位置相对于当前组件左上角的y轴坐标。 |
| button | [MouseButton](ts-appendix-enums.md#mousebutton) | 鼠标按键。 |
| action | [MouseAction](ts-appendix-enums.md#mouseaction) | 鼠标动作。 |
| stopPropagation | () => void | 阻塞事件冒泡。 |
| timestamp<sup>8+</sup> | number | 事件时间戳。触发事件时距离系统启动的时间间隔,单位纳秒。 |
| target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md#eventtarget8对象说明) | 触发手势事件的元素对象显示区域。 |
| source<sup>8+</sup> | [SourceType](ts-gesture-settings.md#sourcetype枚举说明) | 事件输入设备。 |
| 名称 | 属性类型 | 描述 |
| ---------------------- | ---------------------------------------- | ---------------------------- |
| screenX | number | 鼠标位置相对于应用窗口左上角的x轴坐标。 |
| screenY | number | 鼠标位置相对于应用窗口左上角的y轴坐标。 |
| x | number | 鼠标位置相对于当前组件左上角的x轴坐标。 |
| y | number | 鼠标位置相对于当前组件左上角的y轴坐标。 |
| button | [MouseButton](ts-appendix-enums.md#mousebutton) | 鼠标按键。 |
| action | [MouseAction](ts-appendix-enums.md#mouseaction) | 鼠标动作。 |
| stopPropagation | () => void | 阻塞事件冒泡。 |
| timestamp<sup>8+</sup> | number | 事件时间戳。触发事件时距离系统启动的时间间隔,单位纳秒。 |
| target<sup>8+</sup> | [EventTarget](ts-universal-events-click.md#eventtarget8对象说明) | 触发手势事件的元素对象显示区域。 |
| source<sup>8+</sup> | [SourceType](ts-gesture-settings.md#sourcetype枚举说明) | 事件输入设备。 |
## 示例
......@@ -109,8 +109,8 @@ struct MouseEventExample {
鼠标悬浮时改变文本内容与背景颜色:
![mouse](/figures/mouse.png)
![mouse](figures/mouse.png)
鼠标点击时:
![mouse1](/figures/mouse1.png)
\ No newline at end of file
![mouse1](figures/mouse1.png)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册