2021-07-14 23:13:28 +00:00
|
|
|
from dataclasses import dataclass
|
|
|
|
from typing import Union
|
2018-10-31 16:08:29 +00:00
|
|
|
|
|
|
|
|
2021-07-14 23:13:28 +00:00
|
|
|
@dataclass(init=False)
|
|
|
|
class Color:
|
2018-10-31 16:08:29 +00:00
|
|
|
"""
|
2021-07-14 23:13:28 +00:00
|
|
|
8-bit RGB color with alpha channel.
|
2018-10-31 16:08:29 +00:00
|
|
|
|
|
|
|
All values are ints from 0 to 255.
|
|
|
|
"""
|
2021-07-14 23:13:28 +00:00
|
|
|
r: int
|
|
|
|
g: int
|
|
|
|
b: int
|
|
|
|
a: int = 0
|
|
|
|
|
|
|
|
def __init__(self, r: int, g: int, b: int, a: int = 0):
|
2018-10-31 16:08:29 +00:00
|
|
|
for value in r, g, b, a:
|
|
|
|
if value not in range(256):
|
|
|
|
raise ValueError("Color channels must have values 0-255")
|
|
|
|
|
2021-07-14 23:13:28 +00:00
|
|
|
self.r = r
|
|
|
|
self.g = g
|
|
|
|
self.b = b
|
|
|
|
self.a = a
|
2018-10-31 16:08:29 +00:00
|
|
|
|
|
|
|
|
2021-07-14 23:13:28 +00:00
|
|
|
#: Version of the pysubs2 library.
|
2022-11-07 18:06:49 +00:00
|
|
|
VERSION = "1.4.4"
|
2018-10-31 16:08:29 +00:00
|
|
|
|
|
|
|
|
2021-07-14 23:13:28 +00:00
|
|
|
IntOrFloat = Union[int, float]
|