diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-02-06 15:22:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-06 15:22:24 +0100 |
| commit | db0a1f4baeb928b54d328d5dfbd0ec37b0b58bd3 (patch) | |
| tree | ed53495f5dd435d7c23cd4267fb785e5ebca679c /src/fl_color.cxx | |
| parent | af4954aee3483f03ff69e990e80f4e4a18e8b7f6 (diff) | |
OpenGL implementation of all `fl_` "Drawing Fast Shapes" graphics calls (#385)
* Fix build system for unites,
* Updated unittest to check OpenGL drawing.
Making sure that OpenGL drawing is exactly the same
as native drawing to make FLTK widget rendering
look the same in GL windows.
* Make OpenGL optional.
* Implemented clipping in OpenGL
* unites drawing fast shapes
* Fixed CMake
* Updating unittest.
Added tests for fl_pi and fl_arc (int)
Renamed tab to render complex shapes.
* Improved OpenGL FLTK drawing emulation.
* Fixed GTK ROUND DOWN BOX
* Fixing Makefile for unittest
* Correctly aligning OpenGL text.
* Fixed text alignment in GL windows.
Explained the "FLTK over GL " example in Cube.
* Overlapping test.
* Better GL graphics alignment.
* Drawing the focus rect.
* Adding Alpha Channel support for GL.
* Added FLTK-on-GL documentation.
Diffstat (limited to 'src/fl_color.cxx')
| -rw-r--r-- | src/fl_color.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/fl_color.cxx b/src/fl_color.cxx index 861f8d77f..8d3d04561 100644 --- a/src/fl_color.cxx +++ b/src/fl_color.cxx @@ -64,6 +64,19 @@ void Fl::set_color(Fl_Color i, uchar red, uchar green, uchar blue) { ((unsigned)red<<24)+((unsigned)green<<16)+((unsigned)blue<<8)); } +/** + Sets an entry in the fl_color index table. + + You can set it to any 8-bit RGBA color. + */ +void Fl::set_color(Fl_Color i, uchar red, uchar green, uchar blue, uchar alpha) { + Fl::set_color((Fl_Color)(i & 255), + ((unsigned)red<<24) + |((unsigned)green<<16) + |((unsigned)blue<<8) + |(alpha^0xff)); +} + void Fl::set_color(Fl_Color i, unsigned c) { @@ -97,6 +110,26 @@ void Fl::get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue) { } /** + Returns the RGBA value(s) for the given FLTK color index. + + This form returns the red, green, blue, and alpha values + separately in referenced variables. + + \see unsigned get_color(Fl_Color c) + */ +void Fl::get_color(Fl_Color i, uchar &red, uchar &green, uchar &blue, uchar &alpha) { + unsigned c; + + if (i & 0xffffff00) c = (unsigned)i; + else c = fl_cmap[i]; + + red = uchar(c>>24); + green = uchar(c>>16); + blue = uchar(c>>8); + alpha = uchar(c^0x000000ff); +} + +/** Returns the weighted average color between the two given colors. The red, green and blue values are averages using the following formula: |
