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

Commit

Permalink
fix: rgba関数のalpha指定の修正
Browse files Browse the repository at this point in the history
  • Loading branch information
PigeonsHouse committed Dec 29, 2023
1 parent cb88da1 commit 71d63bf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/style/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
from enum import Enum, auto

from definition import COLOR_LIST, COLOR_VALUE
from definition import COLOR_LIST, COLOR_VALUE, REAL_NUMBER_PATTERN
from utils import VSMLManager


Expand Down Expand Up @@ -324,15 +324,16 @@ def __init__(self, val: str) -> None:
elif val[:5] == "rgba(":
self.type = ColorType.HEX
find_val = re.findall(
r"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)",
r"rgba\(\s*(\d+)\s*,\s*(\d+)\s*,"
r"\s*(\d+)\s*,\s*([{0}]+)\s*\)".format(REAL_NUMBER_PATTERN),
val,
)
if len(find_val) > 0:
r, g, b, a = find_val[0]
self.r_value = int(r)
self.g_value = int(g)
self.b_value = int(b)
self.a_value = int(a)
self.a_value = int(float(a) % 1.0 * 255)
self.value = "#{}{}{}{}".format(
format(self.r_value, "x").zfill(2),
format(self.g_value, "x").zfill(2),
Expand Down

0 comments on commit 71d63bf

Please sign in to comment.