跳到主要内容

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 set text color using red, green, and blue values in a document?

// Color paragraph text with a specific RGB combination in a document.

const doc = Api.GetDocument();
const color = Api.RGB(186, 218, 85);
const paragraph = doc.GetElement(0);
paragraph.AddText('This text is in RGB color.');
paragraph.SetColor(color);