> 微信小程序开发教程手册 > 微信小程序API 绘图·设置填充样式

微信小程序API 绘图·设置填充样式绘图接口和方法


setFillStyle


定义

设置填充色。

Tip: 如果没有设置 fillStyle,默认颜色为 black

参数

参数 类型 定义
color Color \ Gradient Object 填充色

例子

const ctx = wx.createCanvasContext('myCanvas')
ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 75)
ctx.draw()

微信小程序API 绘图·设置填充样式

微信小程序API 绘图·设置填充样式绘图接口和方法