Colors module
The gamebeye.gbcamcolors module is as its name indicates focused on colors and color space conversion. It deals with a selection of color palettes (picked and adapted from HerrZatacke gb-printer-web).
Thoses colors allowed me to make this small animation :
Animated GIF made of colorized images
gamebeye.gbcamcolors
module
This module also uses methods from gamebeye.color_helpers module
Define the GBColorPalettes enum.
- class gamebeye.gbcamcolors.GBColorPalettes(value)
Bases:
Enum
56 Pre-defined color palettes based upon Game Boy Camera known palettes.
The GBColorPalettes class inherits from Enum class where the keys are the color palette names and the valuea 4 elements array whose values represent a color coded in hexadecimal basis.
- AQPP = ['#EBEEE7', '#868779', '#FA2B25', '#2A201E']
AQPP color palette
- AZC = ['#47FF99', '#32B66D', '#124127', '#000000']
AZC color palette
- BANANA = ['#FDFE0A', '#FED638', '#977B25', '#221A09']
BANANA color palette
- BGB = ['#E0F8D0', '#88C070', '#346856', '#081820']
BGB color palette
- BLACKZERO = ['#7E8416', '#577B46', '#385D49', '#2E463D']
BLACKZERO color palette
- BW = ['#FFFFFF', '#A8A8A8', '#545454', '#000000']
BW color palette
- CCTR = ['#E6AEC4', '#E65790', '#8F0039', '#380016']
CCTR color palette
- CFP = ['#CF9255', '#CF7163', '#B01553', '#3F1711']
CFP color palette
- CGA1 = ['#FFFFFF', '#55FFFF', '#FF55FF', '#000000']
CGA1 color palette
- CGA2 = ['#FFFFFF', '#55FFFF', '#FF5555', '#000000']
CGA2 color palette
- CHIG = ['#D0D058', '#A0A840', '#708028', '#405010']
CHIG color palette
- CMYK = ['#FFFF00', '#0BE8FD', '#FB00FA', '#373737']
CMYK color palette
- CYBL = ['#9EFBE3', '#21AFF5', '#1E4793', '#0E1E3D']
CYBL color palette
- D2KR = ['#FCF1CD', '#C09E7D', '#725441', '#000000']
D2KR color palette
- DATN = ['#A9B0B3', '#586164', '#20293F', '#030C22']
DATN color palette
- DHG = ['#A1D909', '#467818', '#27421F', '#000000']
DHG color palette
- DIMWM = ['#FFDBCB', '#F27D7A', '#558429', '#222903']
DIMWM color palette
- DMG = ['#9BBC0F', '#77A112', '#306230', '#0F380F']
DMG color palette
- FFS = ['#E9D9CC', '#C5C5CE', '#75868F', '#171F62']
FFS color palette
- FSIL = ['#EAF5FA', '#5FB1F5', '#D23C4E', '#4C1C2D']
FSIL color palette
- GBCD = ['#FFFFA5', '#FE9494', '#9395FE', '#000000']
GBCD color palette
- GBCDA = ['#FFFFFF', '#FFFF00', '#FE0000', '#000000']
GBCDA color palette
- GBCDB = ['#FFFFFF', '#FFFF00', '#7D4900', '#000000']
GBCDB color palette
- GBCEUUS = ['#FFFFFF', '#7BFF30', '#0163C6', '#000000']
GBCEUUS color palette
- GBCJP = ['#FFFFFF', '#FFAD63', '#833100', '#000000']
GBCJP color palette
- GBCL = ['#FFFFFF', '#65A49B', '#0000FE', '#000000']
GBCL color palette
- GBCLA = ['#FFFFFF', '#8B8CDE', '#53528C', '#000000']
GBCLA color palette
- GBCLB = ['#FFFFFF', '#A5A5A5', '#525252', '#000000']
GBCLB color palette
- GBCR = ['#FFFFFF', '#51FF00', '#FF4200', '#000000']
GBCR color palette
- GBCRB = ['#000000', '#008486', '#FFDE00', '#FFFFFF']
GBCRB color palette
- GBCUA = ['#FFFFFF', '#FF8F84', '#943A3A', '#000000']
GBCUA color palette
- GBCUC = ['#FFE7C5', '#CE9C85', '#846B29', '#5B3109']
GBCUC color palette
- GBLIT = ['#1DDECE', '#19C7B3', '#16A596', '#0B7A6D']
GBLIT color palette
- GBPOCKET = ['#C4CFA1', '#8B956D', '#4D533C', '#1F1F1F']
GBPOCKET color palette
- GELC = ['#FF9C00', '#C27600', '#4F3000', '#000000']
GELC color palette
- GLMO = ['#FFBF98', '#A1A8B8', '#514F6C', '#2F1C35']
GLMO color palette
- GRAFIXKIDGRAY = ['#E0DBCD', '#A89F94', '#706B66', '#2B2B26']
GRAFIXKIDGRAY color palette
- GRAFIXKIDGREEN = ['#DBF4B4', '#ABC396', '#7B9278', '#4C625A']
GRAFIXKIDGREEN color palette
- HIPSTER = ['#FDFEF5', '#DEA963', '#9E754F', '#241606']
HIPSTER color palette
- KDITW = ['#FFFE6E', '#D5690F', '#3C3CA9', '#2C2410']
KDITW color palette
- LLAWK = ['#FFFFB5', '#7BC67B', '#6B8C42', '#5A3921']
LLAWK color palette
- MARMX = ['#AEDF1E', '#047E60', '#B62558', '#2C1700']
MARMX color palette
- NC = ['#FCFE54', '#54FEFC', '#04AAAC', '#0402AC']
NC color palette
- PPR = ['#ADFFFC', '#8570B2', '#FF0084', '#68006A']
PPR color palette
- RCS = ['#EDB4A1', '#A96868', '#764462', '#2C2137']
RCS color palette
- ROGA = ['#EBC4AB', '#649A57', '#574431', '#323727']
ROGA color palette
- SFH = ['#FFFF55', '#FF5555', '#881400', '#000000']
SFH color palette
- SHMGY = ['#F7E7C6', '#D68E49', '#A63725', '#331E50']
SHMGY color palette
- SHZOL = ['#F8E3C4', '#CC3495', '#6B1FB1', '#0B0630']
SHZOL color palette
- SLMEM = ['#869AD9', '#6D53BD', '#6F2096', '#4F133F']
SLMEM color palette
- SPEZI = ['#FEDA1B', '#DF7925', '#B60077', '#382977']
SPEZI color palette
- TDOYC = ['#B5FF32', '#FF2261', '#462917', '#1D1414']
TDOYC color palette
- TPA = ['#F3C677', '#E64A4E', '#912978', '#0C0A3E']
TPA color palette
- TSK = ['#F5DB37', '#37CAE5', '#0F86B6', '#123F77']
TSK color palette
- VB85 = ['#FF0000', '#DB0000', '#520000', '#000000']
VB85 color palette
- WTFP = ['#CECECE', '#6F9EDF', '#42678E', '#102533']
WTFP color palette
- YIRL = ['#CEF7F7', '#F78E50', '#9E0000', '#1E0000']
YIRL color palette
- describe() Tuple[str, list]
Describe itself. Return as a tuple the color palette name and colors.
- Returns:
a 2-values tuple containing the color name and its values
- Return type:
str, list
>>> from gamebeye.gbcamcolors.gbcamcolors import GBColorPalettes >>> GBColorPalettes.BW.describe() ('BW', ['#FFFFFF', '#A8A8A8', '#545454', '#000000'])
- property rgb_colors: List[List[int]]
Return the 4 color values of the enum in RGB space.
- Returns:
the 4 colors values in the RGB space
- Return type:
list[list[int]]
>>> from gamebeye.gbcamcolors.gbcamcolors import GBColorPalettes >>> GBColorPalettes.BW.rgb_colors [[255, 255, 255], [168, 168, 168], [84, 84, 84], [0, 0, 0]]
gamebeye.color_helpers
module
Define color conversions and methods related to 8-bits colorspaces.
- gamebeye.color_helpers.bgr_to_hex(bgr_val: List[int]) str
Convert a (B, G, R) array to hexadecimal integer.
All values are clamped between 0 and 255.
- Parameters:
bgr_val (list) – (B, G, R) to convert
- Raises:
ValueError – rgb_val argument must be a 3 values list
- Returns:
an hexadecimal value
- Return type:
str
>>> from gamebeye.gbcamcolors.color_helpers import bgr_to_hex >>> bgr_to_hex([0, 0, 0]) '#000000' >>> bgr_to_hex([0, 0, 255]) '#FF0000' >>> bgr_to_hex([255, 0, 0]) '#0000FF' >>> bgr_to_hex([512, 128, 0]) '#0080FF' >>> bgr_to_hex([0, 0, 0, 0]) Traceback (most recent call last): ... ValueError: bgr_val argument must be a 3 values list
- gamebeye.color_helpers.clamp(val: int) int
Ensure that val is between 0 and 255.
Clamp each out of bound value.
- Parameters:
val (int) – an int value
- Returns:
the clamped value
- Return type:
int
>>> from gamebeye.gbcamcolors.color_helpers import clamp >>> clamp(-125) 0 >>> clamp(0) 0 >>> clamp(125) 125 >>> clamp(255) 255 >>> clamp(512) 255
- gamebeye.color_helpers.clamp_hex(hex_val: str) str
Ensure that val is between ‘0x000000’ and ‘0xFFFFFF’.
Clamp each out of bound value.
- Parameters:
hex_val (str) – an hexadecimal string value
- Returns:
the hex clamped value
- Return type:
str
>>> from gamebeye.gbcamcolors.color_helpers import clamp_hex >>> clamp_hex('#000000') '#000000' >>> clamp_hex('#FFFFFF') '#FFFFFF' >>> clamp_hex('#00FF00') '#00FF00' >>> clamp_hex('#F000000') '#FFFFFF'
- gamebeye.color_helpers.clamp_rgb(rgb_val: List[int]) List[int]
Ensure that all RGB values are between 0 and 255.
Clamp each out of bound value.
- Parameters:
rgb_val (List[int]) – 3-channels list for R, G, B
- Raises:
ValueError – rgb_val argument must be a 3 values list
- Returns:
the clamped list
- Return type:
List[int]
>>> from gamebeye.gbcamcolors.color_helpers import clamp_rgb >>> clamp_rgb([0, 0, 0]) [0, 0, 0] >>> clamp_rgb([255, 255, 255]) [255, 255, 255] >>> clamp_rgb([512, 0, 0]) [255, 0, 0] >>> clamp_rgb([255, 255, 255, 0]) Traceback (most recent call last): ... ValueError: rgb_val argument must be a 3 values list
- gamebeye.color_helpers.hex_to_bgr(hex_val: str) List[int]
Convert a hexadecimal value to BGR values.
All values are clamped between 0 and 255.
The 2 left digits code the green value, the 2 middle digits the blue and the 2 left digits the red.
- Parameters:
hex_val (str) – hexadecimal value.
- Returns:
a list containing B, G, R values
- Return type:
a list of integer
>>> from gamebeye.gbcamcolors.color_helpers import hex_to_bgr >>> hex_to_bgr('#000000') [0, 0, 0] >>> hex_to_bgr('#FF0000') [0, 0, 255] >>> hex_to_bgr('#00FF00') [0, 255, 0] >>> hex_to_bgr('#0000FF') [255, 0, 0] >>> hex_to_bgr('#FFFFFF') [255, 255, 255] >>> hex_to_bgr('#F000000') [255, 255, 255]
- gamebeye.color_helpers.hex_to_rgb(hex_val: str) List[int]
Convert a hexadecimal value to RGB values.
All values are clamped between 0 and 255.
The 2 left digits code the red value, the 2 middle digits the blue and the 2 left digits the green.
- Parameters:
hex_val (str) – hexadecimal value.
- Returns:
a list containing R, G, B values.
- Return type:
a list of integer
>>> from gamebeye.gbcamcolors.color_helpers import hex_to_rgb >>> hex_to_rgb('#000000') [0, 0, 0] >>> hex_to_rgb('#FF0000') [255, 0, 0] >>> hex_to_rgb('#00FF00') [0, 255, 0] >>> hex_to_rgb('#0000FF') [0, 0, 255] >>> hex_to_rgb('#FFFFFF') [255, 255, 255] >>> hex_to_rgb('#F000000') [255, 255, 255]
- gamebeye.color_helpers.is_clamped(val: int) bool
Check if val is clamped between 0 and 255.
If val is out of boundaries, returns False. True otherwise.
- Parameters:
val (int) – the value to be checked
- Returns:
the comparison result
- Return type:
bool
>>> from gamebeye.gbcamcolors.color_helpers import is_clamped >>> is_clamped(-125) False >>> is_clamped(0) True >>> is_clamped(125) True >>> is_clamped(255) True >>> is_clamped(512) False
- gamebeye.color_helpers.is_clamped_hex(hex_val: str) bool
Ensure that val is between ‘#000000’ and ‘#FFFFFF’.
If val is out of boundaries, returns False. True otherwise.
- Parameters:
hex_val (str) – an hexadecimal value
- Returns:
the comparison result
- Return type:
bool
>>> from gamebeye.gbcamcolors.color_helpers import is_clamped_hex >>> is_clamped_hex('#000000') True >>> is_clamped_hex('#FFFFFF') True >>> is_clamped_hex('#00FF00') True >>> is_clamped_hex('#F000000') False
- gamebeye.color_helpers.is_clamped_rgb(rgb_val: List[int]) bool
Check if the RGB color values are clamped between 0 and 255.
If val is out of boundaries, returns False. True otherwise.
- Parameters:
rgb_val (List[int]) – 3-channels list for R, G, B
- Raises:
ValueError – rgb_val argument must be a 3 values list
- Returns:
the comparison result
- Return type:
bool
>>> from gamebeye.gbcamcolors.color_helpers import is_clamped_rgb >>> is_clamped_rgb([0, 0, 0]) True >>> is_clamped_rgb([255, 255, 255]) True >>> is_clamped_rgb([512, 0, 0]) False >>> is_clamped_rgb([255, 255, 255, 0]) Traceback (most recent call last): ... ValueError: rgb_val argument must be a 3 values list
- gamebeye.color_helpers.rgb_to_hex(rgb_val: List[int]) str
Convert a (R, G, B) array to hexadecimal integer.
All values are clamped between 0 and 255.
- Parameters:
rgb_val (list) – (R, G, B) list to convert
- Raises:
ValueError – rgb_val argument must be a 3 values list
- Returns:
an hexadecimal value
- Return type:
str
>>> from gamebeye.gbcamcolors.color_helpers import rgb_to_hex >>> rgb_to_hex([0, 0, 0]) '#000000' >>> rgb_to_hex([0, 0, 255]) '#0000FF' >>> rgb_to_hex([255, 0, 0]) '#FF0000' >>> rgb_to_hex([512, 128, 0]) '#FF8000' >>> rgb_to_hex([0, 0, 0, 0]) Traceback (most recent call last): ... ValueError: rgb_val argument must be a 3 values list