smartinspectpython.sicolor

Module: sicolor.py

Revision History

Date Version Description
2023/09/27 3.0.21.0 Changed initialiation method to accept either an integer or SIColors enum for value argument.
2023/09/03 3.0.20.0 Changed all alpha byte from 0xFF to 0x00 for all color definitions.
2023/05/30 3.0.0.0 Initial Version.

@export
class SIColor:

Mimics the System.Drawing.Color class functionality.

SIColor(value: int)

Initializes a new instance of the class using a supplied known color value that represents the four ARGB components (alpha, red, green, and blue).

Arguments:
  • value (int): Integer value that represents the ARGB components of the color.
A: int

Gets the alpha component value of this color structure.

0 is fully transparent, and 255 is fully opaque.

B: int

Gets the blue component value of this SIColor structure.

G: int

Gets the green component value of this SIColor structure.

Name: str

Gets the name of the color, if it's a known color value.

R: int

Gets the red component value of this SIColor structure.

Value: int

Gets the raw value of the color in integer form.

ValueHex: int

Gets the raw value of the color in hexadecimal form.

Returns a string value in the form of 0xAARRBBGG (e.g. 0x00FF0000).

@staticmethod
def CheckByte(value: int, name: str) -> None:

Ensures the value for the named parameter (A,R,G, or B) is between 0 through 255.

Arguments:
  • value (int): The value to check.
  • name (str): The descriptove name of the value, used to identify the value in case of an exception.
@staticmethod
def FromArgb(alpha: int, red: int, green: int, blue: int):

Creates a SIColor structure from the four ARGB component (alpha, red, green, and blue) values. Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits.

Arguments:
  • alpha (int): The alpha component. Valid values are 0 (fully transparent) through 255 (fully opaque).
  • red (int): The red component. Valid values are 0 through 255.
  • green (int): The green component. Valid values are 0 through 255.
  • blue (int): The blue component. Valid values are 0 through 255.
Returns:

The SIColor that this method creates.

Raises:
  • ArgumentException: alpha, red, green, or blue is less than 0 or greater than 255.
@staticmethod
def FromRgb(red: int, green: int, blue: int):

Creates a SIColor structure from the three RGB component (red, green, and blue) values. Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits. The alpha value is implicitly 255 (fully opaque).

Arguments:
  • red (int): The red component. Valid values are 0 through 255.
  • green (int): The green component. Valid values are 0 through 255.
  • blue (int): The blue component. Valid values are 0 through 255.
Returns:

The SIColor that this method creates.

Raises:
  • ArgumentException: red, green, or blue is less than 0 or greater than 255.
def ToArgb(self) -> int:

Gets the 32-bit ARGB value of this color structure.

@export
class SIColors(enum.Enum):

Pre-defined known color values.

AliceBlue = <SIColors.AliceBlue: 15792383>

System-defined color that has an ARGB value of #FFF0F8FF.

AntiqueWhite = <SIColors.AntiqueWhite: 16444375>

Gets a system-defined color that has an ARGB value of #FFFAEBD7.

Coral = <SIColors.Coral: 16744272>

Gets a system-defined color that has an ARGB value of #FFFF7F50.

CornflowerBlue = <SIColors.CornflowerBlue: 6591981>

Gets a system-defined color that has an ARGB value of #FF6495ED.

DarkBlue = <SIColors.DarkBlue: 139>

Gets a system-defined color that has an ARGB value of #FF00008B.

DarkCyan = <SIColors.DarkCyan: 35723>

Gets a system-defined color that has an ARGB value of #FF008B8B.

DarkGray = <SIColors.DarkGray: 11119017>

Gets a system-defined color that has an ARGB value of #FFA9A9A9.

DarkOrange = <SIColors.DarkOrange: 16747520>

Gets a system-defined color that has an ARGB value of #FFFF8C00.

DeepSkyBlue = <SIColors.DeepSkyBlue: 49151>

Gets a system-defined color that has an ARGB value of #FF00BFFF.

DimGray = <SIColors.DimGray: 6908265>

Gets a system-defined color that has an ARGB value of #FF696969.

ForestGreen = <SIColors.ForestGreen: 2263842>

Gets a system-defined color that has an ARGB value of #.

Gainsboro = <SIColors.Gainsboro: 14474460>

Gets a system-defined color that has an ARGB value of #FFDCDCDC.

Gold = <SIColors.Gold: 16766720>

Gets a system-defined color that has an ARGB value of #.

Green = <SIColors.Green: 32768>

Gets a system-defined color that has an ARGB value of #FF008000.

Khaki = <SIColors.Khaki: 15787660>

Gets a system-defined color that has an ARGB value of #FFF0E68C.

Lavender = <SIColors.Lavender: 15132410>

Gets a system-defined color that has an ARGB value of #FFE6E6FA.

LightBlue = <SIColors.LightBlue: 11393254>

Gets a system-defined color that has an ARGB value of #FFADD8E6.

LightCoral = <SIColors.LightCoral: 15761536>

Gets a system-defined color that has an ARGB value of #FFF08080.

LightGreen = <SIColors.LightGreen: 9498256>

Gets a system-defined color that has an ARGB value of #FF90EE90.

LightGray = <SIColors.LightGray: 13882323>

Gets a system-defined color that has an ARGB value of #FFD3D3D3.

LightSkyBlue = <SIColors.LightSkyBlue: 8900346>

Gets a system-defined color that has an ARGB value of #FF87CEFA.

Orange = <SIColors.Orange: 16753920>

Gets a system-defined color that has an ARGB value of #FFFFA500.

Red = <SIColors.Red: 16711680>

Gets a system-defined color that has an ARGB value of #FFFF0000.

SaddleBrown = <SIColors.SaddleBrown: 9127187>

Gets a system-defined color that has an ARGB value of #FF8B4513.

SeaGreen = <SIColors.SeaGreen: 3050327>

Gets a system-defined color that has an ARGB value of #FF2E8B57.

Silver = <SIColors.Silver: 12632256>

Gets a system-defined color that has an ARGB value of #FFC0C0C0.

SkyBlue = <SIColors.SkyBlue: 8900331>

Gets a system-defined color that has an ARGB value of #FF87CEEB.

SlateGray = <SIColors.SlateGray: 7372944>

Gets a system-defined color that has an ARGB value of #FF708090.

Tan = <SIColors.Tan: 13808780>

Gets a system-defined color that has an ARGB value of #FFD2B48C.

White = <SIColors.White: 16777215>

Gets a system-defined color that has an ARGB value of #FFFFFFFF.

WhiteSmoke = <SIColors.WhiteSmoke: 16119285>

Gets a system-defined color that has an ARGB value of #FFF5F5F5.

Yellow = <SIColors.Yellow: 16776960>

Gets a system-defined color that has an ARGB value of #FFFFFF00.