zenilib: zenilib/jni/external/zenilib/zeni_rest/Logo.cpp Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Logo.cpp
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2 * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3 *
4 * zenilib is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * zenilib 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
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <zeni_rest.h>
19
20 #if defined(_DEBUG) && defined(_WINDOWS)
21 #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
22 #define new DEBUG_NEW
23 #endif
24
25 namespace Zeni {
26
27 Logo::Logo(const Point2f &upper_left, const float &height, const Color &logo_color, const Color &text_color)
28 : m_upper_left(upper_left),
29 m_height(height),
30 m_logo_color(logo_color),
31 m_text_color(text_color),
32 m_vbo(new Vertex_Buffer())
33 {
34 create_all();
35 }
36
37 Logo::~Logo() {
38 delete m_vbo;
39 }
40
41 Logo::Logo(const Logo &rhs)
42 : m_upper_left(rhs.m_upper_left),
43 m_height(rhs.m_height),
44 m_logo_color(rhs.m_logo_color),
45 m_text_color(rhs.m_text_color),
46 m_vbo(new Vertex_Buffer())
47 {
48 create_all();
49 }
50
51 Logo & Logo::operator=(const Logo &rhs) {
52 Logo temp(rhs.m_upper_left, rhs.m_height, rhs.m_logo_color, rhs.m_text_color);
53
54 std::swap(m_upper_left, temp.m_upper_left);
55 std::swap(m_height, temp.m_height);
56 std::swap(m_logo_color, temp.m_logo_color);
57 std::swap(m_text_color, temp.m_text_color);
58 std::swap(m_vbo, temp.m_vbo);
59
60 return *this;
61 }
62
63 void Logo::render() {
64 m_vbo->render();
65 }
66
67 Point2f Logo::get_p00(const Point2f &upper_left, const float &/*height*/) {
68 return Point2f(upper_left.x , upper_left.y );
69 }
70 Point2f Logo::get_p10(const Point2f &upper_left, const float &height) {
71 return Point2f(upper_left.x + 0.34f * height, upper_left.y );
72 }
73 Point2f Logo::get_p20(const Point2f &upper_left, const float &height) {
74 return Point2f(upper_left.x + 0.68f * height, upper_left.y );
75 }
76 Point2f Logo::get_p01(const Point2f &upper_left, const float &height) {
77 return Point2f(upper_left.x , upper_left.y + 0.5f * height);
78 }
79 Point2f Logo::get_p11(const Point2f &upper_left, const float &height) {
80 return Point2f(upper_left.x + 0.34f * height, upper_left.y + 0.5f * height);
81 }
82 Point2f Logo::get_p21(const Point2f &upper_left, const float &height) {
83 return Point2f(upper_left.x + 0.68f * height, upper_left.y + 0.5f * height);
84 }
85 Point2f Logo::get_p02(const Point2f &upper_left, const float &height) {
86 return Point2f(upper_left.x , upper_left.y + 1.0f * height);
87 }
88 Point2f Logo::get_p12(const Point2f &upper_left, const float &height) {
89 return Point2f(upper_left.x + 0.34f * height, upper_left.y + 1.0f * height);
90 }
91 Point2f Logo::get_p22(const Point2f &upper_left, const float &height) {
92 return Point2f(upper_left.x + 0.68f * height, upper_left.y + 1.0f * height);
93 }
94 float Logo::get_thickness(const float &height) {
95 return 0.68f / 12.0f * height;
96 }
97
98 void Logo::create_all() {
99 create_z(Point2f(m_upper_left.x - 0.99f * m_height, m_upper_left.y + 0.25f * m_height), 0.5f * m_height);
100 create_e(Point2f(m_upper_left.x - 0.55f * m_height, m_upper_left.y + 0.25f * m_height), 0.5f * m_height);
101 create_n(Point2f(m_upper_left.x - 0.11f * m_height, m_upper_left.y + 0.25f * m_height), 0.5f * m_height);
102 create_i(Point2f(m_upper_left.x + 0.33f * m_height, m_upper_left.y + 0.25f * m_height), 0.5f * m_height);
103 create_p(Point2f(m_upper_left.x + 0.77f * m_height, m_upper_left.y + 0.25f * m_height), 0.5f * m_height);
104 create_e(Point2f(m_upper_left.x + 1.21f * m_height, m_upper_left.y + 0.25f * m_height), 0.5f * m_height);
105 create_x(Point2f(m_upper_left.x + 1.65f * m_height, m_upper_left.y + 0.25f * m_height), 0.5f * m_height);
106 create_logo(m_upper_left, m_height);
107 }
108
109 void Logo::create_logo(const Point2f &upper_left, const float &height) {
110 const Point2f p30(upper_left.x + 0.500f * height, upper_left.y );
111 const Point2f p02(upper_left.x , upper_left.y + 0.333f * height);
112 const Point2f p42(upper_left.x + 0.666f * height, upper_left.y + 0.333f * height);
113 const Point2f p06(upper_left.x , upper_left.y + height);
114 const Point2f p26(upper_left.x + 0.333f * height, upper_left.y + height);
115 const Point2f p66(upper_left.x + height, upper_left.y + height);
116 const float thickness = 0.68f / 30.0f * height;
117
118 create_thick_line(p30, p06, thickness, m_logo_color);
119 create_thick_line(p30, p66, thickness, m_logo_color);
120 create_thick_line(p02, p42, thickness, m_logo_color);
121 create_thick_line(p06, p26, thickness, m_logo_color);
122 create_circle(p30, thickness, m_logo_color, 18);
123 create_circle(p02, thickness, m_logo_color, 18);
124 create_circle(p06, thickness, m_logo_color, 18);
125 create_circle(p26, thickness, m_logo_color, 18);
126 create_circle(p66, thickness, m_logo_color, 18);
127 }
128
129 void Logo::create_z(const Point2f &upper_left, const float &height) {
130 const Point2f p00 = get_p00(upper_left, height);
131 const Point2f p20 = get_p20(upper_left, height);
132 const Point2f p02 = get_p02(upper_left, height);
133 const Point2f p22 = get_p22(upper_left, height);
134 const float thickness = get_thickness(height);
135
136 create_thick_line(p00, p20, thickness, m_text_color);
137 create_thick_line(p20, p02, thickness, m_text_color);
138 create_thick_line(p02, p22, thickness, m_text_color);
139 create_circle(p00, thickness, m_text_color, 12);
140 create_circle(p20, thickness, m_text_color, 12);
141 create_circle(p02, thickness, m_text_color, 12);
142 create_circle(p22, thickness, m_text_color, 12);
143 }
144
145 void Logo::create_e(const Point2f &upper_left, const float &height) {
146 const Point2f p00 = get_p00(upper_left, height);
147 const Point2f p20 = get_p20(upper_left, height);
148 const Point2f p01 = get_p01(upper_left, height);
149 const Point2f p21 = get_p21(upper_left, height);
150 const Point2f p02 = get_p02(upper_left, height);
151 const Point2f p22 = get_p22(upper_left, height);
152 const float thickness = get_thickness(height);
153
154 create_thick_line(p00, p20, thickness, m_text_color);
155 create_thick_line(p00, p02, thickness, m_text_color);
156 create_thick_line(p01, p21, thickness, m_text_color);
157 create_thick_line(p02, p22, thickness, m_text_color);
158 create_circle(p00, thickness, m_text_color, 12);
159 create_circle(p20, thickness, m_text_color, 12);
160 create_circle(p21, thickness, m_text_color, 12);
161 create_circle(p02, thickness, m_text_color, 12);
162 create_circle(p22, thickness, m_text_color, 12);
163 }
164
165 void Logo::create_n(const Point2f &upper_left, const float &height) {
166 const Point2f p00 = get_p00(upper_left, height);
167 const Point2f p20 = get_p20(upper_left, height);
168 const Point2f p02 = get_p02(upper_left, height);
169 const Point2f p22 = get_p22(upper_left, height);
170 const float thickness = get_thickness(height);
171
172 create_thick_line(p00, p02, thickness, m_text_color);
173 create_thick_line(p00, p22, thickness, m_text_color);
174 create_thick_line(p20, p22, thickness, m_text_color);
175 create_circle(p00, thickness, m_text_color, 12);
176 create_circle(p20, thickness, m_text_color, 12);
177 create_circle(p02, thickness, m_text_color, 12);
178 create_circle(p22, thickness, m_text_color, 12);
179 }
180
181 void Logo::create_i(const Point2f &upper_left, const float &height) {
182 const Point2f p00 = get_p00(upper_left, height);
183 const Point2f p10 = get_p10(upper_left, height);
184 const Point2f p20 = get_p20(upper_left, height);
185 const Point2f p02 = get_p02(upper_left, height);
186 const Point2f p12 = get_p12(upper_left, height);
187 const Point2f p22 = get_p22(upper_left, height);
188 const float thickness = get_thickness(height);
189
190 create_thick_line(p00, p20, thickness, m_text_color);
191 create_thick_line(p10, p12, thickness, m_text_color);
192 create_thick_line(p02, p22, thickness, m_text_color);
193 create_circle(p00, thickness, m_text_color, 12);
194 create_circle(p20, thickness, m_text_color, 12);
195 create_circle(p02, thickness, m_text_color, 12);
196 create_circle(p22, thickness, m_text_color, 12);
197 }
198
199 void Logo::create_p(const Point2f &upper_left, const float &height) {
200 const Point2f p00 = get_p00(upper_left, height);
201 const Point2f p10 = get_p10(upper_left, height);
202 const Point2f p01 = get_p01(upper_left, height);
203 const Point2f p11 = get_p11(upper_left, height);
204 const Point2f p02 = get_p02(upper_left, height);
205 const Point2f phc(p10.x, 0.5f * (p10.y + p11.y));
206 const float thickness = get_thickness(height);
207
208 create_thick_line(p00, p10, thickness, m_text_color);
209 create_thick_line(p00, p02, thickness, m_text_color);
210 create_thick_line(p01, p11, thickness, m_text_color);
211 create_circle(p00, thickness, m_text_color, 12);
212 create_circle(p02, thickness, m_text_color, 12);
213 create_hollow_ellipse(phc, Point2f(0.167f * m_height - thickness, 0.125f * m_height - thickness), Point2f(0.167f * m_height + thickness, 0.125f * m_height + thickness), m_text_color, 36, 18);
214 }
215
216 void Logo::create_x(const Point2f &upper_left, const float &height) {
217 const Point2f p00 = get_p00(upper_left, height);
218 const Point2f p20 = get_p20(upper_left, height);
219 const Point2f p02 = get_p02(upper_left, height);
220 const Point2f p22 = get_p22(upper_left, height);
221 const float thickness = get_thickness(height);
222
223 create_thick_line(p00, p22, thickness, m_text_color);
224 create_thick_line(p02, p20, thickness, m_text_color);
225 create_circle(p00, thickness, m_text_color, 12);
226 create_circle(p20, thickness, m_text_color, 12);
227 create_circle(p02, thickness, m_text_color, 12);
228 create_circle(p22, thickness, m_text_color, 12);
229 }
230
231 void Logo::create_thick_line(const Point2f &p0, const Point2f &p1, const float &thickness, const Color &color) {
232 const Vector3f n = (Global::vector_k % (Vector3f(p1.x, p1.y, 0.0f) - Vector3f(p0.x, p0.y, 0.0f))).normalized() * thickness;
233 Quadrilateral<Vertex2f_Color> q( (Vertex2f_Color(Point2f(p0.x - n.x, p0.y - n.y), color)) ,
234 (Vertex2f_Color(Point2f(p0.x + n.x, p0.y + n.y), color)) ,
235 (Vertex2f_Color(Point2f(p1.x + n.x, p1.y + n.y), color)) ,
236 (Vertex2f_Color(Point2f(p1.x - n.x, p1.y - n.y), color)) );
237 Material m("", color);
238 q.fax_Material(&m);
239 m_vbo->fax_Quadrilateral(&q);
240 }
241
242 void Logo::create_circle(const Point2f &p, const float &radius, const Color &color, const size_t &segments, const size_t &begin, const size_t &end) {
243 const float arc = 2.0f * Global::pi / float(segments);
244 Triangle<Vertex2f_Color> t(Vertex2f_Color(p, color),
245 Vertex2f_Color(Point2f(), color),
246 Vertex2f_Color(Point2f(), color));
247 Material m("", color);
248 t.fax_Material(&m);
249
250 for(size_t i = begin; i != segments && i != end; ++i) {
251 const float float_i = float(i);
252 t.b.position.x = p.x - radius * float(sin(arc * float_i));
253 t.b.position.y = p.y - radius * float(cos(arc * float_i));
254 t.c.position.x = p.x - radius * float(sin(arc * (float_i + 1)));
255 t.c.position.y = p.y - radius * float(cos(arc * (float_i + 1)));
256 m_vbo->fax_Triangle(&t);
257 }
258 }
259
260 void Logo::create_hollow_ellipse(const Point2f &p, const Point2f &inner_radius, const Point2f &outer_radius, const Color &color, const size_t &segments, const size_t &begin, const size_t &end) {
261 const float arc = 2.0f * Global::pi / float(segments);
262 Quadrilateral<Vertex2f_Color> q(Vertex2f_Color(p, color),
263 Vertex2f_Color(p, color),
264 Vertex2f_Color(p, color),
265 Vertex2f_Color(p, color));
266 Material m("", color);
267 q.fax_Material(&m);
268
269 for(size_t i = begin; i != segments && i != end; ++i) {
270 const float float_i = float(i);
271 q.a.position.x = p.x - inner_radius.x * float(sin(arc * float_i));
272 q.a.position.y = p.y - inner_radius.y * float(cos(arc * float_i));
273 q.b.position.x = p.x - outer_radius.x * float(sin(arc * float_i));
274 q.b.position.y = p.y - outer_radius.y * float(cos(arc * float_i));
275 q.c.position.x = p.x - outer_radius.x * float(sin(arc * (float_i + 1)));
276 q.c.position.y = p.y - outer_radius.y * float(cos(arc * (float_i + 1)));
277 q.d.position.x = p.x - inner_radius.x * float(sin(arc * (float_i + 1)));
278 q.d.position.y = p.y - inner_radius.y * float(cos(arc * (float_i + 1)));
279 m_vbo->fax_Quadrilateral(&q);
280 }
281 }
282
283 }
Zeni::Logo
Logo.
Definition: Logo.h:42
color
GLuint color
Definition: glew.h:7185
Zeni::Logo::operator=
Logo & operator=(const Logo &rhs)
Definition: Logo.cpp:51
f
GLclampf f
Definition: glew.h:3390
Zeni::Logo::~Logo
~Logo()
Definition: Logo.cpp:37
n
GLclampd n
Definition: glew.h:7287
t
GLdouble GLdouble t
Definition: glew.h:1384
zeni_rest.h
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:293
Zeni::Logo::Logo
Logo(const Point2f &upper_left, const float &height, const Color &logo_color, const Color &text_color)
Definition: Logo.cpp:27
Zeni::Logo::render
void render()
Definition: Logo.cpp:63
Zeni::Global::vector_k
const Vector3f vector_k(0, 0, 1)
k == Vector3f(0, 0, 1)
Definition: Vector3f.h:55
Zeni::Point2f::y
float y
Definition: Coordinate.h:117
Zeni::Global::pi
const float pi
pi == 3.1415926...
Definition: Vector3f.cpp:27
p
GLfloat GLfloat p
Definition: glew.h:14938
Zeni::Vertex_Buffer::fax_Quadrilateral
void fax_Quadrilateral(const Quadrilateral< Vertex2f_Color > *const &quadrilateral)
Give the Vertex_Buffer a copy of a Quadrilateral.
Definition: Vertex_Buffer.cpp:130
Zeni::Point2f::x
float x
Definition: Coordinate.h:117
Zeni::Vertex_Buffer
A Vertex_Buffer that accepts Triangle and Quadrilaterals.
Definition: Vertex_Buffer.h:85
sin
double sin(double x)
Definition: s_sin.c:56
Zeni::Vertex_Buffer::fax_Triangle
void fax_Triangle(const Triangle< Vertex2f_Color > *const &triangle)
Give the Vertex_Buffer a copy of a Triangle.
Definition: Vertex_Buffer.cpp:88
swap
void swap(Zeni::String &lhs, Zeni::String &rhs)
Definition: String.cpp:578
q
GLdouble GLdouble GLdouble GLdouble q
Definition: glew.h:1400
end
GLuint GLuint end
Definition: glew.h:1239
Zeni::Vertex_Buffer::render
void render()
Render the Vertex_Buffer.
Definition: Vertex_Buffer.cpp:243
i
int i
Definition: pngrutil.c:1377
cos
double cos(double x)
Definition: s_cos.c:56
Zeni::Point2f
A 2D Point represented with floats.
Definition: Coordinate.h:98
m
#define m(i, j)
Zeni::Color
Color.
Definition: Color.h:41
m
const GLdouble * m
Definition: glew.h:8385