![]() |
The ZX Ecosystem v5.1.0;_GUI_v3.1.0
|
These classes provide support for the ZX color system.
NOTE:
-These classes are not thread-safe.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Namespaces | |
namespace | zxeco |
The main namespace of the library, that spans across all the zx modules. | |
Classes | |
class | zxeco::Flash |
A value of flash that is different to the same value of bright, inv or over. More... | |
class | zxeco::Bright |
A value of bright that is different to the same value of flash, inv or over. More... | |
class | zxeco::Inverse |
A value of inv that is different to the same value of flash, bright or over. More... | |
class | zxeco::Over |
A value of over that is different to the same value of flash, bright or inv. More... | |
class | zxeco::BasicColor |
One of the 8 basic colors of the ZX, not considering bright or flash. More... | |
class | zxeco::BrightColor |
A basic color plus a bright level (on / off). More... | |
class | zxeco::PrintColor |
A BasicColor or CONTRAST or TRANSPARENT, but not with bright or flash. More... | |
class | zxeco::Paper |
A printcolor for paper as a different type from a color for ink. More... | |
class | zxeco::Ink |
A printcolor for ink as a different type from a color for paper. More... | |
class | zxeco::AttrColors |
Complete color specification for an attr (character) cell on the zx screen. More... | |
class | zxeco::Colors |
Color specification for a character cell, plus modes of printing. More... | |
Enumerations | |
enum | zxeco::ColorBaseType : uint8_t { BLACK = 0 , BLUE , RED , MAGENTA , GREEN , CYAN , YELLOW , zxeco::WHITE , zxeco::NUMBASICCOLORS , zxeco::TRANSPARENT = NUMBASICCOLORS , zxeco::CONTRAST , NUMPRINTCOLORS } |
Main color constants. More... | |
class zxeco::Flash |
A value of flash that is different to the same value of bright, inv or over.
Definition at line 82 of file ZXColors.h.
Public Member Functions | |
Flash (ColorModVal cmv) | |
Flash (bool f=true) | |
operator ColorModVal (void) const noexcept | |
|
inlineexplicit |
Definition at line 87 of file ZXColors.h.
|
inlinenoexcept |
Definition at line 89 of file ZXColors.h.
class zxeco::Bright |
A value of bright that is different to the same value of flash, inv or over.
Definition at line 99 of file ZXColors.h.
Public Member Functions | |
Bright (ColorModVal cmv) | |
Bright (bool b=true) | |
operator ColorModVal (void) const noexcept | |
|
inlineexplicit |
Definition at line 104 of file ZXColors.h.
|
inlinenoexcept |
Definition at line 106 of file ZXColors.h.
class zxeco::Inverse |
A value of inv that is different to the same value of flash, bright or over.
Definition at line 116 of file ZXColors.h.
Public Member Functions | |
Inverse (ColorModVal cmv) | |
Inverse (bool i=true) | |
operator ColorModVal (void) const noexcept | |
|
inlineexplicit |
Definition at line 121 of file ZXColors.h.
|
inlinenoexcept |
Definition at line 123 of file ZXColors.h.
class zxeco::Over |
A value of over that is different to the same value of flash, bright or inv.
Definition at line 133 of file ZXColors.h.
Public Member Functions | |
Over (ColorModVal cmv) | |
Over (bool o=true) | |
operator ColorModVal (void) const noexcept | |
|
inlineexplicit |
Definition at line 138 of file ZXColors.h.
|
inlinenoexcept |
Definition at line 140 of file ZXColors.h.
class zxeco::BasicColor |
One of the 8 basic colors of the ZX, not considering bright or flash.
Definition at line 153 of file ZXColors.h.
Public Member Functions | |
BasicColor (ColorBaseType cbt=BLACK) | |
Default constructor from a given base color. More... | |
operator ColorBaseType (void) const noexcept | |
Conversion to ColorBaseType. More... | |
BasicColor | contrasting (void) const noexcept |
Return the basic color that contrasts with this one. More... | |
void | setNext (bool circular=true) |
Set this color to the next basic color. More... | |
std::string | to_string (void) const |
Return the name for this color. | |
zxeco::BasicColor::BasicColor | ( | ColorBaseType | cbt = BLACK | ) |
Default constructor from a given base color.
This conversion constructor allows for using simply BLACK in an expression that expects a BasicColor. Throws if CBT is out of range.
|
inlinenoexcept |
Conversion to ColorBaseType.
This operator allows for using a BasicColor object in any expression expecting a ColorBaseType, e.g., for checking equallity of a BasicColor to any of the BLACK, BLUE, etc. constants.
Definition at line 165 of file ZXColors.h.
|
inlinenoexcept |
Return the basic color that contrasts with this one.
Definition at line 170 of file ZXColors.h.
void zxeco::BasicColor::setNext | ( | bool | circular = true | ) |
Set this color to the next basic color.
Set it to the next basic color, maybe in a circular way (otherwise, raise an exception when reaching the last color).
class zxeco::BrightColor |
A basic color plus a bright level (on / off).
This class also relates such a color with info about its RGB components and allows to consider all the bright colors in a linear sequence.
Definition at line 194 of file ZXColors.h.
Static Public Attributes | |
static constexpr RGBPalette::Size | NUMLINEARCOLORS = NUMBASICCOLORS * 2 |
Number of linear colors. Black is counted twice, being equal w & w/o br. More... | |
static constexpr RGBPalette::Index | FIRSTLINEARCOLORWBRIGHT = NUMBASICCOLORS |
First linear color that has bright. More... | |
Public Member Functions | |
BrightColor (BasicColor bc=BLACK, bool br=false) | |
Default constructor and constructor from BasicColor. More... | |
BrightColor (RGBPalette::Index li) | |
Constructor from a linear index, from 0 to NUMLINEARCOLORS-1. More... | |
BrightColor (const RGBColor &col) | |
Constructor from a rgb color. More... | |
BasicColor | color (void) const noexcept |
Get the basic color. More... | |
bool | bright (void) const noexcept |
Get the bright level. More... | |
RGBPalette::Index | linear (void) const noexcept |
Return the index of this color in the ZX palette. More... | |
const RGBColor & | rgbColor (void) const noexcept |
Return the RGBColor used to define this BrightColor. More... | |
std::string | to_string (void) const |
Return a descriptive string for this color. | |
|
inline |
Default constructor and constructor from BasicColor.
Definition at line 208 of file ZXColors.h.
zxeco::BrightColor::BrightColor | ( | RGBPalette::Index | li | ) |
Constructor from a linear index, from 0 to NUMLINEARCOLORS-1.
Raise an exception if the index is invalid.
|
inline |
Constructor from a rgb color.
Get the nearest ZX color to RGB.
Definition at line 216 of file ZXColors.h.
|
inlinenoexcept |
Get the basic color.
Definition at line 223 of file ZXColors.h.
|
inlinenoexcept |
Get the bright level.
Definition at line 226 of file ZXColors.h.
|
inlinenoexcept |
Return the index of this color in the ZX palette.
Undefined result if bright is transparent.
Definition at line 229 of file ZXColors.h.
|
inlinenoexcept |
Return the RGBColor used to define this BrightColor.
The returned RGBColor is static and therefore it always exists.
Definition at line 234 of file ZXColors.h.
|
staticconstexpr |
Number of linear colors. Black is counted twice, being equal w & w/o br.
Definition at line 201 of file ZXColors.h.
|
staticconstexpr |
First linear color that has bright.
Definition at line 204 of file ZXColors.h.
class zxeco::PrintColor |
A BasicColor or CONTRAST or TRANSPARENT, but not with bright or flash.
Definition at line 254 of file ZXColors.h.
Public Member Functions | |
PrintColor (ColorBaseType cbt=BLACK) | |
Default constructor and from a constant color. Call base constructor. More... | |
PrintColor (const BasicColor &bc) noexcept | |
Constructor from the corresponding BasicColor. More... | |
operator ColorBaseType (void) const noexcept | |
Conversion to ColorBaseType. More... | |
BasicColor | basic (void) const |
Conversion to BasicColor, if a valid one; otherwise, exception. | |
bool | isBasic (void) const noexcept |
Return TRUE if the color is a basic one and not CONTRAST or TRANSP. More... | |
std::string | to_string (void) const |
Return a descriptive text of the color. | |
zxeco::PrintColor::PrintColor | ( | ColorBaseType | cbt = BLACK | ) |
Default constructor and from a constant color. Call base constructor.
This conversion constructor allows to use the constant (BLACK, BLUE, ...) in any expression expecting a PrintColor.
|
inlinenoexcept |
Constructor from the corresponding BasicColor.
This conversion constructor allows to use a BasicColor in any expression expecting a PrintColor.
Definition at line 263 of file ZXColors.h.
|
inlinenoexcept |
Conversion to ColorBaseType.
This operator allows to use a PrintColor in expressions expecting a constant (BLACK, BLUE, ...).
Definition at line 270 of file ZXColors.h.
|
inlinenoexcept |
Return TRUE if the color is a basic one and not CONTRAST or TRANSP.
Definition at line 277 of file ZXColors.h.
class zxeco::Paper |
A printcolor for paper as a different type from a color for ink.
Definition at line 292 of file ZXColors.h.
Public Member Functions | |
Paper (PrintColor p) | |
![]() | |
PrintColor (ColorBaseType cbt=BLACK) | |
Default constructor and from a constant color. Call base constructor. More... | |
PrintColor (const BasicColor &bc) noexcept | |
Constructor from the corresponding BasicColor. More... | |
operator ColorBaseType (void) const noexcept | |
Conversion to ColorBaseType. More... | |
BasicColor | basic (void) const |
Conversion to BasicColor, if a valid one; otherwise, exception. | |
bool | isBasic (void) const noexcept |
Return TRUE if the color is a basic one and not CONTRAST or TRANSP. More... | |
std::string | to_string (void) const |
Return a descriptive text of the color. | |
|
inlineexplicit |
Definition at line 296 of file ZXColors.h.
class zxeco::Ink |
A printcolor for ink as a different type from a color for paper.
Definition at line 301 of file ZXColors.h.
Public Member Functions | |
Ink (PrintColor p) | |
![]() | |
PrintColor (ColorBaseType cbt=BLACK) | |
Default constructor and from a constant color. Call base constructor. More... | |
PrintColor (const BasicColor &bc) noexcept | |
Constructor from the corresponding BasicColor. More... | |
operator ColorBaseType (void) const noexcept | |
Conversion to ColorBaseType. More... | |
BasicColor | basic (void) const |
Conversion to BasicColor, if a valid one; otherwise, exception. | |
bool | isBasic (void) const noexcept |
Return TRUE if the color is a basic one and not CONTRAST or TRANSP. More... | |
std::string | to_string (void) const |
Return a descriptive text of the color. | |
|
inlineexplicit |
Definition at line 305 of file ZXColors.h.
class zxeco::AttrColors |
Complete color specification for an attr (character) cell on the zx screen.
It contains: flash, bright, paper and ink, with the two latter being PrintColor and all supporting TRANSPARENT values.
Definition at line 314 of file ZXColors.h.
Public Member Functions | |
AttrColors (void) | |
Default constructor: no bright, no flash, black ink, white paper. More... | |
AttrColors (Flash f, Bright b, Paper p, Ink i) | |
Constructor from elements. More... | |
AttrColors (uint8_t attr) | |
Constructor from the byte that contains the screen attribute. | |
uint8_t | toAttr (void) const |
Convert the color specification into a byte for the attribute screen. More... | |
ColorModVal | flash (void) const noexcept |
Get the flash element. More... | |
ColorModVal | bright (void) const noexcept |
Get the bright element. More... | |
PrintColor | paper (void) const noexcept |
Get the paper element. More... | |
PrintColor | ink (void) const noexcept |
Get the ink element. More... | |
bool | rgb (RGBColor &ink, RGBColor &paper) const |
Get RGB colors for this attribute and return flash. | |
void | setFlash (ColorModVal f) noexcept |
Change the flash element. More... | |
void | setFlash (bool f=true) noexcept |
< Change the flash element to one of ON or OFF. More... | |
void | setBright (ColorModVal b) noexcept |
Change the bright element. More... | |
void | setBright (bool b=true) noexcept |
< Change the bright element to one of ON or OFF. More... | |
void | setPaper (PrintColor p) noexcept |
Change the paper element. More... | |
void | setInk (PrintColor i) noexcept |
Change the ink element. More... | |
void | swapPaperAndInk (void) noexcept |
Swap paper and ink. More... | |
AttrColors | swapped (void) const noexcept |
< Return a version of these colors but with ink and paper swapped. More... | |
void | adjustByExisting (const AttrColors &ex) |
Change this attrs as though the ZX would use them for printing on EX. More... | |
std::string | to_string (bool shorttxt=false) const |
Return a descriptive text of this color specification. | |
|
inline |
Default constructor: no bright, no flash, black ink, white paper.
Definition at line 320 of file ZXColors.h.
Constructor from elements.
Definition at line 323 of file ZXColors.h.
uint8_t zxeco::AttrColors::toAttr | ( | void | ) | const |
Convert the color specification into a byte for the attribute screen.
CONTRAST and TRANSPARENT colors, and TRANSPARENT bright/flash, produce exception.
|
inlinenoexcept |
Get the flash element.
Definition at line 339 of file ZXColors.h.
|
inlinenoexcept |
Get the bright element.
Definition at line 342 of file ZXColors.h.
|
inlinenoexcept |
Get the paper element.
Definition at line 345 of file ZXColors.h.
|
inlinenoexcept |
Get the ink element.
Definition at line 348 of file ZXColors.h.
|
inlinenoexcept |
Change the flash element.
Definition at line 354 of file ZXColors.h.
|
inlinenoexcept |
< Change the flash element to one of ON or OFF.
Definition at line 357 of file ZXColors.h.
|
inlinenoexcept |
Change the bright element.
Definition at line 361 of file ZXColors.h.
|
inlinenoexcept |
< Change the bright element to one of ON or OFF.
Definition at line 364 of file ZXColors.h.
|
inlinenoexcept |
Change the paper element.
Definition at line 368 of file ZXColors.h.
|
inlinenoexcept |
Change the ink element.
Definition at line 371 of file ZXColors.h.
|
inlinenoexcept |
Swap paper and ink.
Definition at line 374 of file ZXColors.h.
|
inlinenoexcept |
< Return a version of these colors but with ink and paper swapped.
Definition at line 377 of file ZXColors.h.
void zxeco::AttrColors::adjustByExisting | ( | const AttrColors & | ex | ) |
Change this attrs as though the ZX would use them for printing on EX.
This method works as the original ZX when printing with certain attrs (the ones in this object) on a character cell that has others (the ones in EX), i.e., this method changes transparencies and constrasts by concrete colors according to the ones in EX.
According to original ZX behaviour of printing (0x0dbd ROM, in this very sequence):
1.- Substitute ink 8 by ex.ink and paper 8 by ex.paper 2.- If paper == 9, substitute paper 9 by contrast of ink (if ink == 9, then set ink to BLACK before that). 3.- If ink == 9, substitute ink 9 by contrast of paper. 4.- If bright == 8, substitute it by ex.bright 5.- If flash == 8, substitute it by ex.flash
For drawing, the same is done but only ink is taken from the desired colors.
Exceptions are thrown if EX contains non-basic colors.
class zxeco::Colors |
Color specification for a character cell, plus modes of printing.
Contains an AttrColors object plus the inverse and over modes of printing.
Definition at line 419 of file ZXColors.h.
Public Member Functions | |
Colors (void) | |
Default constructor: default color attribute plus no inverse or over. More... | |
Colors (AttrColors cc, Inverse inv, Over ov) | |
Constructor from an attribute specification plus inverse and over. More... | |
ColorModVal | inverse (void) const noexcept |
Get the inverse mode. More... | |
void | setInverse (ColorModVal inv) noexcept |
Change the inverse mode. More... | |
void | setInverse (bool i=true) noexcept |
< Change the inverse element to one of ON or OFF. More... | |
ColorModVal | over (void) const noexcept |
Get the over mode. More... | |
void | setOver (ColorModVal ov) noexcept |
Change the over mode. More... | |
void | setOver (bool o=true) noexcept |
Change the over element to one of ON or OFF. More... | |
Colors & | operator<< (Paper p) noexcept |
Colors & | operator<< (Ink i) noexcept |
Colors & | operator<< (Bright b) noexcept |
Colors & | operator<< (Flash f) noexcept |
Colors & | operator<< (Inverse f) noexcept |
Colors & | operator<< (Over o) noexcept |
std::string | to_string (void) const |
Return a text with the information of the colors. More... | |
![]() | |
AttrColors (void) | |
Default constructor: no bright, no flash, black ink, white paper. More... | |
AttrColors (Flash f, Bright b, Paper p, Ink i) | |
Constructor from elements. More... | |
AttrColors (uint8_t attr) | |
Constructor from the byte that contains the screen attribute. | |
uint8_t | toAttr (void) const |
Convert the color specification into a byte for the attribute screen. More... | |
ColorModVal | flash (void) const noexcept |
Get the flash element. More... | |
ColorModVal | bright (void) const noexcept |
Get the bright element. More... | |
PrintColor | paper (void) const noexcept |
Get the paper element. More... | |
PrintColor | ink (void) const noexcept |
Get the ink element. More... | |
bool | rgb (RGBColor &ink, RGBColor &paper) const |
Get RGB colors for this attribute and return flash. | |
void | setFlash (ColorModVal f) noexcept |
Change the flash element. More... | |
void | setFlash (bool f=true) noexcept |
< Change the flash element to one of ON or OFF. More... | |
void | setBright (ColorModVal b) noexcept |
Change the bright element. More... | |
void | setBright (bool b=true) noexcept |
< Change the bright element to one of ON or OFF. More... | |
void | setPaper (PrintColor p) noexcept |
Change the paper element. More... | |
void | setInk (PrintColor i) noexcept |
Change the ink element. More... | |
void | swapPaperAndInk (void) noexcept |
Swap paper and ink. More... | |
AttrColors | swapped (void) const noexcept |
< Return a version of these colors but with ink and paper swapped. More... | |
void | adjustByExisting (const AttrColors &ex) |
Change this attrs as though the ZX would use them for printing on EX. More... | |
std::string | to_string (bool shorttxt=false) const |
Return a descriptive text of this color specification. | |
|
inline |
Default constructor: default color attribute plus no inverse or over.
Definition at line 423 of file ZXColors.h.
|
inline |
Constructor from an attribute specification plus inverse and over.
Definition at line 426 of file ZXColors.h.
|
inlinenoexcept |
Get the inverse mode.
Definition at line 431 of file ZXColors.h.
|
inlinenoexcept |
Change the inverse mode.
Definition at line 434 of file ZXColors.h.
|
inlinenoexcept |
< Change the inverse element to one of ON or OFF.
Definition at line 437 of file ZXColors.h.
|
inlinenoexcept |
Get the over mode.
Definition at line 441 of file ZXColors.h.
|
inlinenoexcept |
Change the over mode.
Definition at line 444 of file ZXColors.h.
|
inlinenoexcept |
Change the over element to one of ON or OFF.
Definition at line 447 of file ZXColors.h.
Definition at line 450 of file ZXColors.h.
Definition at line 451 of file ZXColors.h.
Definition at line 452 of file ZXColors.h.
Definition at line 453 of file ZXColors.h.
Definition at line 454 of file ZXColors.h.
Definition at line 455 of file ZXColors.h.
|
inline |
Return a text with the information of the colors.
Definition at line 457 of file ZXColors.h.
enum zxeco::ColorBaseType : uint8_t |
#include <ZXColors.h>
Main color constants.
Definition at line 46 of file ZXColors.h.