跳到主要内容

RGB

从红、绿、蓝分量创建 RGB 颜色。

语法

expression.RGB(r, g, b);

expression - 表示 Api 类的变量。

参数

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

返回值

ApiColor

示例

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

// How do I define a custom color using RGB components in a spreadsheet?

// Fill a shape with a color built from specific red, green, and blue intensities in a spreadsheet.

const worksheet = Api.GetActiveSheet();
const color = Api.RGB(186, 218, 85);
const fill = Api.CreateSolidFill(color);
const stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(0, 0, 0)));
worksheet.AddShape("rect", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);