diff --git a/arbitrile.cpp b/arbitrile.cpp index 812dbacd..3d0e2898 100644 --- a/arbitrile.cpp +++ b/arbitrile.cpp @@ -127,6 +127,35 @@ template void verify_index(int index, const T& v, exp_parser& ep) { if( string unnamed = "unnamed"; +EX void load_tile(exp_parser& ep, bool unit) { + current.shapes.emplace_back(); + auto& cc = current.shapes.back(); + cc.id = isize(current.shapes) - 1; + cc.flags = 0; + while(ep.next() != ')') { + ld dist = 1; + if(!unit) { + dist = ep.rparse(0); + ep.force_eat(","); + } + ld angle = ep.rparse(0); + cc.edges.push_back(real(dist * ep.extra_params["distunit"])); + cc.angles.push_back(real(angle * ep.extra_params["angleunit"] + ep.extra_params["angleofs"])); + if(ep.eat(",")) continue; + else if(ep.eat(")")) break; + else throw hr_parse_exception("expecting , or )"); + } + try { + cc.build_from_angles_edges(); + } + catch(hr_parse_exception& ex) { + throw hr_parse_exception(ex.s + ep.where()); + } + cc.connections.resize(cc.size()); + for(int i=0; i