Freeciv-3.1: /fast/freeciv/nightly/S3_1/client/gui-qt/colors.cpp Source File

Freeciv-3.1

Loading...
Searching...
No Matches
colors.cpp
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "mem.h"
20
21// gui-qt
22#include "colors.h"
23#include "qtg_cxxside.h"
24
25/************************************************************************/
29 struct color *qtg_color_alloc(int r, int g, int b)
30{
31 struct color *pcolor = new color;
32
33 pcolor->qcolor.setRgb(r, g, b);
34
35 return pcolor;
36}
37
38/************************************************************************/
41 void qtg_color_free(struct color *pcolor)
42{
43 delete pcolor;
44}
45
46/************************************************************************/
50 int color_brightness_score(struct color *pcolor)
51{
52 /* QColor has color space conversions, but nothing giving a perceptually
53 * even color space */
54 struct rgbcolor *prgb = rgbcolor_new(pcolor->qcolor.red(),
55 pcolor->qcolor.green(),
56 pcolor->qcolor.blue());
57 int score = rgbcolor_brightness_score(prgb);
58
59 rgbcolor_destroy(prgb);
60 return score;
61}
pcolor
struct canvas int int struct sprite bool int int fog_y struct canvas struct sprite struct color * pcolor
Definition canvas_g.h:57
qtg_color_alloc
struct color * qtg_color_alloc(int r, int g, int b)
Definition colors.cpp:29
color_brightness_score
int color_brightness_score(struct color *pcolor)
Definition colors.cpp:50
qtg_color_free
void qtg_color_free(struct color *pcolor)
Definition colors.cpp:41
colors.h
mem.h
qtg_cxxside.h
rgbcolor_destroy
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
rgbcolor_new
struct rgbcolor * rgbcolor_new(int r, int g, int b)
Definition rgbcolor.c:34
rgbcolor_brightness_score
int rgbcolor_brightness_score(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:196
color
Definition colors.h:20
color::g
int g
Definition colors.h:21
color::color
GdkRGBA color
Definition colors.h:21
color::r
int r
Definition colors.h:21
color::b
int b
Definition colors.h:21
rgbcolor
Definition rgbcolor.h:33