# CanvasContext.createPattern(string image, string repetition)

Start from base library version 1.9.90. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support

A method that creates a pattern for a specified image, repeating a meta image in a specified direction

# parameter

# string image

Duplicate image source, support code package path and local temporary path (Local path)

# string repetition

How to repeat images

repetition Legal value

value Introductions Minimum version
repeat Repeat horizontally and vertically.
repeat-x Repeat horizontally
repeat-y Repeat in vertical direction
no-repeat No repeat

# sample code

    const ctx = wx.createCanvasContext('myCanvas')
    const pattern = ctx.createPattern('/path/to/image',  'repeat-x')
    ctx.fillStyle = pattern
    ctx.fillRect(0, 0, 300, 150)