|
| 1 | +from typing import Literal, Self |
| 2 | + |
| 3 | +from pptx.enum.dml import MSO_COLOR_TYPE, MSO_THEME_COLOR, MSO_THEME_COLOR_INDEX |
| 4 | +from pptx.oxml.dml.color import CT_Color, CT_SRgbColor, _BaseColorElement |
| 5 | + |
| 6 | +class ColorFormat: |
| 7 | + """ |
| 8 | + Provides access to color settings such as RGB color, theme color, and |
| 9 | + luminance adjustments. |
| 10 | + """ |
| 11 | + def __init__(self, eg_colorChoice_parent: CT_Color, color: _Color) -> None: ... |
| 12 | + @property |
| 13 | + def brightness(self) -> float: |
| 14 | + """ |
| 15 | + Read/write float value between -1.0 and 1.0 indicating the brightness |
| 16 | + adjustment for this color, e.g. -0.25 is 25% darker and 0.4 is 40% |
| 17 | + lighter. 0 means no brightness adjustment. |
| 18 | + """ |
| 19 | + ... |
| 20 | + |
| 21 | + @brightness.setter |
| 22 | + def brightness(self, value: float) -> None: ... |
| 23 | + @classmethod |
| 24 | + def from_colorchoice_parent(cls, eg_colorChoice_parent: CT_Color) -> Self: ... |
| 25 | + @property |
| 26 | + def rgb(self) -> RGBColor: |
| 27 | + """ |
| 28 | + |RGBColor| value of this color, or None if no RGB color is explicitly |
| 29 | + defined for this font. Setting this value to an |RGBColor| instance |
| 30 | + causes its type to change to MSO_COLOR_TYPE.RGB. If the color was a |
| 31 | + theme color with a brightness adjustment, the brightness adjustment |
| 32 | + is removed when changing it to an RGB color. |
| 33 | + """ |
| 34 | + ... |
| 35 | + |
| 36 | + @rgb.setter |
| 37 | + def rgb(self, rgb: RGBColor) -> None: ... |
| 38 | + @property |
| 39 | + def theme_color(self) -> MSO_THEME_COLOR_INDEX: |
| 40 | + """Theme color value of this color. |
| 41 | +
|
| 42 | + Value is a member of :ref:`MsoThemeColorIndex`, e.g. |
| 43 | + ``MSO_THEME_COLOR.ACCENT_1``. Raises AttributeError on access if the |
| 44 | + color is not type ``MSO_COLOR_TYPE.SCHEME``. Assigning a member of |
| 45 | + :ref:`MsoThemeColorIndex` causes the color's type to change to |
| 46 | + ``MSO_COLOR_TYPE.SCHEME``. |
| 47 | + """ |
| 48 | + ... |
| 49 | + |
| 50 | + @theme_color.setter |
| 51 | + def theme_color(self, mso_theme_color_idx: MSO_THEME_COLOR_INDEX) -> None: ... |
| 52 | + @property |
| 53 | + def type(self) -> MSO_COLOR_TYPE: |
| 54 | + """ |
| 55 | + Read-only. A value from :ref:`MsoColorType`, either RGB or SCHEME, |
| 56 | + corresponding to the way this color is defined, or None if no color |
| 57 | + is defined at the level of this font. |
| 58 | + """ |
| 59 | + ... |
| 60 | + |
| 61 | +class _Color: |
| 62 | + """ |
| 63 | + Object factory for color object of the appropriate type, also the base |
| 64 | + class for all color type classes such as SRgbColor. |
| 65 | + """ |
| 66 | + def __new__(cls, xClr: _BaseColorElement | None) -> Self: ... |
| 67 | + def __init__(self, xClr: _BaseColorElement | None) -> None: ... |
| 68 | + @property |
| 69 | + def brightness(self) -> float: ... |
| 70 | + @brightness.setter |
| 71 | + def brightness(self, value: float) -> None: ... |
| 72 | + @property |
| 73 | + def color_type(self) -> MSO_COLOR_TYPE: ... |
| 74 | + @property |
| 75 | + def rgb(self) -> RGBColor: |
| 76 | + """ |
| 77 | + Raises TypeError on access unless overridden by subclass. |
| 78 | + """ |
| 79 | + ... |
| 80 | + |
| 81 | + @property |
| 82 | + def theme_color(self) -> Literal[MSO_THEME_COLOR_INDEX.NOT_THEME_COLOR]: |
| 83 | + """ |
| 84 | + Raises TypeError on access unless overridden by subclass. |
| 85 | + """ |
| 86 | + ... |
| 87 | + |
| 88 | +class _HslColor(_Color): |
| 89 | + @property |
| 90 | + def color_type(self) -> Literal[MSO_COLOR_TYPE.HSL]: ... |
| 91 | + |
| 92 | +class _NoneColor(_Color): |
| 93 | + @property |
| 94 | + def color_type(self) -> None: ... |
| 95 | + @property |
| 96 | + def theme_color(self): |
| 97 | + """ |
| 98 | + Raise TypeError on attempt to access .theme_color when no color |
| 99 | + choice is present. |
| 100 | + """ |
| 101 | + ... |
| 102 | + |
| 103 | +class _PrstColor(_Color): |
| 104 | + @property |
| 105 | + def color_type(self) -> Literal[MSO_COLOR_TYPE.PRESET]: ... |
| 106 | + |
| 107 | +class _SchemeColor(_Color): |
| 108 | + def __init__(self, schemeClr) -> None: ... |
| 109 | + @property |
| 110 | + def color_type(self) -> Literal[MSO_COLOR_TYPE.SCHEME]: ... |
| 111 | + @property |
| 112 | + def theme_color(self) -> MSO_THEME_COLOR | None: |
| 113 | + """ |
| 114 | + Theme color value of this color, one of those defined in the |
| 115 | + MSO_THEME_COLOR enumeration, e.g. MSO_THEME_COLOR.ACCENT_1. None if |
| 116 | + no theme color is explicitly defined for this font. Setting this to a |
| 117 | + value in MSO_THEME_COLOR causes the color's type to change to |
| 118 | + ``MSO_COLOR_TYPE.SCHEME``. |
| 119 | + """ |
| 120 | + ... |
| 121 | + |
| 122 | + @theme_color.setter |
| 123 | + def theme_color(self, mso_theme_color_idx: MSO_THEME_COLOR) -> None: ... |
| 124 | + |
| 125 | +class _ScRgbColor(_Color): |
| 126 | + @property |
| 127 | + def color_type(self) -> Literal[MSO_COLOR_TYPE.SCRGB]: ... |
| 128 | + |
| 129 | +class _SRgbColor(_Color): |
| 130 | + def __init__(self, srgbClr: CT_SRgbColor) -> None: ... |
| 131 | + @property |
| 132 | + def color_type(self) -> Literal[MSO_COLOR_TYPE.RGB]: ... |
| 133 | + @property |
| 134 | + def rgb(self) -> RGBColor: |
| 135 | + """ |
| 136 | + |RGBColor| value of this color, corresponding to the value in the |
| 137 | + required ``val`` attribute of the ``<a:srgbColr>`` element. |
| 138 | + """ |
| 139 | + ... |
| 140 | + |
| 141 | + @rgb.setter |
| 142 | + def rgb(self, rgb) -> None: ... |
| 143 | + |
| 144 | +class _SysColor(_Color): |
| 145 | + @property |
| 146 | + def color_type(self) -> Literal[MSO_COLOR_TYPE.SYSTEM]: ... |
| 147 | + |
| 148 | +class RGBColor(tuple[int, int, int]): |
| 149 | + """ |
| 150 | + Immutable value object defining a particular RGB color. |
| 151 | + """ |
| 152 | + def __new__(cls, r: int, g: int, b: int) -> Self: ... |
| 153 | + def __str__(self) -> str: |
| 154 | + """ |
| 155 | + Return a hex string rgb value, like '3C2F80' |
| 156 | + """ |
| 157 | + ... |
| 158 | + |
| 159 | + @classmethod |
| 160 | + def from_string(cls, rgb_hex_str: str) -> Self: |
| 161 | + """ |
| 162 | + Return a new instance from an RGB color hex string like ``'3C2F80'``. |
| 163 | + """ |
| 164 | + ... |
0 commit comments