Skip to content
This repository has been archived by the owner on Jul 6, 2024. It is now read-only.

Commit

Permalink
fix: Colorのrgb, rgba関数のバグ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
PigeonsHouse committed Dec 26, 2023
1 parent 0c83ae9 commit 16304cb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/style/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,37 +260,37 @@ def __init__(self, val: str) -> None:
elif val[:4] == "rgb(":
self.type = ColorType.HEX
find_val = re.findall(
r"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,(\d+)\s*\)",
r"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)",
val,
)
if len(find_val) > 0:
r, g, b = find_val[0]
self.value = "#{}{}{}".format(
format(r, "x").zfill(2),
format(g, "x").zfill(2),
format(b, "x").zfill(2),
)
self.r_value = int(r)
self.g_value = int(g)
self.b_value = int(b)
self.value = "#{}{}{}".format(
format(self.r_value, "x").zfill(2),
format(self.g_value, "x").zfill(2),
format(self.b_value, "x").zfill(2),
)
elif val[:5] == "rgba(":
self.type = ColorType.HEX
find_val = re.findall(
r"rgb\(\s*(\d+)\s*,\s*(\d+)\s*,(\d+)\s*,(\d+)\s*\)",
r"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)",
val,
)
if len(find_val) > 0:
r, g, b, a = find_val[0]
self.value = "#{}{}{}{}".format(
format(r, "x").zfill(2),
format(g, "x").zfill(2),
format(b, "x").zfill(2),
format(a, "x").zfill(2),
)
self.r_value = int(r)
self.g_value = int(g)
self.b_value = int(b)
self.a_value = int(a)
self.value = "#{}{}{}{}".format(
format(self.r_value, "x").zfill(2),
format(self.g_value, "x").zfill(2),
format(self.b_value, "x").zfill(2),
format(self.a_value, "x").zfill(2),
)
else:
raise ValueError()

Expand Down

0 comments on commit 16304cb

Please sign in to comment.