TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ollm/opencomic-ai-training/llms.txt
Use this file to discover all available pages before exploring further.
options module is the default export from src/options.mts and acts as the central configuration manager for the entire dataset generation pipeline. It reads YAML config files from disk, recursively merges any file: field references (allowing large configs to be split across multiple files), creates a seeded main RandGenerator keyed 'options', prepares all output directories, and stores the resulting Options object in module-level state. Once an image is about to be generated, setCurrentImageRand() seeds a fresh per-image generator and randomize() resolves all Rand fields deterministically before any Krita calls are made.
options.load()
Reads and parses a YAML options file, resolves all file: includes, creates the main random generator, prepares output directories, and stores the result in module state.
Absolute path to the root YAML options file on disk.
- Reads and parses the YAML file at
fileusing theyamlpackage. - Recursively calls
loadFiles()on every object and array in the parsed data. Any entry that contains afile:key is loaded from that path and merged (or spread, if the loaded file is an array) in place. - Creates a
RandGeneratorviarand.randByKey('options', data.seed)and stores it asdata.mainRand. - For each entry in
data.degradations, resolves theoutput.clean,output.degraded, andoutput.optionspaths via theresolvehelper and creates any missing directories withfs.mkdirSync(..., { recursive: true }). - Stores the completed
Optionsobject in the module-leveloptionsvariable and returns it.
All
Rand fields in the returned object are not yet resolved — they still
hold their raw config values. Call setCurrentImageRand() and then
randomize() before using any randomisable field.options.setCurrentImageRand()
Seeds the per-image random generator so that randomize() produces a deterministic, image-specific sequence of values.
The 1-based index of the image about to be generated.
RandGenerator is created via rand.randByKey('image-' + image, seed) and stored as options.currentImageRand. The raw numeric seed is also stored as options.imageSeed.
This must be called before every call to
options.randomize(). Because
the seed is derived purely from the image index and the global seed, re-calling
setCurrentImageRand(n) at any point will reproduce the same per-image
sequence, which is useful for resuming interrupted runs.options.randomize()
Recursively walks an options object and resolves all Rand values in place using the current image RNG.
The object (or sub-object) to randomize. Typically a deep clone of the raw
Options config or one of its sub-sections such as options.base or
options.postProcessing.How many levels deep to recurse. Pass
-1 (the default) for unlimited depth.Internal recursion counter. Do not pass this manually.
| Value shape | Behaviour |
|---|---|
Key is prob | Evaluated by rand.prob() — resolved to true or false. |
Array whose first element is a number, string, or null | If it is a two-element all-numeric array it is treated as a [from, to] range; otherwise a single element is chosen at random. |
Array of objects with if field | The first object whose if condition matches the current values map is selected; its value is then passed through rand.generate(). |
Array of objects with prob field | Filtered by rand.probFilter() before recursing — items whose probability does not fire are removed. |
Single object with weight or prob field | Resolved directly by rand.generate(). |
Key is brush without a name set | After recursing, a brush preset name is drawn from krita.presets filtered by the resolved category and any disabled-brush lists (BRUSHES_WITH_STRANGE_PATTERNS, optionally BRUSHES_WITH_PIXELATED_EDGES). |
| Plain object (none of the above) | Recurses into it (up to depth levels). |
options.setValues()
Flattens the leaf values of an object into a dot-notation key map. These entries are consulted by the if condition evaluator inside randomize().
The object whose leaf values should be stored in the condition map.
Optional dot-notation prefix to prepend to every key. Defaults to
'' (no
prefix). For example, passing 'inKrita.halftone' stores keys such as
inKrita.halftone.angle.values map (Map<string, any>). An if expression such as "base.colored == true" is split on spaces and the left operand is looked up in this map at condition-check time.
options.resetValues()
Clears the if-condition values map, discarding any values accumulated by previous setValues() calls.
drawing.generateImage() calls resetValues() automatically at the top of each invocation.
options.get()
Returns the currently loaded Options object, or undefined if load() has not yet been called.
options.values (getter)
Returns the live Map<string, any> of flattened condition values populated by setValues().
if expressions in your config.
Full usage example
The following shows the typical per-image lifecycle: load the config once at startup, then for every image set the per-image RNG, deep-clone the config, randomize it, and pass it to the drawing step.In normal operation you do not need to call
setCurrentImageRand(),
resetValues(), or randomize() manually — drawing.generateImage()
invokes all three internally before any drawing begins.