using namespace std;
int main(
int argc,
char * argv[])
{
if (argc == 2 && !strcmp(argv[1], "-h")) {
cout << "Usage: arithmetic [word] \n\n"
" Where letters of word are in {a, b, c, d, e}\n\n";
exit(0);
}
char the_string[1024] = "cccccccbb";
if (argc == 2) {
Tools::secured_strncpy(the_string, argv[1], 1024);
}
double probabilities[100] = {0.2, 0.1, 0.6, 0.05, 0.05};
double lefts[100] = {0, 0.2, 0.3, 0.9, 0.95};
Color colors[5] = {
Color(0, 0, 255),
Color(0, 255, 0),
Color(255, 0, 0),
Color(0, 255, 255),
Color(255, 255, 0)};
char * pc = the_string;
int h = 0;
double thickness = 0.5 / strlen(the_string);
double left = 0;
double width = 1.0;
double w = 1.0;
double n = 1;
char str[20];
while (*pc) {
int i = *pc - 'a';
left += width * lefts[i];
width *= probabilities[i];
w /= 2.0;
n *= 2;
for (int k = 0; k < n; k++) {
}
board.
drawRectangle(left, -h * thickness, width, 0.9 * thickness);
board.
drawText((left + width / 2.0), -(h + 0.5) * thickness, str);
++h;
++pc;
}
for (int k = 0; k < 5; k++) {
board.
drawRectangle(lefts[k], thickness, probabilities[k], 0.9 * thickness);
}
board.
save(
"arithmetic.svg", PageSize::BoundingBox, 0.0, Unit::Centimeter);
}
Declaration of the Board class.
int main(int argc, char *argv[])
Definition arithmetic.cpp:16
Structure representing an RGB triple.
Definition Color.h:43
Class for EPS, FIG or SVG drawings.
Definition Board.h:61
Board & setFontSize(double fontSize)
Definition Board.cpp:287
void drawRectangle(double left, double top, double width, double height)
Definition Board.cpp:323
void save(const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
Definition Board.cpp:958
Board & setPenColor(const Color &color)
Definition Board.cpp:244
Board & setPenColorRGBi(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
Definition Board.cpp:232
void drawText(double x, double y, const char *text)
Definition Board.cpp:428
Board & setLineWidth(double width)
Definition Board.cpp:274
void clear(const Color &color=Color::Null)
Definition Board.cpp:149
Shape & scaleToWidth(double w, LineWidthFlag lineWidthFlag)
Definition Shape.cpp:85