5
#define M_PI_2 1.57079632679489661923 /* pi/2 */
10
#include "libdisplay/libdisplay.h"
12
Symbol::Symbol(const unsigned char color[3],
13
const int x, const int y, const int r)
14
: Annotation(color), x_(x), y_(y), r_(r)
25
Symbol::DrawCircle(DisplayBase *display, const int r,
26
const unsigned char color[3])
30
double dd = 1 / (M_PI_2 * r);
31
for (double d = 0; d < M_PI_2; d += dd)
33
xx = static_cast<int>(cos(d) * r + 0.5);
34
yy = static_cast<int>(sin(d) * r + 0.5);
35
double opacity = (xx * xx + yy * yy) / r2;
36
if (opacity > 1) opacity = 1/opacity;
38
display->setPixel(x_ + xx, y_ + yy, color, opacity);
39
display->setPixel(x_ - xx, y_ + yy, color, opacity);
40
display->setPixel(x_ + xx, y_ - yy, color, opacity);
41
display->setPixel(x_ - xx, y_ - yy, color, opacity);
43
display->setPixel(x_, y_ + r, color);
44
display->setPixel(x_, y_ - r, color);
48
Symbol::Draw(DisplayBase *display)
50
unsigned char black[3] = { 0, 0, 0 };
51
DrawCircle(display, r_ - 1, black);
52
DrawCircle(display, r_ + 1, black);
54
DrawCircle(display, r_, color_);