New method rgb2ColorIndex() to converts a 24-bit RGB color to a 256-color compatible approximation
This commit is contained in:
parent
70f3598b62
commit
1f8d16791a
|
@ -1,3 +1,7 @@
|
||||||
|
2018-11-03 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* New method rgb2ColorIndex() to converts a 24-bit RGB color
|
||||||
|
to a 256-color compatible approximation
|
||||||
|
|
||||||
2018-11-01 Markus Gans <guru.mail@muenster.de>
|
2018-11-01 Markus Gans <guru.mail@muenster.de>
|
||||||
* Moved FTerm debug access methods to FTermDebugData
|
* Moved FTerm debug access methods to FTermDebugData
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
     [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html)
|
     [![documented](https://codedocs.xyz/gansm/finalcut.svg)](https://codedocs.xyz/gansm/finalcut/hierarchy.html)
|
||||||
|
|
||||||
The FINAL CUT is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
|
The FINAL CUT is a C++ class library and widget toolkit with full mouse support for creating a [text-based user interface](https://en.wikipedia.org/wiki/Text-based_user_interface). The library supports the programmer to develop an application for the text console. It allows the simultaneous handling of multiple text windows on the screen.
|
||||||
The C++ class design was inspired by the Qt framework. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on.
|
The structure of the Qt framework was originally the inspiration for the C++ class design of FINAL CUT. It provides common controls like dialog boxes, push buttons, check boxes, radio buttons, input lines, list boxes, status bars and so on.
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
```bash
|
```bash
|
||||||
|
|
|
@ -87,8 +87,8 @@ How can I fix display problems?
|
||||||
* Make sure that the environment variable TERM has the right
|
* Make sure that the environment variable TERM has the right
|
||||||
terminal name.
|
terminal name.
|
||||||
|
|
||||||
* With the command "`msgcat --color=test`" you can test whether
|
* Use the command "`msgcat --color=test`" to test whether the terminal
|
||||||
the colors are displayed correctly in the terminal
|
displays colors correctly in the terminal.
|
||||||
|
|
||||||
* If characters are not displayed in the right place on the screen,
|
* If characters are not displayed in the right place on the screen,
|
||||||
it may help to disable cursor optimization for your program with
|
it may help to disable cursor optimization for your program with
|
||||||
|
|
|
@ -72,7 +72,7 @@ The title bar of the dialog box gets the text "A dialog".
|
||||||
dialog.setGeometry (25, 5, 30, 10);
|
dialog.setGeometry (25, 5, 30, 10);
|
||||||
```
|
```
|
||||||
The dialog window gets a width of 30 and a height of 10 characters.
|
The dialog window gets a width of 30 and a height of 10 characters.
|
||||||
The window in the terminal is located at the positions x=25 and
|
The position of the window in the terminal is at x=25 and
|
||||||
y=5 (note: x=1 and y=1 represents the upper left corner).
|
y=5 (note: x=1 and y=1 represents the upper left corner).
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
|
@ -93,7 +93,7 @@ if available) visible.
|
||||||
return app.exec();
|
return app.exec();
|
||||||
```
|
```
|
||||||
The last line calls `exec()` to start the application and return
|
The last line calls `exec()` to start the application and return
|
||||||
the result to the operating system. When the application starts,
|
the result to the operating system. The started application enters
|
||||||
it enters the main event loop. This loop doesn't end until the
|
the main event loop. This loop does not end until the window is
|
||||||
window/application is closed.
|
not closed.
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,20 @@ void FVTerm::setPrintCursor (int x, int y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
short FVTerm::rgb2ColorIndex (short r, short g, short b)
|
||||||
|
{
|
||||||
|
// Converts a 24-bit RGB color to a 256-color compatible approximation
|
||||||
|
|
||||||
|
if ( r < 0 || g < 0 || b < 0 || r > 0xff || g > 0xff || b > 0xff )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
short ri = (((r * 5) + 127) / 255) * 36;
|
||||||
|
short gi = (((g * 5) + 127) / 255) * 6;
|
||||||
|
short bi = (((b * 5) + 127) / 255);
|
||||||
|
return 16 + ri + gi + bi;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FVTerm::clearArea (int fillchar)
|
void FVTerm::clearArea (int fillchar)
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,6 +153,7 @@ class FVTerm
|
||||||
void showCursor();
|
void showCursor();
|
||||||
void setPrintCursor (const FPoint&);
|
void setPrintCursor (const FPoint&);
|
||||||
void setPrintCursor (int, int);
|
void setPrintCursor (int, int);
|
||||||
|
short rgb2ColorIndex (short, short, short);
|
||||||
void setColor (short, short);
|
void setColor (short, short);
|
||||||
static void setNormal();
|
static void setNormal();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue