#include <cstdlib>
using namespace LibBoard;
void drawFern(
Board & b,
unsigned int iterations)
{
double x = 0.0;
double y = 0.0;
double nx, ny;
double radius = 2.0;
while (iterations--) {
double g = rand() / static_cast<double>(RAND_MAX);
if (g < .01) {
nx = 0;
ny = 0.16 * y;
} else if (g < .08) {
nx = 0.2 * x - 0.26 * y;
ny = 0.23 * x + 0.22 * y + 1.6;
} else if (g < 0.15) {
nx = -0.15 * x + 0.28 * y;
ny = 0.26 * x + 0.24 * y + 0.44;
} else {
radius /= 2.0;
nx = 0.85 * x + 0.04 * y;
ny = -0.04 * x + 0.85 * y + 1.6;
}
x = nx;
y = ny;
}
}
int main(int, char *[])
{
srand(static_cast<unsigned int>(time(nullptr)));
drawFern(board, 1 << 17);
board.
saveEPS(
"fern.eps", Board::A4);
board.
saveSVG(
"fern.svg", Board::A4);
}
void saveEPS(std::ostream &out, PageSize size=Board::BoundingBox, double margin=0.0, Unit unit=UMillimeter, const std::string &title=std::string()) const
Definition: Board.cpp:532
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=0.0, Unit unit=UMillimeter) const
Definition: Board.cpp:758