跳到主要内容

CreateRGBColor

通过设置红、绿、蓝颜色分量的适当值来创建 RGB 颜色。

语法

expression.CreateRGBColor(r, g, b);

expression - 表示 Api 类的变量。

参数

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

返回值

ApiRGBColor

示例

在 PDF 中的渐变填充中使用 RGB 颜色。

// How do I define a custom color using red, green, and blue values in a PDF?

// Create a gradient stop with an RGB color in a PDF.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const rgbColor = Api.RGB(255, 111, 61);
const gs1 = Api.CreateGradientStop(Api.CreatePresetColor("peachPuff"), 0);
const gs2 = Api.CreateGradientStop(rgbColor, 100000);
const fill = Api.CreateRadialGradientFill([gs1, gs2]);
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const drawing = Api.CreateShape("flowChartMagneticTape", 150 * 36000, 65 * 36000, fill, stroke);
drawing.SetPosition(608400, 1267200);
page.AddObject(drawing);