1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-09-27 13:48:15 +00:00

'single color' now works better with live canvas

This commit is contained in:
Zeno Rogue 2024-05-27 13:38:33 +02:00
parent bfacda7207
commit 8321751cb0
2 changed files with 12 additions and 5 deletions

View File

@ -962,7 +962,7 @@ EX void initConfig() {
-> editable(0, 1, 0.05, "tree-drawing parameter", "How much of edges to draw for tree patterns (to show how the tree edges are oriented).", 't');
// param_char(patterns::whichCanvas, "whichCanvas", 0); %TODO
param_i(ccolor::rwalls, "randomwalls");
param_f(ccolor::rwalls, "randomwalls");
param_b(vid.grid, "grid");
param_b(models::desitter_projections, "desitter_projections", false);

View File

@ -1564,7 +1564,7 @@ EX namespace ccolor {
EX int jhole = 0;
EX int jblock = 0;
EX int rwalls = 50;
EX ld rwalls = 50;
EX bool live_canvas;
EX void edit_rwalls() {
@ -1651,10 +1651,17 @@ EX namespace ccolor {
0x404040, 0x606060, 0x808080
});
EX map<cell*, pair<int, ld>> percentages;
auto pct_hook = addHook(hooks_clearmemory, 40, [] { percentages = {}; });
EX data plain = data("single color", always_available, CCO {
color_t r = isize(cco.ctab) == 1 ? cco.ctab[0] : cco.ctab[cco.ctab.size()];
if(hrand(100) < rwalls) r |= 0x1000000;
if(c == cwt.at) r &= 0xFFFFFF;
if(!percentages.count(c)) {
percentages[c].first = hrand(1000000);
percentages[c].second = c == cwt.at ? 100 : hrand(10000) / 100.;
}
auto& p = percentages[c];
color_t r = cco.ctab[gmod(p.first, cco.ctab.size())];
if(p.second < rwalls) r |= 0x1000000;
return r;
},
{linf[laCanvas].color >> 2});