Skip to content

RomanSoloweow/Avalonia.ColorGenerator

Repository files navigation

NuGet Pre Release

Avalonia.ColorGenerator

Generates a number for choosing a color from a ready set.

Usage example (application with color display)

 ColorGenerator generator = new();

Get random color

ColorWithValue value = generator.Next();

Get random unique color (in case of overflow, the list will start over or be re-formed depending on the flag)

ColorWithValue value = generator.NextUnique();

You can implement your own set of colors for the generator by implementing the interface

public interface IColorsPack
{
    int CountColors();
    ColorDefinition GetColor(int colorNumber);
    ColorDefinition GetColor(string colorName);
}

Fields of color:

  • Color - Color for SolidColorBrush or other
  • Name - name of current color
  • Index - index of current color
  • Hex - Color Hex format

License📑

Licensed under the MIT license.