 |
HilVert
1v2
A demo of the Hilbert Curve in SVG.
|
Go to the documentation of this file.
142 crvOrd{src.crvOrd - 1},
217 default:
return e =
right;
246 default:
return e =
left;
325 static string errtxt{
"not_known"};
399 bool rpete{
hdng == oldhdg};
400 if (rpete) ++mple;
else if (
osink !=
nullptr && oldhdg !=
stard) {
402 *
osink << ((oldhdg ==
up || oldhdg ==
down) ?
'v' :
'h');
403 *
osink << ((oldhdg ==
left || oldhdg ==
up ) ?
"-" :
"");
574 std::map<string, HVenm> m {
582 if (
ofs.is_open())
ofs.close();
584 if (
ofs.is_open()) os = &
ofs;
else
589 if (m.count(argv[2])) hd = m[argv[2]];
else return HVenm::errHdng;
592 co = std::atoi(argv[1]);
611 return "HilVert: 1v2";
680 auto shigh{clsSde *
segPx};
681 auto vside{shigh +
segPx};
682 auto dst{(clsSde * clsSde - 1) *
segPx};
683 auto sda{(dst * 11) / 10 + 6};
684 auto dtime{sda / 40 + 3};
691 if (
osink ==
nullptr)
return;
693 "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
694 "<!-- Generator: " <<
vers() <<
" -->\n<svg\n" <<
695 "\txmlns=\"http://www.w3.org/2000/svg\"\n" <<
696 "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" <<
697 "\tviewBox=\"0 0 " << vside <<
' ' << vside <<
"\"\n" <<
700 "\t\tid=\"pth\"\n" <<
701 "\t\tstroke=\"blue\"\n" <<
702 "\t\tfill=\"yellow\"\n" <<
703 "\t\tstroke-width=\"1px\"\n" <<
704 "\t\tstroke-dasharray=\"" << sda <<
"\"\n" <<
707 << (r || (!l && u ^ cw) ?
segPx : shigh)
709 << (d || (!u && r ^ cw) ?
segPx : shigh)
716 "\t\tid=\"sdo\"\n" <<
717 "\t\txlink:href=\"#pth\"\n" <<
718 "\t\tattributeName=\"stroke-dashoffset\"\n" <<
719 "\t\tfrom=\"" << sda <<
"\"\n" <<
721 "\t\tbegin=\"2s\"\n" <<
722 "\t\tdur=\"" << dtime <<
"s\"\n" <<
723 "\t\tfill=\"freeze\"\n" <<
724 "\t\trepeatCount=\"indefinite\"\n" <<
void draw()
Output the SVG line segments for a complete HC.
void grfc()
Output a complete HC in Scaleable Vector Graphic format.
const std::string & errs(HVenm erno)
Translate an error code to a text string.
Hen & operator--(Hen &e)
Turn to the left of the current heading.
Generate SVG visualisations of the Hilbert Curve (HC).
static constexpr int segPx
static const std::map< HVenm, std::string > errTyp
std::string vers()
Generate the version number for HilVert.
All declarations for the HilVert class.
static constexpr int linSegsCrd
void sgmnt()
Draw a path segment.
constexpr auto widdershins
HilVert(int curvOrd=1, HVenm heading=HVenm::down, HVenm rotation=HVenm::clockwise, std::ostream *outSink=&std::cout)
void turnExe(HVenm sense)
Alter the current heading by 90 degrees.
auto & operator++(Hen &e)
Turn to the right of the current heading.
HilVert::HVenm cmndLn(int argc, const char *argv[])
This is called by the main() function to set up the HilVert object.
void drawChld(HVenm flipRot)
auto & operator^=(Hen &e, const bool &b)
Swap clockwise with anticlock on condition.