00001 #include <iostream>
00002 #include <sstream>
00003
00004 #include "hex.h"
00005 #include "hexsvg.h"
00006 #include "hexmove.h"
00007
00008 using namespace std;
00009
00010
00011 int main()
00012 {
00013 using namespace hex;
00014 hex::Grid g(10,10);
00015 hex::svg::Document d(g);
00016 std::ostringstream os;
00017 hex::Point margin(0.5,0.5);
00018 d.p0 -= margin;
00019 d.p1 += margin;
00020 os<<d.header();
00021
00022 hex::Area a =hex::Path(g.hex(1,1),g.hex(7,4)).to_area();
00023
00024 hex::Boundary b =a.boundary();
00025
00026
00027 Area r =hex::range(g.hex(5,5),2);
00028 r.style="fill:#ddf; stroke:#99f; stroke-width:0.04";
00029 os<<d.draw_complex_area(r,+0.5);
00030
00031
00032
00033 os<<"<g style=\"fill:none; stroke:green; stroke-width:0.04\">\n";
00034 float bias=0.04;
00035
00036 a.style="stroke:red";
00037 os<<d.draw_complex_area( a, bias );
00038 os<<"</g>\n";
00039
00040 Area ga =g.to_area();
00041 ga.style="fill:none; stroke:gray; stroke-width:0.01";
00042 os<<d.draw_skeleton( ga, true );
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 hex::move::Topography move(1);
00057 move.increase_cost(r,2);
00058 move.increase_cost(a,100);
00059 cerr<<a.str()<<endl;
00060 hex::Path bp =move.best_path( g.hex(1,3),g.hex(8,5) );
00061 bp.style="fill:none;stroke:#33f; stroke-width:0.08; marker-end:url(#Triangle)";
00062 os<<d.draw_path(bp);
00063 hex::Area hz =move.horizon( g.hex(1,3), 3 );
00064 hz.style="fill:none;stroke:#33f; stroke-width:0.04; marker-end:url(#Triangle)";
00065 os<<d.draw_simple_area(hz);
00066
00067 os<<d.footer();
00068
00069 cout<<os.str()<<endl;
00070
00071 return 0;
00072 }