-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from markuspg/markuspg/refactor_color_handling
Move colors and their handling in own translation unit and refactor them slightly
- Loading branch information
Showing
16 changed files
with
2,999 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
/build-aux/ | ||
/config.* | ||
/configure | ||
/doc/html/ | ||
/libtool | ||
/po/POTFILES | ||
Makefile | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Screentest - CRT/LCD monitor testing utility. | ||
* https://tobix.github.io/screentest/ | ||
* Copyright (C) 2001 Jan "Yenya" Kasprzak <kas@fi.muni.cz> | ||
* Copyright (C) 2006-2017 Tobias Gruetzmacher <tobias-screentest@23.gs> | ||
* Copyright (C) 2021 Apr Thorsten Kattanek <thorsten.kattanek@gmx.de> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* 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. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | ||
*/ | ||
|
||
#include "screentest_colors.h" | ||
|
||
#define GRAY_VALUE(idx) \ | ||
((GdkRGBA){idx / ((float)SCREENTEST_GRAYS_MAX - 1), \ | ||
idx / ((float)SCREENTEST_GRAYS_MAX - 1), \ | ||
idx / ((float)SCREENTEST_GRAYS_MAX - 1), 1.0}) | ||
|
||
const GdkRGBA fgcolors[SCREENTEST_COLORS_MAX] = { | ||
// WHITE | ||
{1.0, 1.0, 1.0, 1.0}, | ||
// RED | ||
{1.0, 0.0, 0.0, 1.0}, | ||
// GREEN | ||
{0.0, 1.0, 0.0, 1.0}, | ||
// BLUE | ||
{0.0, 0.0, 1.0, 1.0}, | ||
// CYAN | ||
{0.0, 1.0, 1.0, 1.0}, | ||
// MAGENTA | ||
{1.0, 0.0, 1.0, 1.0}, | ||
// YELLOW | ||
{1.0, 1.0, 0.0, 1.0}, | ||
// BLACK | ||
{0.0, 0.0, 0.0, 1.0}}; | ||
GdkRGBA bg_col = {0.0, 0.0, 0.0, 1.0}; // fgcolors[SCREENTEST_COLORS_BLACK]; | ||
GdkRGBA fg_col = {1.0, 1.0, 1.0, 1.0}; // fgcolors[SCREENTEST_COLORS_WHITE]; | ||
GdkRGBA *const bg_color = &bg_col; | ||
GdkRGBA *const fg_color = &fg_col; | ||
const GdkRGBA grays[SCREENTEST_GRAYS_MAX] = { | ||
GRAY_VALUE(0), GRAY_VALUE(1), GRAY_VALUE(2), GRAY_VALUE(3), | ||
GRAY_VALUE(4), GRAY_VALUE(5), GRAY_VALUE(6), GRAY_VALUE(7), | ||
}; | ||
|
||
void screentest_set_color_bg(cairo_t *cr) { | ||
cairo_set_source_rgb(cr, bg_color->red, bg_color->green, bg_color->blue); | ||
} | ||
|
||
void screentest_set_color_fg(cairo_t *cr) { | ||
cairo_set_source_rgb(cr, fg_color->red, fg_color->green, fg_color->blue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Screentest - CRT/LCD monitor testing utility. | ||
* https://tobix.github.io/screentest/ | ||
* Copyright (C) 2001 Jan "Yenya" Kasprzak <kas@fi.muni.cz> | ||
* Copyright (C) 2006-2017 Tobias Gruetzmacher <tobias-screentest@23.gs> | ||
* Copyright (C) 2021 Apr Thorsten Kattanek <thorsten.kattanek@gmx.de> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* 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. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | ||
*/ | ||
|
||
#ifndef SCREENTEST_COLORS_H | ||
#define SCREENTEST_COLORS_H | ||
|
||
#include <gdk/gdk.h> | ||
|
||
/** | ||
* An array representing a predefined set of colors for screentest | ||
*/ | ||
enum ScreentestColors { | ||
SCREENTEST_COLORS_WHITE, | ||
SCREENTEST_COLORS_RED, | ||
SCREENTEST_COLORS_GREEN, | ||
SCREENTEST_COLORS_BLUE, | ||
SCREENTEST_COLORS_CYAN, | ||
SCREENTEST_COLORS_MAGENTA, | ||
SCREENTEST_COLORS_YELLOW, | ||
SCREENTEST_COLORS_BLACK, | ||
SCREENTEST_COLORS_MAX | ||
}; | ||
|
||
/** | ||
* One above the highest index of the `grays` array | ||
*/ | ||
#define SCREENTEST_GRAYS_MAX SCREENTEST_COLORS_MAX | ||
|
||
/** | ||
* @brief A pointer to the storage location of the background color (on stack) | ||
*/ | ||
extern GdkRGBA *const bg_color; | ||
/** | ||
* @brief An array holding all predefined `ScreentestColors` | ||
*/ | ||
extern const GdkRGBA fgcolors[SCREENTEST_COLORS_MAX]; | ||
/** | ||
* @brief A pointer to the storage location of the foreground color (on stack) | ||
*/ | ||
extern GdkRGBA *const fg_color; | ||
/** | ||
* @brief An array holding all predefined gray value "colors" | ||
*/ | ||
extern const GdkRGBA grays[SCREENTEST_GRAYS_MAX]; | ||
|
||
/** | ||
* @brief Set the source pattern of the given Cairo context to an opaque color | ||
* @param[in,out] cr The Cairo context which is used to draw the background | ||
*/ | ||
void screentest_set_color_bg(cairo_t *cr); | ||
/** | ||
* @brief Set the source pattern of the given Cairo context to an opaque color | ||
* @param[in,out] cr The Cairo context which is used to draw the foreground | ||
*/ | ||
void screentest_set_color_fg(cairo_t *cr); | ||
|
||
#endif // SCREENTEST_COLORS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.