/// <summary> /// Gets a colour based on a zero-based index within a palette.<br /> /// If the index exceeds the number of elements in the palette, then a remainder index is used instead. /// </summary> /// <param name="palette">The <see cref="ColourPaletteType" /></param> /// <param name="index">The index used to look up a colour</param> /// <returns> /// A <see cref="Color" /> /// </returns> public static Color GetColour(ColourPaletteType palette, int index) { int remainder; List <Color> colourList = colourPalettes[palette].ColorList; Math.DivRem(index, colourList.Count, out remainder); return(colourList[remainder]); }
/// <summary> /// Gets a colour based on a zero-based index within a colour group, within a palette.<br /> /// If the index exceeds the number of elements in the colour group, then a remainder index is used instead. /// </summary> /// <param name="palette">The <see cref="ColourPaletteType" /></param> /// <param name="colourGroup">The <see cref="ColourGroup" /></param> /// <param name="index">The index used to look up a colour</param> /// <returns> /// A <see cref="Color" /> /// </returns> public static Color GetColour(ColourPaletteType palette, ColourGroup colourGroup, int index) { int remainder; var gp = colourPalettes[palette].ColourGroups; List <Color> colourGroupColours = colourPalettes[palette].ColourGroups[colourGroup]; Math.DivRem(index, colourGroupColours.Count, out remainder); return(colourGroupColours[remainder]); }
/// <summary> /// Returns the number of colours in the specified palette, so that we can (for example) /// request them in reverse order. /// </summary> /// <param name="palette">The palette.</param> /// <returns></returns> public static int CountColours(ColourPaletteType palette) { return(colourPalettes[palette].ColorList.Count); }
/// <summary> /// Creates and returns a new instance of a brush based on a zero-based index within a colour group, within a palette.<br /> /// If the index exceeds the number of elements in the colour group, then a remainder index is used instead. /// </summary> /// <param name="palette">The <see cref="ColourPaletteType" /></param> /// <param name="colourGroup">The <see cref="ColourGroup" /></param> /// <param name="index">The index used to look up a colour</param> /// <returns> /// A new instance of a <see cref="SolidColorBrush" /> /// </returns> public static Brush GetNewBrush(ColourPaletteType palette, ColourGroup colourGroup, int index) { return(new SolidColorBrush(GetColour(palette, colourGroup, index))); }