# CanvasContext.createPattern(string image, string repetition)

Creates radial gradient management objects

## Support

App capability | Android | iOS | PC | Harmony | Preview
---|---|---|---|---|---
Gadget | V3.45.0+ | V3.45.0+ | V3.45.0+ | V7.35.0+ | Preview
Web app | **X** | **X** | **X** | **X** | /

## Input

Name | Data type | Required | Default value | Description
---|---|---|---|---
image | string | Yes | &nbsp; | Image URL. Local and network URLs are supported
repetition | string | Yes | &nbsp; | Repeat mode<br>**Valid values**:<br>- `repeat` Default. Both horizontal and vertical<br>- `repeat-x` Horizontal<br>- `repeat-y` Vertical<br>- `no-repeat` No direction

## Output

Return value:
`CanvasPattern`

##  Sample code

```javascript
const pattern = ctx.createPattern("https://sf3-cn.feishucdn.com/obj/eden-cn/eseh7nupevhps/block/image.png", "repeat-x");
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, 300, 150);
ctx.draw();
```
