2
* Copyright (C) 2007 Javier M Mora <javiermm@gmail.com>
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of the
7
* License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
23
namespace gbrainy.Core.Main
25
//Utility class for color operations
26
public class ColorPalette
28
private ArrayListIndicesRandom color_order;
32
set { alpha = value; }
37
get { return color_order.Count; }
40
// Are defined "First", "PrimaryColors", "PrimarySecundaryColors", and "Last" to
41
// create iterators. So:
42
// for (Colors.Id it= Colors.Id.First; it<Colors.Id.PrimaryColors; it++);
43
// for (Colors.Id it= Colors.Id.First; it<Colors.Id.PrimarySecundaryColors; it++);
44
// for (Colors.Id it= Colors.Id.First; it<Colors.Id.Last; it++);
57
PrimarySecundaryColors,
58
Black=PrimarySecundaryColors,
63
private static readonly string[] ColorName= new string[] {
64
Catalog.GetString ("red"),
65
Catalog.GetString ("green"),
66
Catalog.GetString ("blue"),
67
Catalog.GetString ("yellow"),
68
Catalog.GetString ("magenta"),
69
Catalog.GetString ("orange"),
70
Catalog.GetString ("black"),
71
Catalog.GetString ("white")
74
private static Cairo.Color[] CairoColor = new Cairo.Color[] {
75
new Cairo.Color (0.81, 0.1, 0.13),
76
new Cairo.Color (0.54, 0.71, 0.24),
77
new Cairo.Color (0.17, 0.23 ,0.56),
78
new Cairo.Color (0.94, 0.93, 0.25),
79
new Cairo.Color (0.82, 0.25, 0.59),
80
new Cairo.Color (1, 0.54, 0),
81
new Cairo.Color (0, 0, 0),
82
new Cairo.Color (.9, .9, .9)
85
public ColorPalette (Id id)
87
color_order = new ArrayListIndicesRandom((int)id);
91
public ColorPalette (int size)
93
color_order = new ArrayListIndicesRandom(size);
97
public void Initialize()
99
color_order.Initialize();
102
public Cairo.Color Cairo (int index)
104
return Cairo (CairoColor[(int)color_order[index]]);
107
public Cairo.Color Cairo (Id id)
109
return Cairo (CairoColor[(int)id]);
112
public Cairo.Color Cairo(Cairo.Color color)
114
return new Cairo.Color(color.R, color.G, color.B, alpha);
117
public string Name(int index)
119
return ColorName[(int)color_order[index]];
122
public string Name(Id id)
124
return ColorName[(int)id];
129
return color_order.Count;