[O] Fix weights

#451
This commit is contained in:
Azalea 2025-10-22 09:53:46 +08:00
parent e788f93c2b
commit 67ae918ae8
2 changed files with 237 additions and 226 deletions

View file

@ -1,5 +1,4 @@
{
"presets": {
"rainbow": ["#E50000", "#FF8D00", "#FFEE00", "#028121", "#004CFF", "#770088"],
"transgender": ["#55CDFD", "#F6AAB7", "#FFFFFF", "#F6AAB7", "#55CDFD"],
"nonbinary": ["#FCF431", "#FCFCFC", "#9D59D2", "#282828"],
@ -89,7 +88,7 @@
},
"boyflux2": {
"colors": ["#E48AE4", "#9A81B4", "#55BFAB", "#FFFFFF", "#A8A8A8", "#81D5EF", "#69ABE5", "#5276D4"],
"comment": "i didn't expect this one to work. cool!"
"weights": [1, 1, 1, 1, 1, 5, 5, 5]
},
"girlflux": {
"colors": ["#F9E6D7", "#F2526C", "#BF0311", "#E9C587", "#BF0311", "#F2526C", "#F9E6D7"],
@ -113,7 +112,10 @@
"unlabeled2": ["#250548", "#FFFFFF", "#F7DCDA", "#EC9BEE", "#9541FA", "#7D2557"],
"pangender": ["#FFF798", "#FEDDCD", "#FFEBFB", "#FFFFFF", "#FFEBFB", "#FEDDCD", "#FFF798"],
"pangender.contrast": ["#FFE87F", "#FCBAA6", "#FBC9F3", "#FFFFFF", "#FBC9F3", "#FCBAA6", "#FFE87F"],
"gendernonconforming1": ["#50284D", "#96467B", "#5C96F7", "#FFE6F7", "#5C96F7", "#96467B", "#50284D"],
"gendernonconforming1": {
"colors": ["#50284D", "#96467B", "#5C96F7", "#FFE6F7", "#5C96F7", "#96467B", "#50284D"],
"weights": [4, 1, 1, 1, 1, 1, 4]
},
"gendernonconforming2": ["#50284D", "#96467B", "#5C96F7", "#FFE6F7", "#5C96F7", "#96467B", "#50284D"],
"femboy": ["#D260A5", "#E4AFCD", "#FEFEFE", "#57CEF8", "#FEFEFE", "#E4AFCD", "#D260A5"],
"tomboy": ["#2F3FB9", "#613A03", "#FEFEFE", "#F1A9B7", "#FEFEFE", "#613A03", "#2F3FB9"],
@ -223,4 +225,3 @@
"throatlozenges": ["#2759DA", "#03940D", "#F5F100", "#F59B00", "#B71212"],
"band": ["#2670C0", "#F5BD00", "#DC0045", "#E0608E"]
}
}

View file

@ -22,6 +22,16 @@ class ColorProfile:
colors: list[RGB]
spacing: ColorSpacing = 'equal'
@staticmethod
def from_json(data: list | dict) -> 'ColorProfile':
if isinstance(data, list):
return ColorProfile(data)
else:
pf = ColorProfile(data['colors'])
if 'weights' in data:
pf = ColorProfile(pf.with_weights(data['weights']))
return pf
def __init__(self, colors: list[str] | list[RGB]):
if isinstance(colors[0], str):
self.raw = colors
@ -166,6 +176,6 @@ class ColorProfile:
PRESETS: dict[str, ColorProfile] = {
k: (ColorProfile(v) if isinstance(v, list) else ColorProfile(v['colors']))
for k, v in json.loads((SRC / 'data/presets.json').read_text('utf-8'))['presets'].items()
k: ColorProfile.from_json(v)
for k, v in json.loads((SRC / 'data/presets.json').read_text('utf-8')).items()
}