From ca3232c3bbd25bd03214f3f931f75999225d8d33 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 18 Jan 2020 17:11:57 +0100 Subject: [PATCH] extended 'linewidth' setting: illustration mode, hint about Alt, disable shadows, bright mode, colorblind simulation --- celldrawer.cpp | 18 +++++++++++++++++- config.cpp | 11 +++++++++++ drawing.cpp | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/celldrawer.cpp b/celldrawer.cpp index 28fe4266..476540c2 100644 --- a/celldrawer.cpp +++ b/celldrawer.cpp @@ -567,8 +567,23 @@ void celldrawer::setcolors() { if(!wmspatial && snakelevel(c) && !realred(c->wall)) fcol = wcol; if(c->wall == waGlass && !wmspatial) fcol = wcol; + + if(neon_mode == 4) { + fcol = highwall(c) ? w_monochromatize(fcol, 0) : w_monochromatize(fcol, 1); + wcol = w_monochromatize(wcol, 0); + if(c->land == laWarpCoast && !pseudohept(c) && c->wall == waNone) fcol = 0x707070; + } } +EX color_t w_monochromatize(color_t x, int d) { + int c = part(x,2) + part(x,1) + part(x, 0) + 1; + c /= 3; + if(d == 0) c = c; + else c = (c + 2 * 255) / 3; + return c * 0x10101; + } + + void celldrawer::tune_colors() { if(inmirror(c)) { // for debugging @@ -708,7 +723,7 @@ void celldrawer::draw_wall() { } else { forCellIdEx(c2, i, c) - if(!highwall(c2) || conegraph(c2)) { + if(!highwall(c2) || conegraph(c2) || neon_mode == 4) { if(placeSidewall(c, i, SIDE_WALL, V, darkena(wcol2, fd, alpha))) break; } } @@ -2451,6 +2466,7 @@ void celldrawer::draw() { ct6 = ctof(c); #endif fd = getfd(c); + if(neon_mode == 4) fd = 0; error = false; setcolors(); diff --git a/config.cpp b/config.cpp index f225ee15..82dc823f 100644 --- a/config.cpp +++ b/config.cpp @@ -641,6 +641,9 @@ EX void initConfig() { addsaver(nilv::nilperiod[2], "nilperiod_z"); addsaver(neon_mode, "neon_mode"); + addsaver(noshadow, "noshadow"); + addsaver(bright, "bright"); + addsaver(cblind, "cblind"); callhooks(hooks_configfile); @@ -1144,6 +1147,14 @@ EX void showGraphConfig() { dialog::add_action([] { neon_mode = 2; }); dialog::addBoolItem("neon mode II", neon_mode == 3, 'D'); dialog::add_action([] { neon_mode = 3; }); + dialog::addBoolItem("illustration mode", neon_mode == 4, 'E'); + dialog::add_action([] { neon_mode = 4; }); + dialog::addBreak(100); + dialog::addInfo(XLAT("hint: press Alt while testing modes")); + dialog::addBreak(100); + dialog::addBoolItem_action("disable shadows", noshadow, 'F'); + dialog::addBoolItem_action("bright mode", bright, 'G'); + dialog::addBoolItem_action("colorblind simulation", cblind, 'H'); }; } diff --git a/drawing.cpp b/drawing.cpp index e3aac538..317451b6 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2028,6 +2028,25 @@ EX void apply_neon(color_t& col, int& r) { #if CAP_SHAPES +EX color_t magentize(color_t x) { + if(neon_mode != 4) return x; + int green = part(x,2); + int magenta = (part(x, 1) + part(x, 3)) / 2; + int nm = max(magenta, green); + int gm = (magenta + green)/2; + nm = (nm + 255) / 2; + gm = gm / 2; + + return (nm * 0x1000100) | (gm * 0x10000) | (part(x, 0)); + } + +EX color_t monochromatize(color_t x) { + int c = part(x,2) + part(x,1) + part(x, 3); + c ++; + c /= 3; + return c * 0x1010100 | (part(x, 0)); + } + EX dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, PPR prio) { if(prio == PPR::DEFAULT) prio = h.prio; @@ -2072,6 +2091,19 @@ EX dqi_poly& queuepolyat(const transmatrix& V, const hpcshape& h, color_t col, P if(col == 0xFF) ptd.outline = 0xFFFFFFFF; if(poly_outline != 0xFF) ptd.outline = poly_outline; break; + case 4: { + if(poly_outline > 0xFF) { + ptd.color = magentize(col); + ptd.outline = 0xFF; + } + else { + ptd.outline = poly_outline; + ptd.color = monochromatize(col); + } + if(ptd.color & 0xFF) ptd.color |= 0xFF; + if(ptd.outline & 0xFF) ptd.outline |= 0xFF; + break; + } } ptd.linewidth = vid.linewidth; ptd.flags = h.flags;