Freeciv-3.2: /fast/freeciv/nightly/S3_2/client/gui-gtk-4.0/colors.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
colors.c
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#include <stdio.h>
19
20#include <gtk/gtk.h>
21
22/* utility */
23#include "log.h"
24#include "mem.h"
25
26/* common */
27#include "rgbcolor.h"
28
29/* client/gui-gtk-4.0 */
30#include "gui_main.h"
31
32#include "colors.h"
33
34/************************************************************************/
38 struct color *color_alloc(int r, int g, int b)
39{
40 struct color *color = fc_malloc(sizeof(*color));
41
42 color->color.red = (double)r/255;
43 color->color.green = (double)g/255;
44 color->color.blue = (double)b/255;
45 color->color.alpha = 1.0;
46
47 return color;
48}
49
50/************************************************************************/
53 void color_free(struct color *color)
54{
55 free(color);
56}
57
58/************************************************************************/
62 int color_brightness_score(struct color *pcolor)
63{
64 struct rgbcolor *prgb = rgbcolor_new(pcolor->color.red * 255,
65 pcolor->color.green * 255,
66 pcolor->color.blue * 255);
67 int score = rgbcolor_brightness_score(prgb);
68
69 rgbcolor_destroy(prgb);
70 return score;
71}
pcolor
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
incite_cost
char * incite_cost
Definition comments.c:74
color_alloc
struct color * color_alloc(int r, int g, int b)
Definition colors.c:38
color_free
void color_free(struct color *color)
Definition colors.c:53
color_brightness_score
int color_brightness_score(struct color *pcolor)
Definition colors.c:62
colors.h
gui_main.h
log.h
mem.h
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
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
rgbcolor.h
color
Definition colors.h:21
color::g
int g
Definition colors.h:21
color::color
GdkRGBA color
Definition colors.h:22
color::r
int r
Definition colors.h:21
color::b
int b
Definition colors.h:21
rgbcolor
Definition rgbcolor.h:33