-
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.
Rename color handling symbols and move out
- Loading branch information
Showing
13 changed files
with
202 additions
and
97 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
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,79 @@ | ||
/* | ||
* Screentest - CRT/LCD monitor testing utility. | ||
* https://tobix.github.io/screentest/ | ||
* Copyright (C) 2001 Jan "Yenya" Kasprzak <[email protected]> | ||
* Copyright (C) 2006-2017 Tobias Gruetzmacher <[email protected]> | ||
* Copyright (C) 2021 Apr Thorsten Kattanek <[email protected]> | ||
* | ||
* 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" | ||
|
||
GdkRGBA bg_col = {0}; | ||
GdkRGBA fg_col = {0}; | ||
GdkRGBA fgcolors[SCREENTEST_COLORS_MAX] = {0}; | ||
GdkRGBA *const bg_color = &bg_col; | ||
GdkRGBA *const fg_color = &fg_col; | ||
GdkRGBA grays[SCREENTEST_GRAYS_MAX] = {0}; | ||
|
||
void screentest_colors_init() { | ||
gint i; | ||
|
||
fgcolors[SCREENTEST_COLORS_WHITE].red = | ||
fgcolors[SCREENTEST_COLORS_WHITE].green = | ||
fgcolors[SCREENTEST_COLORS_WHITE].blue = | ||
fgcolors[SCREENTEST_COLORS_WHITE].alpha = 1.0; | ||
|
||
fgcolors[SCREENTEST_COLORS_RED].red = fgcolors[SCREENTEST_COLORS_RED].alpha = | ||
1.0; | ||
|
||
fgcolors[SCREENTEST_COLORS_GREEN].green = | ||
fgcolors[SCREENTEST_COLORS_GREEN].alpha = 1.0; | ||
|
||
fgcolors[SCREENTEST_COLORS_BLUE].blue = | ||
fgcolors[SCREENTEST_COLORS_BLUE].alpha = 1.0; | ||
|
||
fgcolors[SCREENTEST_COLORS_CYAN].green = 1.0; | ||
fgcolors[SCREENTEST_COLORS_CYAN].blue = 1.0; | ||
fgcolors[SCREENTEST_COLORS_CYAN].alpha = 1.0; | ||
|
||
fgcolors[SCREENTEST_COLORS_MAGENTA].red = 1.0; | ||
fgcolors[SCREENTEST_COLORS_MAGENTA].blue = 1.0; | ||
fgcolors[SCREENTEST_COLORS_MAGENTA].alpha = 1.0; | ||
|
||
fgcolors[SCREENTEST_COLORS_YELLOW].red = 1.0; | ||
fgcolors[SCREENTEST_COLORS_YELLOW].green = 1.0; | ||
fgcolors[SCREENTEST_COLORS_YELLOW].alpha = 1.0; | ||
|
||
fgcolors[SCREENTEST_COLORS_BLACK].alpha = | ||
1.0; // The other fields are 0 already | ||
|
||
*fg_color = fgcolors[SCREENTEST_COLORS_WHITE]; | ||
*bg_color = fgcolors[SCREENTEST_COLORS_BLACK]; | ||
|
||
for (i = 0; i < SCREENTEST_GRAYS_MAX; i++) { | ||
grays[i].red = grays[i].green = grays[i].blue = | ||
i / (float)(SCREENTEST_GRAYS_MAX - 1); | ||
grays[i].alpha = 1.0; | ||
} | ||
} | ||
|
||
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,80 @@ | ||
/* | ||
* Screentest - CRT/LCD monitor testing utility. | ||
* https://tobix.github.io/screentest/ | ||
* Copyright (C) 2001 Jan "Yenya" Kasprzak <[email protected]> | ||
* Copyright (C) 2006-2017 Tobias Gruetzmacher <[email protected]> | ||
* Copyright (C) 2021 Apr Thorsten Kattanek <[email protected]> | ||
* | ||
* 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 <gtk/gtk.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 GdkRGBA fgcolors[]; | ||
/** | ||
* @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 GdkRGBA grays[]; | ||
|
||
/** | ||
* @brief Initialize the color storage locations and their default values | ||
*/ | ||
void screentest_colors_init(void); | ||
|
||
/** | ||
* @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.