From a37457ead99f2d5c5baca79405d1abe8da8b1cbe Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 2 Jan 2020 16:51:32 +0100 Subject: [PATCH] precise_width for nicer long lines --- config.cpp | 16 +++++++++++++++- graph.cpp | 13 +++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/config.cpp b/config.cpp index 0deb3a68..8eb91fc0 100644 --- a/config.cpp +++ b/config.cpp @@ -296,6 +296,7 @@ EX void initConfig() { addsaver(vid.usingGL, "usingGL", true); addsaver(vid.antialias, "antialias", AA_NOGL | AA_FONT | (ISWEB ? AA_MULTI : AA_LINES) | AA_LINEWIDTH | AA_VERSION); addsaver(vid.linewidth, "linewidth", 1); + addsaver(precise_width, "precisewidth", .5); addsaver(linepatterns::width, "pattern-linewidth", 1); addsaver(vid.scale, "scale", 1); addsaver(vid.xposition, "xposition", 0); @@ -1115,7 +1116,20 @@ EX void showGraphConfig() { dialog::editNumber(vid.linewidth, 0, 10, 0.1, 1, XLAT("line width"), ""); dialog::extra_options = [] () { dialog::addBoolItem("finer lines at the boundary", vid.antialias & AA_LINEWIDTH, 'O'); - dialog::add_action([] () { vid.antialias ^= AA_LINEWIDTH; }); + dialog::add_action([] () { + vid.antialias ^= AA_LINEWIDTH; + }); + + if(vid.antialias & AA_LINEWIDTH) { + dialog::addSelItem("variable width", fts(precise_width), 'M'); + dialog::add_action([] () { + popScreen(); + dialog::editNumber(precise_width, 0, 2, 0.1, 0.5, + XLAT("variable width"), XLAT("lines longer than this value will be split into shorter lines, with width computed separately for each of them.") + ); + }); + } + else dialog::addBreak(100); dialog::addBoolItem("standard graphics", neon_mode == 0, 'A'); dialog::add_action([] { neon_mode = 0; }); diff --git a/graph.cpp b/graph.cpp index 12818100..3724eb79 100644 --- a/graph.cpp +++ b/graph.cpp @@ -3588,9 +3588,18 @@ bool celldrawer::cell_clipped() { return false; } +EX ld precise_width = .5; + EX void gridline(const transmatrix& V1, const hyperpoint h1, const transmatrix& V2, const hyperpoint h2, color_t col, int prec) { - ld d = hdist(h1, h2); - while(d > .5 && d < 100) d /= 2, prec++; + ld d = hdist(V1*h1, V2*h2); + println(hlog, "d = ", d); + while(d > precise_width && d < 100) { + if(!eqmatrix(V1, V2, 1e-6)) { gridline(V1, h1, V1, inverse(V1) * V2 * h2, col, prec); return; } + hyperpoint h = midz(h1, h2); + gridline(V1, h1, V1, h, col, prec); + gridline(V1, h, V1, h2, col, prec); + return; + } #if MAXMDIM >= 4 if(WDIM == 2 && GDIM == 3) { ld eps = cgi.human_height/100;