Skip to content

Instantly share code, notes, and snippets.

@AllanChain
Last active June 18, 2022 03:30
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AllanChain/6db240c8981eec8fe360c678d0fc1462 to your computer and use it in GitHub Desktop.
Save AllanChain/6db240c8981eec8fe360c678d0fc1462 to your computer and use it in GitHub Desktop.
网页版树洞渐变色
'''
网页版树洞从 Alice 到 Zombie Zach 的颜色渐变
https://pkuhelper.pku.edu.cn/hole/##1264962
参考了网页版树洞的颜色生成机制,值越接近则颜色越接近。
可以通过更改 i 的值(0 到 1)来改变从谁开始
'''
NAMES = [
'Alice',
'Bob',
'Carol',
'Dave',
'Eve',
'Francis',
'Grace',
'Hans',
'Isabella',
'Jason',
'Kate',
'Louis',
'Margaret',
'Nathan',
'Olivia',
'Paul',
'Queen',
'Richard',
'Susan',
'Thomas',
'Uma',
'Vivian',
'Winnie',
'Xander',
'Yasmine',
'Zach']
PREFIXIES = [
'',
'Angry',
'Baby',
'Crazy',
'Diligent',
'Excited',
'Fat',
'Greedy',
'Hungry',
'Interesting',
'Jolly',
'Kind',
'Little',
'Magic',
'Naïve',
'Old',
'Powerful',
'Quiet',
'Rich',
'Superman',
'THU',
'Undefined',
'Valuable',
'Wifeless',
'Xiangbuchulai',
'Young',
'Zombie']
TOTAL = len(NAMES) * len(PREFIXIES)
COLORS = 13
GOLD_RATIO = 0.618033988749895
# Old Version
# for color in range(COLORS):
# i = color
# while i < TOTAL:
# prefix = PREFIXIES[i // len(NAMES)]
# if prefix:
# prefix += ' '
# print(prefix + NAMES[i % len(NAMES)], end=',')
# i += COLORS
# print()
i = 0
everyone_color = []
for prefix in PREFIXIES:
if prefix:
prefix += ' '
for name in NAMES:
everyone_color.append((prefix + name, i))
i = (i + GOLD_RATIO) % 1
everyone_color.sort(key=lambda x: x[1])
print(','.join(x[0] for x in everyone_color))
"""
网页版树洞决定字母君的颜色
https://pkuhelper.pku.edu.cn/hole/##1264962
参考了网页版树洞的颜色生成机制,值越接近则颜色越接近。
"""
NAMES = [
"Alice",
"Bob",
"Carol",
"Dave",
"Eve",
"Francis",
"Grace",
"Hans",
"Isabella",
"Jason",
"Kate",
"Louis",
"Margaret",
"Nathan",
"Olivia",
"Paul",
"Queen",
"Richard",
"Susan",
"Thomas",
"Uma",
"Vivian",
"Winnie",
"Xander",
"Yasmine",
"Zach",
]
# 也可以选择仅用少数几个前缀
PREFIXIES = [
"",
"Angry ",
"Baby ",
"Crazy ",
"Diligent ",
"Excited ",
"Fat ",
"Greedy ",
"Hungry ",
"Interesting ",
"Jolly ",
"Kind ",
"Little ",
"Magic ",
"Naïve ",
"Old ",
"Powerful ",
"Quiet ",
"Rich ",
"Superman ",
"THU ",
"Undefined ",
"Valuable ",
"Wifeless ",
"Xiangbuchulai ",
"Young ",
"Zombie ",
]
TOTAL = len(NAMES) * len(PREFIXIES)
GOLD_RATIO = 0.618033988749895
names = [prefix + name for prefix in PREFIXIES for name in NAMES]
colors = {(GOLD_RATIO * i % 1): "" for i in range(TOTAL)}
for i, color in enumerate(sorted(colors.keys())):
colors[color] = names[i]
print("\u200b".join(colors.values()))
'''
网页版树洞 You Win 版本的渐变
https://pkuhelper.pku.edu.cn/hole/##1265265
可通过 YOUWIN_COUNT 来调节个数,更加自由。
实测 300 个效果不错
'''
GOLD_RATIO = 0.618033988749895
YOUWIN_COUNT = 300
i = 0
everyone_color = []
for youwin in range(YOUWIN_COUNT):
everyone_color.append((youwin, i))
i = (i + GOLD_RATIO) % 1
everyone_color.sort(key=lambda x: x[1])
print(','.join(f'You Win {i}' for i in range(YOUWIN_COUNT)))
print()
print(','.join(f'You Win {x[0]}' for x in everyone_color))
@AllanChain
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment