PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
ColorTest.cpp
Go to the documentation of this file.
1//* -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*- */
3// Name: ColorTest.cpp
4// Purpose: Tests the Color Class
5// Author: Shane T. Mueller, Ph.D.
6// Copyright: (c) 2003 Shane T. Mueller <smueller@umich.edu>
7// License: GPL 2
8//
9//
10//
11// This file is part of the PEBL project.
12//
13// PEBL is free software; you can redistribute it and/or modify
14// it under the terms of the GNU General Public License as published by
15// the Free Software Foundation; either version 2 of the License, or
16// (at your option) any later version.
17//
18// PEBL is distributed in the hope that it will be useful,
19// but WITHOUT ANY WARRANTY; without even the implied warranty of
20// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21// GNU General Public License for more details.
22//
23// You should have received a copy of the GNU General Public License
24// along with PEBL; if not, write to the Free Software
25// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27#include "../objects/PColor.h"
28#include "../objects/PObject.h"
29
30#include <iostream>
31
32using std::cout;
33using std::endl;
34using std::flush;
35
36//The following is the entry point for the command-line version
37int main(int argc, char **argv)
38{
39
40 cout << "\n\n\n==========================================================\n";
41 cout << "Testing the PColor Class\n";
42 cout << "==========================================================\n";
43
44 cout << "Constructing Colors\n";
45 PColor myColor1 = PColor();
46 PColor myColor2 = PColor(myColor1);
47 PColor myColor3 = PColor(1,2,3,4);
48 PColor myColor4 = PColor(16712194); //Should be 1,2,3,4
49 PColor myColor5 = PColor(0,0,1,0);
50 PColor myColor6 = PColor("AliceBlue"); //The first color
51 PColor myColor7 = PColor("YELLOW4"); //The last color
52 PColor myColor8 = PColor("grey18");
53 PColor myColor9 = PColor("Bugouho"); //Doesn't exist
54
55
56
57 cout << "==========================================================\n";
58 cout << "Printing Colors\n";
59 cout << myColor1 << endl;
60 cout << myColor2 << endl;
61 cout << myColor3 << endl;
62 cout << myColor4 << endl;
63 cout << myColor5 << endl;
64 cout << myColor6 << endl;
65 cout << myColor7 << endl;
66 cout << myColor8 << endl;
67 cout << myColor9 << endl;
68
69
70 cout << "==========================================================\n";
71 cout << "Printing Integer Colors\n";
72 cout << "myColor1: " << myColor1 << "|" << myColor1.GetColor() << endl;
73 cout << "myColor2: " << myColor2 << "|" << myColor2.GetColor() << endl;
74 cout << "myColor3: " << myColor3 << "|" << myColor3.GetColor() << endl;
75 cout << "myColor4: " << myColor4 << "|" << myColor4.GetColor() << endl;
76 cout << "myColor5: " << myColor5 << "|" << myColor5.GetColor() << endl;
77 cout << "myColor6: " << myColor6 << "|" << myColor6.GetColor() << endl;
78 cout << "myColor7: " << myColor7 << "|" << myColor7.GetColor() << endl;
79 cout << "myColor8: " << myColor8 << "|" << myColor8.GetColor() << endl;
80 cout << "myColor9: " << myColor9 << "|" << myColor9.GetColor() << endl;
81
82
83
84 cout << "==========================================================\n";
85 cout << "Changing color of: " << myColor1 << endl;;
86 myColor1.SetRed(150);
87 myColor1.SetGreen(175);
88 myColor1.SetBlue(200);
89 myColor1.SetAlpha(225);
90
91 cout << "to: " << myColor1 << endl;
92
93
94 cout << "==========================================================\n";
95 cout << "Getting specific colors of " << myColor1 << endl;
96 cout << "Red: " << myColor1.GetRed() <<endl;
97 cout << "Green: " << myColor1.GetGreen()<<endl;
98 cout << "Blue: " << myColor1.GetBlue()<<endl;
99 cout << "Alpha: " << myColor1.GetAlpha()<<endl;
100 cout <<endl;
101
102
103
104
105 cout << "==========================================================\n";
106 cout << "Changing color of: " << myColor1 << endl;;
107 myColor1.SetRed(150);
108 myColor1.SetGreen(175);
109 myColor1.SetBlue(200);
110 myColor1.SetAlpha(225);
111
112 cout << "to: " << myColor1 << endl;
113
114
115 cout << "==========================================================\n";
116 cout << "Getting specific colors of " << myColor1 << endl;
117 cout << "Red: " << myColor1.GetRed() <<endl;
118 cout << "Green: " << myColor1.GetGreen()<<endl;
119 cout << "Blue: " << myColor1.GetBlue()<<endl;
120 cout << "Alpha: " << myColor1.GetAlpha()<<endl;
121 cout <<endl;
122
123
124
125
126 cout << "==========================================================\n";
127 cout << "Changing color of: " << myColor1 << endl;;
128 myColor1.SetColorByName("dodgerblue");
129
130
131 cout << "to: " << myColor1 << endl;
132
133
134 cout << "==========================================================\n";
135 cout << "Getting specific colors of " << myColor1 << endl;
136 cout << "Red: " << myColor1.GetRed() <<endl;
137 cout << "Green: " << myColor1.GetGreen()<<endl;
138 cout << "Blue: " << myColor1.GetBlue()<<endl;
139 cout << "Alpha: " << myColor1.GetAlpha()<<endl;
140 cout <<endl;
141
142
143
144
145 cout << "==========================================================\n";
146 cout << "Changing color of: " << myColor1 << endl;;
147 myColor1.SetColorByRGBA(252355);
148 cout << "to: " << myColor1 << endl;
149
150
151 cout << "==========================================================\n";
152 cout << "Getting specific colors of " << myColor1 << endl;
153 cout << "Red: " << myColor1.GetRed() <<endl;
154 cout << "Green: " << myColor1.GetGreen()<<endl;
155 cout << "Blue: " << myColor1.GetBlue()<<endl;
156 cout << "Alpha: " << myColor1.GetAlpha()<<endl;
157 cout <<endl;
158
159
160 cout << "==========================================================\n";
161 cout << "Changing color of: " << myColor1 << endl;;
162 myColor1.SetColorByRGBA(15, 33, 199, 53);
163 cout << "to: " << myColor1 << endl;
164
165
166 cout << "==========================================================\n";
167 cout << "Getting specific colors of " << myColor1 << endl;
168 cout << "Red: " << myColor1.GetRed() <<endl;
169 cout << "Green: " << myColor1.GetGreen()<<endl;
170 cout << "Blue: " << myColor1.GetBlue()<<endl;
171 cout << "Alpha: " << myColor1.GetAlpha()<<endl;
172 cout <<endl;
173
174
175 cout << "Finished" << endl;
176 return 0;
177}
178
int main(int argc, char **argv)
Definition ColorTest.cpp:37
void SetRed(int color)
Definition PColor.cpp:197
int GetRed() const
Definition PColor.cpp:226
void SetColorByName(const std::string &colorname)
Sets color as by its name.
Definition PColor.cpp:257
int GetAlpha() const
Definition PColor.cpp:229
int GetBlue() const
Definition PColor.cpp:228
int GetGreen() const
Definition PColor.cpp:227
unsigned int GetColor() const
Gets 32-bit unsigned int color.
Definition PColor.cpp:395
void SetGreen(int color)
Definition PColor.cpp:204
void SetColorByRGBA(unsigned int color)
Sets color as a 32-bit unsigned int.
Definition PColor.cpp:235
void SetBlue(int color)
Definition PColor.cpp:211
void SetAlpha(int color)
Definition PColor.cpp:218