跳到主要内容

RGBA

从红、绿、蓝和透明度分量创建 RGBA 颜色。

语法

expression.RGBA(r, g, b, a);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
r必需byte红色分量 (0-255)。
g必需byte绿色分量 (0-255)。
b必需byte蓝色分量 (0-255)。
a必需byte透明度分量 (0-255)。

返回值

ApiColor

示例

从红、绿、蓝和透明度值创建颜色并将其作为电子表格中的形状填充应用。

// How do I define a semi-transparent custom color using RGBA components in a spreadsheet?

// Fill a shape with a color that has a specific opacity level set via alpha in a spreadsheet.

const worksheet = Api.GetActiveSheet();
const color = Api.RGBA(110, 160, 180, 127);
const fill = Api.CreateSolidFill(color);
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
worksheet.AddShape("rect", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);