父级 Paint 库 display.* 修订版 版本 2024.3703 关键字 渐变绘画 另请参见 object.fill object.stroke
渐变绘画创建从一种颜色到另一种颜色的线性渐变。
local paint = {
type = "gradient",
color1 = { r,g,b,a },
color2 = { r,g,b,a },
direction =
}
String. "gradient" 的字符串值。
Array. 起始颜色的颜色通道的 RGB+A 数组。每个数字的范围应在 0 和 1 之间,并表示该通道的相应值。
Array. 结束颜色的颜色通道的 RGB+A 数组。每个数字的范围应在 0 和 1 之间,并表示该通道的相应值。
String. 渐变的方向,从 color1 到 color2。可以是 "down"、"up"、"left" 或 "right"。默认值为 "down"。
若作为 direction 参数传递 number.,将使用 "down",并且 fill.rotation 将应用其值。
(继承自 Paint 的属性)
local paint = {
type = "gradient",
color1 = { 1, 0, 0.4 },
color2 = { 1, 0, 0, 0.2 },
direction = "down"
}
local rect = display.newRect( 200, 200, 300, 300 )
rect.fill = paint