-
Notifications
You must be signed in to change notification settings - Fork 1
/
hair_color_formula.py
95 lines (82 loc) · 3.31 KB
/
hair_color_formula.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# hair_color_formula.py
def choose_developer(desired_lift, hair_condition):
if desired_lift <= 2:
developer = '10vol'
elif desired_lift == 2:
developer = '20vol'
elif desired_lift == 3:
developer = '30vol'
elif desired_lift >= 4:
developer = '40vol'
if hair_condition == 'damaged' and developer == '40vol':
developer = '30vol'
return developer
def get_grey_coverage_formula(grey_percentage, coverage_type):
grey_coverage_formulas = {
'full': {
25: '30g Natural, 10g Intense Natural, 60mL 20vol',
50: '20g Natural, 20g Intense Natural, 60mL 20vol',
75: '10g Natural, 30g Intense Natural, 30mL 10vol, 30mL 20vol',
100: '10g Natural, 30g Intense Natural, 60mL 10vol'
},
'blended': {
25: '40g Pre-Blended, 60mL 20vol',
50: '10g Natural, 30g Pre-Blended, 60mL 20vol',
75: '20g Natural, 20g Pre-Blended, 60mL 20vol',
100: '20g Natural, 20g Pre-Blended, 30mL 10vol, 30mL 20vol'
}
}
formula = grey_coverage_formulas.get(coverage_type, {}).get(grey_percentage, '')
return formula
def choose_push_tone(natural_level, desired_level, desired_tone):
def choose_push_tone(natural_level, desired_level, desired_tone):
# Look up the natural remaining pigment for the desired level
def natural_remaining_pigment = get_natural_remaining_pigment(desired_level)
def get_natural_remaining_pigment(level):
# Map hair levels to their natural remaining pigments
natural_remaining_pigments = {
1: .6,
2: .6,
3: .6,
4: .6,
5: .6,
6: .6/.4,
7: .4,
8: .4/.3,
9: .3,
10: .3,
}
# Return the natural remaining pigment for the input level
return natural_remaining_pigments.get(level)
# Determine the amount of push tone needed
level_difference = desired_level - natural_level
if level_difference <= 2:
push_tone_amount = get_push_tone_amount(desired_level, 'Light (g)')
elif 2 < level_difference <= 3:
push_tone_amount = get_push_tone_amount(desired_level, 'Standard (g)')
else:
push_tone_amount = get_push_tone_amount(desired_level, 'Saturated (g)')
# If the desired tone is 'neutral' or 'cool', adjust the push tone anount
if desired_tone in ['neutral', 'cool']:
complementary_color = get_complementary_color(natural_remaining_pigment)
push_tone_code = adjust_push_tone_code(complementary_color)
if desired_tone == 'cool':
push_tone_amount = get_push_tone_amount(desired_level, 'Saturated (g)')
else:
push_tone_code = adjust_push_tone_code(desired_tone)
return {'Push Tone': push_tone_code, 'Amount (g)': push_tone_amount}
return push_tone_info
def get_complementary_color(color):
...
return complementary_color
def adjust_push_tone_code(color):
...
return push_tone_code
def get_push_tone_amount(level, amount_type):
...
return amount
def create_hair_color_formula(natural_level, desired_level, desired_tone, grey_percentage, coverage_type, hair_condition, desired_result, desired_color):
...
return formula
# Test the create_hair_color_formula function
print(create_hair_color_formula(1, 5, 'neutral', 25, 'full', 'normal', 'vibrant', 'blue'))