arb:: removed angleofs function, 'legacy' variable for the old behavior

This commit is contained in:
Zeno Rogue 2020-06-06 18:41:36 +02:00
parent 0739a7c16e
commit 123b49e0f3
2 changed files with 22 additions and 5 deletions

View File

@ -14,6 +14,8 @@ EX namespace arb {
EX int affine_limit = 200;
EX bool legacy; /* angleofs command */
#if HDR
struct shape {
@ -151,6 +153,7 @@ void shape::build_from_angles_edges() {
int n = isize(angles);
hyperpoint ctr = Hypc;
vector<transmatrix> matrices;
if(!legacy) for(auto& a: angles) a += M_PI;
for(int i=0; i<n; i++) {
matrices.push_back(at);
println(hlog, "at = ", at);
@ -172,6 +175,7 @@ void shape::build_from_angles_edges() {
}
println(hlog, "ctr = ", ctr);
}
if(!legacy) for(auto& a: angles) a -= M_PI;
ctr = normalize(ctr);
for(auto& v: vertices) v = gpushxto0(ctr) * v;
}
@ -296,8 +300,14 @@ EX void load(const string& fname, bool after_sliding IS(false)) {
set_flag(ginf[gArbitrary].flags, qAFFINE, false);
geom3::apply_always3();
}
else if(ep.eat("legacysign.")) {
if(legacy) angleunit *= -1;
}
else if(ep.eat("angleunit(")) angleunit = real(ep.parsepar());
else if(ep.eat("angleofs(")) angleofs = real(ep.parsepar());
else if(ep.eat("angleofs(")) {
angleofs = real(ep.parsepar());
if(!legacy) angleofs = 0;
}
else if(ep.eat("distunit(")) distunit = real(ep.parsepar());
else if(ep.eat("line(")) {
addflag(arcm::sfLINE);
@ -893,6 +903,9 @@ int readArgs() {
shift();
run(args());
}
else if(argis("-arb-legacy")) {
legacy = true;
}
else if(argis("-arb-slider")) {
PHASEFROM(2);
shift();

View File

@ -297,10 +297,14 @@ cld exp_parser::parse(int prio) {
if(result < 0) result = -result;
while(result > 2 * M_PI) result -= 2 * M_PI;
if(result > M_PI) result = 2 * M_PI - result;
res = M_PI - result;
if(extra_params.count("angleofs"))
res -= extra_params["angleofs"];
if(arb::legacy) {
res = M_PI - result;
if(extra_params.count("angleofs"))
res -= extra_params["angleofs"];
}
else
res = result;
if(extra_params.count("angleunit"))
res /= extra_params["angleunit"];