跳到主要内容

ThemeColor

Creates a theme color.

Syntax

expression.ThemeColor(name);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nameOptionalSchemeColorId"tx1"The theme color name. If the provided name is not supported, the 'tx1' color will be used.

Returns

ApiColor

Example

This example shows how to create a theme color and use it as a shape fill.

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

const color = Api.ThemeColor('accent6');
const fill = Api.CreateSolidFill(color);
const stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(0, 0, 0)));
const shape = Api.CreateShape("rect", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);
slide.AddObject(shape);