schemeFor method

HarmonyScheme? schemeFor(
  1. List<Weighted<HarmonyScheme>> schemes, {
  2. HarmonyScheme? drawn,
})

The harmony scheme to use instead of the drawn one, when schemes offers it; null keeps the draw.

Implementation

HarmonyScheme? schemeFor(
  List<Weighted<HarmonyScheme>> schemes, {
  HarmonyScheme? drawn,
}) {
  final want = intent.harmony;
  if (want == null) {
    if (!tonal || drawn == null) return null;
    return drawn == HarmonyScheme.monochrome
        ? drawn
        : HarmonyScheme.analogous;
  }
  return schemes.any((w) => w.value == want && w.weight > 0) ? want : null;
}