Let a chain stage be switched off without taking it apart
Trying a stage out meant removing it and building it again from scratch, settings and all, to see what the picture looked like without it. A stage now carries an `enabled` flag and can simply be switched off: it keeps its place in the chain and everything it was set to. `enabledStages` is the one place that reads the flag, and renderChain, chainNeedsSources, chainTitle and chainSlug all go through it. A disabled stage is skipped whole — handed no image and drawing nothing from the shared rng — so switching one off renders byte for byte what the chain rendered before that stage was added, which is the only thing that makes the switch worth anything while comparing. Whichever stage runs first is the one handed the sources, so disabling a leading scanlines lets blur lead and the chain needs no images at all. The status line and the generated file name follow too: they name what was rendered, not what sits in the sidebar. A chain with every stage disabled throws rather than quietly rendering nothing. In the interface it is a check on the chain row: the row dims, the params heading says "(off)" and the settings stay editable — a stage being worked on is not the same as one being deleted. On the command line it is `--disable NAME`, which picks its stage by effect name exactly as the params do. A project writes `"enabled": false` only for a stage that is off, so existing project files are unchanged and an ordinary one stays uncluttered. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "cli/options.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <charconv>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
@@ -89,6 +90,10 @@ Options parseOptions(int argc, char** argv) {
|
||||
std::to_string(kMinDpi) + "-" + std::to_string(kMaxDpi));
|
||||
}
|
||||
options.dpi = static_cast<int>(dpi);
|
||||
} else if (arg == "--disable") {
|
||||
const std::string name = requireValue(argc, argv, i, arg);
|
||||
effectByName(name); // validate now, exactly as -e does
|
||||
options.disabled.push_back(name);
|
||||
} else if (arg == "--seed") {
|
||||
const std::string value = requireValue(argc, argv, i, arg);
|
||||
long seed = 0;
|
||||
@@ -176,6 +181,7 @@ std::string usage(const char* programName) {
|
||||
<< " --format NAME canvas format, overrides --size (see below)\n"
|
||||
<< " --dpi N resolution of a print format, " << kMinDpi << "-" << kMaxDpi
|
||||
<< " (default: " << kDefaultDpi << ")\n"
|
||||
<< " --disable NAME keep this effect in the chain but skip it\n"
|
||||
<< " --seed N random seed (default: random)\n"
|
||||
<< " --list-effects list available effects and exit\n"
|
||||
<< " -h, --help show this help and exit\n";
|
||||
@@ -207,6 +213,8 @@ std::vector<ChainStage> buildChain(const Options& options) {
|
||||
ChainStage stage;
|
||||
stage.effect = effectByName(name);
|
||||
stage.values = stage.effect->defaults();
|
||||
stage.enabled = std::find(options.disabled.begin(), options.disabled.end(), name) ==
|
||||
options.disabled.end();
|
||||
for (const auto& spec : stage.effect->params()) {
|
||||
const auto it = options.params.find(spec.key);
|
||||
if (it != options.params.end()) stage.values[spec.key] = it->second;
|
||||
|
||||
Reference in New Issue
Block a user