1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 21:07:17 +00:00

arb:: symmetries

This commit is contained in:
Zeno Rogue 2020-05-31 03:24:41 +02:00
parent 6de3bface4
commit 18d4165f64
2 changed files with 20 additions and 1 deletions

View File

@ -27,6 +27,7 @@ struct shape {
void build_from_angles_edges();
vector<pair<int, int> > sublines;
vector<pair<ld, ld>> stretch_shear;
int repeat_value;
};
struct arbi_tiling {
@ -154,6 +155,7 @@ EX void load_tile(exp_parser& ep, bool unit) {
auto& cc = current.shapes.back();
cc.id = isize(current.shapes) - 1;
cc.flags = 0;
cc.repeat_value = 1;
while(ep.next() != ')') {
cld dist = 1;
if(!unit) {
@ -341,6 +343,22 @@ EX void load(const string& fname) {
}
}
}
else if(ep.eat("repeat(")) {
int i = ep.iparse(0);
verify_index(i, c.shapes, ep);
ep.force_eat(",");
int rep = ep.iparse(0);
ep.force_eat(")");
auto& sh = c.shapes[i];
int N = isize(sh.angles);
if(N % rep)
throw hr_parse_exception("repeat value should be a factor of the number of vertices, " + ep.where());
sh.repeat_value = rep;
int d = N / rep;
for(int i=d; i<N; i++)
sh.connections[i] = sh.connections[i-d];
}
else if(ep.eat("debug(")) {
int i = ep.iparse(0);
verify_index(i, c.shapes, ep);

View File

@ -586,6 +586,7 @@ EX namespace patterns {
int id;
int dir;
bool reflect;
/** 1 if no symmetries, more otherwise */
int symmetries;
};
#endif
@ -1031,7 +1032,7 @@ EX namespace patterns {
if(arb::in()) {
si.id = arb::id_of(c->master);
si.dir = 0;
si.symmetries = 1;
si.symmetries = arb::current.shapes[si.id].repeat_value;
si.reflect = false;
return si;
}