How to use the pysubs2.common.Color function in pysubs2

To help you get started, we’ve selected a few pysubs2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tkarabela / pysubs2 / pysubs2 / substation.py View on Github external
def ssa_rgb_to_color(s):
    x = int(s)
    r = x & 0xff
    g = (x >> 8) & 0xff
    b = (x >> 16) & 0xff
    return Color(r, g, b)
github tkarabela / pysubs2 / pysubs2 / substation.py View on Github external
def ass_rgba_to_color(s):
    x = int(s[2:], base=16)
    r = x & 0xff
    g = (x >> 8) & 0xff
    b = (x >> 16) & 0xff
    a = (x >> 24) & 0xff
    return Color(r, g, b, a)
github tkarabela / pysubs2 / pysubs2 / ssastyle.py View on Github external
def __init__(self, **fields):
        self.fontname = "Arial" #: Font name
        self.fontsize = 20.0 #: Font size (in pixels)
        self.primarycolor = Color(255, 255, 255, 0) #: Primary color (:class:`pysubs2.Color` instance)
        self.secondarycolor = Color(255, 0, 0, 0) #: Secondary color (:class:`pysubs2.Color` instance)
        self.tertiarycolor = Color(0, 0, 0, 0) #: Tertiary color (:class:`pysubs2.Color` instance)
        self.outlinecolor = Color(0, 0, 0, 0) #: Outline color (:class:`pysubs2.Color` instance)
        self.backcolor = Color(0, 0, 0, 0) #: Back, ie. shadow color (:class:`pysubs2.Color` instance)
        self.bold = False #: Bold
        self.italic = False #: Italic
        self.underline = False #: Underline (ASS only)
        self.strikeout = False #: Strikeout (ASS only)
        self.scalex = 100.0 #: Horizontal scaling (ASS only)
        self.scaley = 100.0 #: Vertical scaling (ASS only)
        self.spacing = 0.0 #: Letter spacing (ASS only)
        self.angle = 0.0 #: Rotation (ASS only)
        self.borderstyle = 1 #: Border style
        self.outline = 2.0 #: Outline width (in pixels)
        self.shadow = 2.0 #: Shadow depth (in pixels)
        self.alignment = 2 #: Numpad-style alignment, eg. 7 is "top left" (that is, ASS alignment semantics)
        self.marginl = 10 #: Left margin (in pixels)
        self.marginr = 10 #: Right margin (in pixels)
github tkarabela / pysubs2 / pysubs2 / ssastyle.py View on Github external
def __init__(self, **fields):
        self.fontname = "Arial" #: Font name
        self.fontsize = 20.0 #: Font size (in pixels)
        self.primarycolor = Color(255, 255, 255, 0) #: Primary color (:class:`pysubs2.Color` instance)
        self.secondarycolor = Color(255, 0, 0, 0) #: Secondary color (:class:`pysubs2.Color` instance)
        self.tertiarycolor = Color(0, 0, 0, 0) #: Tertiary color (:class:`pysubs2.Color` instance)
        self.outlinecolor = Color(0, 0, 0, 0) #: Outline color (:class:`pysubs2.Color` instance)
        self.backcolor = Color(0, 0, 0, 0) #: Back, ie. shadow color (:class:`pysubs2.Color` instance)
        self.bold = False #: Bold
        self.italic = False #: Italic
        self.underline = False #: Underline (ASS only)
        self.strikeout = False #: Strikeout (ASS only)
        self.scalex = 100.0 #: Horizontal scaling (ASS only)
        self.scaley = 100.0 #: Vertical scaling (ASS only)
        self.spacing = 0.0 #: Letter spacing (ASS only)
        self.angle = 0.0 #: Rotation (ASS only)
        self.borderstyle = 1 #: Border style
        self.outline = 2.0 #: Outline width (in pixels)
        self.shadow = 2.0 #: Shadow depth (in pixels)
        self.alignment = 2 #: Numpad-style alignment, eg. 7 is "top left" (that is, ASS alignment semantics)
        self.marginl = 10 #: Left margin (in pixels)
github tkarabela / pysubs2 / pysubs2 / ssastyle.py View on Github external
def __init__(self, **fields):
        self.fontname = "Arial" #: Font name
        self.fontsize = 20.0 #: Font size (in pixels)
        self.primarycolor = Color(255, 255, 255, 0) #: Primary color (:class:`pysubs2.Color` instance)
        self.secondarycolor = Color(255, 0, 0, 0) #: Secondary color (:class:`pysubs2.Color` instance)
        self.tertiarycolor = Color(0, 0, 0, 0) #: Tertiary color (:class:`pysubs2.Color` instance)
        self.outlinecolor = Color(0, 0, 0, 0) #: Outline color (:class:`pysubs2.Color` instance)
        self.backcolor = Color(0, 0, 0, 0) #: Back, ie. shadow color (:class:`pysubs2.Color` instance)
        self.bold = False #: Bold
        self.italic = False #: Italic
        self.underline = False #: Underline (ASS only)
        self.strikeout = False #: Strikeout (ASS only)
        self.scalex = 100.0 #: Horizontal scaling (ASS only)
        self.scaley = 100.0 #: Vertical scaling (ASS only)
        self.spacing = 0.0 #: Letter spacing (ASS only)
        self.angle = 0.0 #: Rotation (ASS only)
        self.borderstyle = 1 #: Border style
        self.outline = 2.0 #: Outline width (in pixels)
        self.shadow = 2.0 #: Shadow depth (in pixels)
        self.alignment = 2 #: Numpad-style alignment, eg. 7 is "top left" (that is, ASS alignment semantics)
        self.marginl = 10 #: Left margin (in pixels)
        self.marginr = 10 #: Right margin (in pixels)
        self.marginv = 10 #: Vertical margin (in pixels)
        self.alphalevel = 0 #: Old, unused SSA-only field
github tkarabela / pysubs2 / pysubs2 / substation.py View on Github external
def field_to_string(f, v):
            if f in {"start", "end"}:
                return ms_to_timestamp(v)
            elif f == "marked":
                return "Marked=%d" % v
            elif f == "alignment" and format_ == "ssa":
                return text_type(ass_to_ssa_alignment(v))
            elif isinstance(v, bool):
                return "-1" if v else "0"
            elif isinstance(v, (text_type, Number)):
                return text_type(v)
            elif isinstance(v, Color):
                if format_ == "ass":
                    return color_to_ass_rgba(v)
                else:
                    return color_to_ssa_rgb(v)
            else:
                raise TypeError("Unexpected type when writing a SubStation field")
github tkarabela / pysubs2 / pysubs2 / ssastyle.py View on Github external
def __init__(self, **fields):
        self.fontname = "Arial" #: Font name
        self.fontsize = 20.0 #: Font size (in pixels)
        self.primarycolor = Color(255, 255, 255, 0) #: Primary color (:class:`pysubs2.Color` instance)
        self.secondarycolor = Color(255, 0, 0, 0) #: Secondary color (:class:`pysubs2.Color` instance)
        self.tertiarycolor = Color(0, 0, 0, 0) #: Tertiary color (:class:`pysubs2.Color` instance)
        self.outlinecolor = Color(0, 0, 0, 0) #: Outline color (:class:`pysubs2.Color` instance)
        self.backcolor = Color(0, 0, 0, 0) #: Back, ie. shadow color (:class:`pysubs2.Color` instance)
        self.bold = False #: Bold
        self.italic = False #: Italic
        self.underline = False #: Underline (ASS only)
        self.strikeout = False #: Strikeout (ASS only)
        self.scalex = 100.0 #: Horizontal scaling (ASS only)
        self.scaley = 100.0 #: Vertical scaling (ASS only)
        self.spacing = 0.0 #: Letter spacing (ASS only)
        self.angle = 0.0 #: Rotation (ASS only)
        self.borderstyle = 1 #: Border style
        self.outline = 2.0 #: Outline width (in pixels)
        self.shadow = 2.0 #: Shadow depth (in pixels)
        self.alignment = 2 #: Numpad-style alignment, eg. 7 is "top left" (that is, ASS alignment semantics)
        self.marginl = 10 #: Left margin (in pixels)
        self.marginr = 10 #: Right margin (in pixels)
        self.marginv = 10 #: Vertical margin (in pixels)