Package csb :: Package bio :: Package io :: Module clans :: Class Color |
[frames] | no frames]

# Class Color

source code

    object --+
             |
            Color

RGB color handling class. Color is stored as r, g, b, and a (i.e. alpha) attributes. Default color is `r`=`g`=`b`=0 (i.e. black) with a=255

Instance Methods
__init__(self, r=0, g=0, b=0, a=255) x.__init__(...) initializes x; see help(type(x)) for signature | source code
__repr__(self) str(x) | source code
__str__(self) str(x) | source code
str |
to_clans_color(self) Formats the color for use in CLANS files. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__subclasshook__`

Static Methods
from_string(color_string, separator=`'``;``'`) Factory for a Color instance created from a string formatted as r{separator}g{separator}b{separator}a, where the final '{separator}a' is optional. | source code

Properties
int | a the alpha value of the RGB color.
int | b the blue value of the RGB color.
int | g the green value of the RGB color.
int | r the red value of the RGB color.
Inherited from `object`: `__class__`

Method Details

### __init__(self, r=0, g=0, b=0, a=255) (Constructor) | source code
x.__init__(...) initializes x; see help(type(x)) for signature Parameters: `r` (int) - the red value `g` (int) - the green value `b` (int) - the blue value `a` (int) - the alpha value Overrides: object.__init__ (inherited documentation)

### __repr__(self) (Representation operator) | source code
str(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

### from_string(color_string, separator=`'``;``'`) Static Method | source code
Factory for a Color instance created from a string formatted as r{separator}g{separator}b{separator}a, where the final '{separator}a' is optional. Parameters: `color_string` (str) - the color string Raises: `TypeError` - if `color_string` is not a string `ValueError` - if any value in color is outside of range(256)

### to_clans_color(self) | source code
Formats the color for use in CLANS files. Returns: str the color formatted for use in CLANS files; format: r;g;b;a

Property Details

### a the alpha value of the RGB color. raises ValueError if `value` is outside of range(256) Get Method: unreachable.a(self) - the alpha value of the RGB color. Set Method: unreachable.a(self, value) Type: int

### b the blue value of the RGB color. raises ValueError if `value` is outside of range(256) Get Method: unreachable.b(self) - the blue value of the RGB color. Set Method: unreachable.b(self, value) Type: int

### g the green value of the RGB color. raises ValueError if `value` is outside of range(256) Get Method: unreachable.g(self) - the green value of the RGB color. Set Method: unreachable.g(self, value) Type: int

### r the red value of the RGB color. raises ValueError if `value` is outside of range(256) Get Method: unreachable.r(self) - the red value of the RGB color. Set Method: unreachable.r(self, value) - Set the red value of the RGB color. Type: int