Skip to content

Commit

Permalink
Change Contrast Function
Browse files Browse the repository at this point in the history
-Contrast function now returns either black or white
-updated GUI screenshot
  • Loading branch information
Nexusnui committed Oct 28, 2023
1 parent 9cfa2f4 commit 31a71dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions app/brickcolor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,13 @@ def get_color_info_by_id(id: str):
return found_color

def get_contrast_color(rgb_values: str):
red = hex_switch(rgb_values[1:3])
green = hex_switch(rgb_values[3:5])
blue = hex_switch(rgb_values[5:7])

return f"#{''.join([red, green, blue])}"


def hex_switch(hex_val: str):
if int(hex_val, 16) < 128:
return "FF"
r = 0 if int(rgb_values[1:3], 16) < 128 else 1
g = 0 if int(rgb_values[3:5], 16) < 128 else 1
b = 0 if int(rgb_values[5:7], 16) < 128 else 1
if r+g+b < 2:
return "#FFFFFF"
else:
return "00"
return "#000000"


def get_complementary_color(rgb_values: str):
Expand Down
Binary file modified graphical_userinterface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 31a71dd

Please sign in to comment.