Skip to content

VariantDraft

Namespace Nfty.Core.Editing in assembly Nfty.Core.

public sealed class VariantDraft

An editable variant: identity + weight + its pixels, in one or both of the two forms a variant can be authored in.

Remarks

A variant carries a grayscale VariantDraft.Map always, and a full-color VariantDraft.Color once it has been painted or imported in color mode. Which one is authoritative is decided by the owning IngredientDraft.Kind and never by which happens to be non-null: a Custom ingredient exports its VariantDraft.Color, everything else exports its VariantDraft.Map.

Both are kept rather than one replacing the other because that is precisely what the non-destructive save needs. Painting a Dynamic layer in color leaves its value-map untouched — so the original ingredient stays byte-identical on disk — while the color map becomes a new Custom ingredient beside it.

Constructors

VariantDraft(string, string, double, ValueMap, ColorMap?)

public VariantDraft(string id, string name, double weight, ValueMap map, ColorMap? color = null);

Creates a variant being edited.

Parameters

  • id (string) - Stable identifier.
  • name (string) - Display name.
  • weight (double) - Roll weight.
  • map (ValueMap) - Its grayscale pixels.
  • color (ColorMap?) - Its full-color pixels, or null for a variant not authored in color.

Properties

Color

public ColorMap? Color { get; set; }

The editable full-color pixels, or null while this variant has only ever been a value-map. Set when color mode is entered, and the only thing a Custom layer exports.

Id

public string Id { get; }

Stable identifier, unique within the draft.

Map

public ValueMap Map { get; }

The editable grayscale pixels — what a Dynamic or Static layer is authored in.

Name

public string Name { get; set; }

Display name.

Weight

public double Weight { get; set; }

Roll weight; zero shelves the variant.

Methods

EnsureColor()

public ColorMap EnsureColor();

The variant's color pixels, widening its value-map on first use so entering color mode shows the drawing that is already there rather than a blank canvas. Idempotent: once a color map exists it is returned untouched, so re-entering color mode never discards paint.

Returns. This variant's color map.