跳到主要内容

ThemeColor

创建主题颜色。

语法​

expression.ThemeColor(name, tintAndShade);

expression - 表示 Api 类的变量。

参数​

名称必需/可选数据类型默认值描述
name可选SchemeColorId"tx1"主题颜色名称。如果提供的名称不受支持,将使用 'tx1' 颜色。
tintAndShade可选number0亮度偏移,范围从 -1(最暗的阴影)到 1(最亮的色调)。0 表示保持主题颜色不变。

返回值​

ApiColor

示例​

将主题颜色应用于文档中的段落文本。

// How do I color text using the document's theme palette in a document?

// Set the font color of a paragraph to one of the built-in theme accent colors in a document.

const doc = Api.GetDocument();
const color = Api.ThemeColor('accent6');
const paragraph = doc.GetElement(0);
paragraph.AddText('This text is in theme color.');
paragraph.SetColor(color);