CreateRGBColor
通过设置红、绿、蓝颜色分量的适当值来创建 RGB 颜色。
语法
expression.CreateRGBColor(r, g, b);
expression - 表示 Api 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| r | 必需 | byte | 红色分量值。 | |
| g | 必需 | byte | 绿色分量值。 | |
| b | 必需 | byte | 蓝色分量值。 |
返回值
示例
使用红、绿、蓝值定义自定义颜色以填充文档中的形状。
// How do I specify exact RGB color values to create a gradient fill on a shape in a document?
// Blend two hand-picked RGB colors across a shape using a linear gradient in a document.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
let gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
let fill = Api.CreateLinearGradientFill([gs1, gs2], 5400000);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = Api.CreateShape("rect", 5930900, 395605, fill, stroke);
paragraph.AddDrawing(shape);