$color
存储颜色数据,包括不透明度。
$color(colorStr:string)
解析颜色字符串,返回颜色值。如果解析失败,则会抛出异常。
允许的格式有以下两种:
#RRGGBB
#AARRGGBB{
type: "text",
props: {
text: "Hello, OneScript!",
textColor: $color("#FF0000"),
}
}内置颜色常用颜色:
let color = $color("red")| 名称 | 颜色 |
|---|---|
| black | 黑色 |
| darkGray | 深灰色 |
| gray | 灰色 |
| lightGray | 浅灰色 |
| white | 白色 |
| red | 红色 |
| green | 绿色 |
| blue | 蓝色 |
| yellow | 黄色 |
| cyan | 青色 |
| magenta | 品红色 |
| transparent | 透明色 |
$color({light:string,dark:string})
同时设置浅色模式和深色模式下的颜色值
{
type: "text",
props: {
text: "Hello, OneScript!",
textColor: $color({light:"white",dark:"black"}),
}
}