当前位置:K88软件开发文章中心编程全书微信小程序 → 文章内容

微信小程序API 绘图·createPattern

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-15 15:01:12

由 Carrie 创建, 最后一次修改 2018-03-23 canvasContext.createPattern基础库 1.9.90 开始支持,低版本需做兼容处理定义对指定的图像创建模式的方法,可在指定的方向上重复元图像语法canvasContext.createPattern(image, repetition)参数 属性值 类型 说明 image String 重复的图像源,仅支持包内路径和临时路径 repetition String 指定如何重复图像,有效值有: repeat, repeat-x, repeat-y, no-repeat 例子const ctx = wx.createCanvasContext('myCanvas')const pattern = ctx.createPattern('/path/to/image', 'repeat-x')ctx.fillStyle = patternctx.fillRect(0, 0, 300, 150)ctx.draw()

微信小程序API 绘图·createPattern