跳到主要内容

IsThemeColor

如果颜色是主题颜色则返回 true。

语法

expression.IsThemeColor();

expression - 表示 ApiColor 类的变量。

参数

此方法没有任何参数。

返回值

boolean

示例

确定文档中的颜色是否链接到主题插槽。

// How do I check if a color comes from the document theme in a document?

// Distinguish a fixed hex color from a theme-bound color that changes with the theme in a document.

const doc = Api.GetDocument();
const hexColor = Api.HexColor('#FF0000');
const themeColor = Api.ThemeColor('accent1');
const paragraph = doc.GetElement(0);
paragraph.AddText('Is hexColor a theme color? ' + hexColor.IsThemeColor());
paragraph.AddLineBreak();
paragraph.AddText('Is themeColor a theme color? ' + themeColor.IsThemeColor());