🎨 颜色(Color)#
#bs.color:help
实现各种格式之间的颜色转换。
“色彩是光的表达——不是物理意义上的光,而是真正存在于艺术家脑海中的光。”
—亨利·马蒂斯(Henri Matisse)
Minecraft 颜色格式
Minecraft 的内部颜色格式是十进制。此模块实现了这种整数(十进制)格式与其他常用格式之间的转换。
🔧 函数#
你可以在下方找到此模块中的所有可用函数。
转换为十六进制#
- #bs.color:rgb_to_hex {color:[]}
将颜色从RGB转换为十六进制。
- 输入:
函数宏:
参数
color: 用来表示RGB颜色的向量(比如:[0,255,128])。
- 输出:
命令存储
bs:out color.rgb_to_hex: 十六进制字符串形式的颜色。
示例:将RGB颜色转换为十六进制:
# Get the RGB color
function #bs.color:rgb_to_hex {color:[0,255,128]}
# Show the result
data get storage bs:out color.rgb_to_hex
- #bs.color:int_to_hex {color:<value>}
将颜色从整数转换为十六进制。
- 输入:
函数宏:
参数
color: 用整数表示的颜色。
- 输出:
命令存储
bs:out color.int_to_hex: 十六进制字符串形式的颜色。
示例:获取最近的僵尸皮革头盔的十六进制颜色:
# Get the hexadecimal color
function #bs.color:int_to_hex with entity @e[type=minecraft:zombie,sort=nearest,limit=1] ArmorItems[3].tag.display
# Show the result
data get storage bs:out color.int_to_hex
制作人员:Aksiome、theogiraudet
转换为整数#
- #bs.color:hex_to_int {color:<value>}
将颜色从十六进制转换为整数。
- 输入:
函数宏:
参数
color: 用16进制字符串表示的颜色(比如:#ffffff)。
- 输出:
返回值 | 分数
$color.hex_to_int bs.out:整数形式的颜色。命令存储
bs:out color.hex_to_int: 整数形式的颜色。
示例:使用十六进制格式更改最近的僵尸皮革头盔的颜色:
# Summon a test subject
summon minecraft:zombie ~ ~ ~ {ArmorItems:[{},{},{},{id:"minecraft:leather_helmet",Count:1b}]}
# Set the helmet color
execute as @e[type=minecraft:zombie,sort=nearest,limit=1] store result entity @s ArmorItems[3].tag.display.color int 1 run function #bs.color:hex_to_int {color:"#ffffff"}
- #bs.color:rgb_to_int {color:[]}
将颜色从RGB转换为整数。
- 输入:
函数宏:
参数
color: 用来表示RGB颜色的向量(比如:[0,255,128])。
- 输出:
返回值 | 分数
$color.rgb_to_int bs.out:整数形式的颜色。命令存储
bs:out color.rgb_to_int: 整数形式的颜色。
示例:使用RGB格式更改最近的僵尸皮革头盔的颜色:
# Summon a test subject
summon minecraft:zombie ~ ~ ~ {ArmorItems:[{},{},{},{id:"minecraft:leather_helmet",Count:1b}]}
# Set the helmet color
execute as @e[type=minecraft:zombie,sort=nearest,limit=1] store result entity @s ArmorItems[3].tag.display.color int 1 run function #bs.color:rgb_to_int {color:[255,0,0]}
制作人员:Aksiome、theogiraudet
转换为RGB#
- #bs.color:hex_to_rgb {color:<value>}
将颜色从十六进制转换为RGB。
- 输入:
函数宏:
参数
color: 用16进制字符串表示的颜色(比如:#ffffff)。
- 输出:
命令存储
bs:out color.hex_to_rgb: 表示RGB颜色的向量。分数
$color.hex_to_rgb.[r,g,b] bs.out:表示RGB颜色的向量分量。
示例:将十六进制颜色转换为RGB:
# Get the RGB color
function #bs.color:hex_to_rgb {color:"#ffffff"}
# Show the result
data get storage bs:out color.hex_to_rgb
- #bs.color:int_to_rgb {color:<value>}
将颜色从整数转换为RGB。
- 输入:
函数宏:
参数
color: 用整数表示的颜色。
- 输出:
命令存储
bs:out color.int_to_rgb: 表示RGB颜色的向量。分数
$color.int_to_rgb.[r,g,b] bs.out:表示RGB颜色的向量分量。
示例:获取最近的僵尸皮革头盔的RGB颜色:
# Get the RGB color
function #bs.color:int_to_rgb with entity @e[type=minecraft:zombie,sort=nearest,limit=1] ArmorItems[3].tag.display
# Show the result
data get storage bs:out color.int_to_rgb
制作人员:Aksiome、theogiraudet
💬 这对你有帮助吗?
欢迎在下方留下你的问题和反馈!