Skip to content

ColorRoller

Namespace Nfty.Core.Generation in assembly Nfty.Ticket.

public static class ColorRoller

Turns a layer's colorization into the color one asset will use.

Methods

FromFixed(string, ColorModel)

public static RolledColor FromFixed(string fixedSpec, ColorModel model);

Resolves a single fixed color spec to its (H, S) deterministically, consuming NO RNG. Used by Static layers, which colorize with exactly one fixed color and no per-asset roll, and by preview, so a rendered preview resolves color exactly as generation does.

Parameters

  • fixedSpec (string) - A prefixed color spec (hex:, rgb:, hsl:, hsv:).
  • model (ColorModel) - Which model hue and saturation are read in; the value or lightness is dropped.

Returns. The hue (degrees) and saturation (0..1) of the color.

Exceptions

  • FormatException - The spec has no prefix, an unknown one, or a malformed body.

Roll(Colorization, IRng)

public static RolledColor Roll(Colorization c, IRng rng);

Rolls a color, consuming RNG.

Parameters

  • c (Colorization) - The layer's colorization.
  • rng (IRng) - The run's RNG.

Returns. The rolled hue and saturation.

SampleHue(ColorRange, double)

public static double SampleHue(ColorRange range, double unit);

The hue this range yields for a unit sample. Split out so UniqueSpace can evaluate the same expression at its endpoints instead of re-deriving the reachable interval algebraically — the count is a promise about what ColorRoller.Roll() produces, and re-derivation is what let the two drift apart before.

Parameters

  • range (ColorRange) - The range being sampled.
  • unit (double) - A value in [0,1), as IRng.NextDouble() produces.

Returns. Hue in degrees.

SampleSat(ColorRange, double)

public static double SampleSat(ColorRange range, double unit);

The saturation this range yields for a unit sample, as the 0..1 fraction RolledColor.S carries. The /100 is not cosmetic: its rounding is baked into the DNA of every Set ever generated, so this is the only definition of the value.

Parameters

  • range (ColorRange) - The range being sampled.
  • unit (double) - A value in [0,1), as IRng.NextDouble() produces.

Returns. Saturation as a 0..1 fraction.