IngredientDraft¶
Namespace Nfty.Core.Editing in assembly Nfty.Core.
The whole ingredient being edited: identity, layer kind, colorization, the fixed canvas size, and its variants. Every variant's raster is created at IngredientDraft.Canvas — the single source of truth.
Constructors¶
IngredientDraft(string, string, LayerKind, Colorization?, Dimensions, IEnumerable<VariantDraft>)¶
public IngredientDraft(string id, string name, LayerKind kind, Colorization? colorization, Dimensions canvas, IEnumerable<VariantDraft> variants);
Creates a draft ingredient.
Parameters
id(string) - Stable identifier.name(string) - Display name.kind(LayerKind) - Layer kind.colorization(Colorization?) - Color configuration, or null for Custom.canvas(Dimensions) - Canvas size every variant must match.variants(IEnumerable<VariantDraft>) - Initial variants.
Properties¶
Canvas¶
The canvas every variant must match.
Colorization¶
How it is colored; null for a Custom layer.
Id¶
Stable identifier for the ingredient being built.
Kind¶
Which kind of layer this will be.
Name¶
Display name.
Variants¶
The variants being edited.
Methods¶
AddVariant(string, string, double)¶
Adds a blank variant sized to the canvas. A Custom ingredient's variants are authored in color, so one gets a blank ColorMap as well — without it a freshly added Custom variant would have nothing to export.
Parameters
id(string) - Stable identifier.name(string) - Display name.weight(double) - Roll weight.
Returns. The new variant, already added.
DuplicateVariant(string, string, string)¶
Appends a copy of an existing variant (same weight, cloned pixels) under a new id/name. Both rasters are cloned when both exist — copying only the value-map would give a Custom variant a gray ghost for artwork and silently block its save.
Parameters
sourceId(string) - The variant to copy.newId(string) - The copy's identifier.newName(string) - The copy's display name.
Returns. The copy, already added.
Exceptions
InvalidOperationException- The source is absent, or the new id is taken.
RemoveVariant(string)¶
Removes a variant by id. Throws if it is absent (the caller enforces any minimum count).
Parameters
id(string) - Id of the variant to remove.
Exceptions
InvalidOperationException- The ingredient has no variant with that id.