跳到主要内容

CreateRGBColor

Creates an RGB color setting the appropriate values for the red, green and blue color components.

Syntax

expression.CreateRGBColor(r, g, b);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
rRequiredbyteRed color component value.
gRequiredbyteGreen color component value.
bRequiredbyteBlue color component value.

Returns

ApiRGBColor

Example

This example shows how to create a RGB color for gradient stop.

// How to create a RGB color for a gradient stop.

// Add an RGB color as a stop for a gradient.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const rgbColor = Api.CreateRGBColor(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", 300 * 36000, 130 * 36000, fill, stroke);
drawing.SetPosition(608400, 1267200);
slide.AddObject(drawing);