External/OxyPlot/OxyPlot/Foundation/OxyPalettes.cs
author StephaneLenclud
Tue, 03 Feb 2015 10:14:18 +0100
branchMiniDisplay
changeset 450 f2d8620e2434
permissions -rw-r--r--
Rebracer update.
moel@391
     1
// --------------------------------------------------------------------------------------------------------------------
moel@391
     2
// <copyright file="OxyPalettes.cs" company="OxyPlot">
moel@391
     3
//   The MIT License (MIT)
moel@391
     4
//
moel@391
     5
//   Copyright (c) 2012 Oystein Bjorke
moel@391
     6
//
moel@391
     7
//   Permission is hereby granted, free of charge, to any person obtaining a
moel@391
     8
//   copy of this software and associated documentation files (the
moel@391
     9
//   "Software"), to deal in the Software without restriction, including
moel@391
    10
//   without limitation the rights to use, copy, modify, merge, publish,
moel@391
    11
//   distribute, sublicense, and/or sell copies of the Software, and to
moel@391
    12
//   permit persons to whom the Software is furnished to do so, subject to
moel@391
    13
//   the following conditions:
moel@391
    14
//
moel@391
    15
//   The above copyright notice and this permission notice shall be included
moel@391
    16
//   in all copies or substantial portions of the Software.
moel@391
    17
//
moel@391
    18
//   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
moel@391
    19
//   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
moel@391
    20
//   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
moel@391
    21
//   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
moel@391
    22
//   CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
moel@391
    23
//   TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
moel@391
    24
//   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
moel@391
    25
// </copyright>
moel@391
    26
// <summary>
moel@391
    27
//   Provides predefined palettes.
moel@391
    28
// </summary>
moel@391
    29
// --------------------------------------------------------------------------------------------------------------------
moel@391
    30
namespace OxyPlot
moel@391
    31
{
moel@391
    32
    /// <summary>
moel@391
    33
    /// Provides predefined palettes.
moel@391
    34
    /// </summary>
moel@391
    35
    public static class OxyPalettes
moel@391
    36
    {
moel@391
    37
        /// <summary>
moel@391
    38
        /// Initializes static members of the <see cref="OxyPalettes"/> class.
moel@391
    39
        /// </summary>
moel@391
    40
        static OxyPalettes()
moel@391
    41
        {
moel@391
    42
            BlueWhiteRed31 = BlueWhiteRed(31);
moel@391
    43
            Hot64 = Hot(64);
moel@391
    44
            Hue64 = Hue(64);
moel@391
    45
        }
moel@391
    46
moel@391
    47
        /// <summary>
moel@391
    48
        /// Gets the blue white red (31) palette.
moel@391
    49
        /// </summary>
moel@391
    50
        public static OxyPalette BlueWhiteRed31 { get; private set; }
moel@391
    51
moel@391
    52
        /// <summary>
moel@391
    53
        /// Gets the hot (64) palette.
moel@391
    54
        /// </summary>
moel@391
    55
        public static OxyPalette Hot64 { get; private set; }
moel@391
    56
moel@391
    57
        /// <summary>
moel@391
    58
        /// Gets the hue64 palette.
moel@391
    59
        /// </summary>
moel@391
    60
        public static OxyPalette Hue64 { get; private set; }
moel@391
    61
moel@391
    62
        /// <summary>
moel@391
    63
        /// Creates a black/white/red palette with the specified number of colors.
moel@391
    64
        /// </summary>
moel@391
    65
        /// <param name="numberOfColors">
moel@391
    66
        /// The number of colors to create for the palette.
moel@391
    67
        /// </param>
moel@391
    68
        /// <returns>
moel@391
    69
        /// A palette.
moel@391
    70
        /// </returns>
moel@391
    71
        public static OxyPalette BlackWhiteRed(int numberOfColors)
moel@391
    72
        {
moel@391
    73
            return OxyPalette.Interpolate(numberOfColors, OxyColors.Black, OxyColors.White, OxyColors.Red);
moel@391
    74
        }
moel@391
    75
moel@391
    76
        /// <summary>
moel@391
    77
        /// Creates a blue/white/red palette with the specified number of colors.
moel@391
    78
        /// </summary>
moel@391
    79
        /// <param name="numberOfColors">
moel@391
    80
        /// The number of colors to create for the palette.
moel@391
    81
        /// </param>
moel@391
    82
        /// <returns>
moel@391
    83
        /// A palette.
moel@391
    84
        /// </returns>
moel@391
    85
        public static OxyPalette BlueWhiteRed(int numberOfColors)
moel@391
    86
        {
moel@391
    87
            return OxyPalette.Interpolate(numberOfColors, OxyColors.Blue, OxyColors.White, OxyColors.Red);
moel@391
    88
        }
moel@391
    89
moel@391
    90
        /// <summary>
moel@391
    91
        /// Creates a 'cool' palette with the specified number of colors.
moel@391
    92
        /// </summary>
moel@391
    93
        /// <param name="numberOfColors">
moel@391
    94
        /// The number of colors to create for the palette.
moel@391
    95
        /// </param>
moel@391
    96
        /// <returns>
moel@391
    97
        /// A palette.
moel@391
    98
        /// </returns>
moel@391
    99
        public static OxyPalette Cool(int numberOfColors)
moel@391
   100
        {
moel@391
   101
            return OxyPalette.Interpolate(numberOfColors, OxyColors.Cyan, OxyColors.Magenta);
moel@391
   102
        }
moel@391
   103
moel@391
   104
        /// <summary>
moel@391
   105
        /// Creates a gray-scale palette with the specified number of colors.
moel@391
   106
        /// </summary>
moel@391
   107
        /// <param name="numberOfColors">
moel@391
   108
        /// The number of colors to create for the palette.
moel@391
   109
        /// </param>
moel@391
   110
        /// <returns>
moel@391
   111
        /// A palette.
moel@391
   112
        /// </returns>
moel@391
   113
        public static OxyPalette Gray(int numberOfColors)
moel@391
   114
        {
moel@391
   115
            return OxyPalette.Interpolate(numberOfColors, OxyColors.Black, OxyColors.White);
moel@391
   116
        }
moel@391
   117
moel@391
   118
        /// <summary>
moel@391
   119
        /// Creates a 'hot' palette with the specified number of colors.
moel@391
   120
        /// </summary>
moel@391
   121
        /// <param name="numberOfColors">
moel@391
   122
        /// The number of colors to create for the palette.
moel@391
   123
        /// </param>
moel@391
   124
        /// <returns>
moel@391
   125
        /// A palette.
moel@391
   126
        /// </returns>
moel@391
   127
        public static OxyPalette Hot(int numberOfColors)
moel@391
   128
        {
moel@391
   129
            return OxyPalette.Interpolate(
moel@391
   130
                numberOfColors,
moel@391
   131
                OxyColors.Black,
moel@391
   132
                OxyColor.FromRgb(127, 0, 0),
moel@391
   133
                OxyColor.FromRgb(255, 127, 0),
moel@391
   134
                OxyColor.FromRgb(255, 255, 127),
moel@391
   135
                OxyColors.White);
moel@391
   136
        }
moel@391
   137
moel@391
   138
        /// <summary>
moel@391
   139
        /// Creates a palette from the hue component of the HSV color model.
moel@391
   140
        /// </summary>
moel@391
   141
        /// <param name="numberOfColors">
moel@391
   142
        /// The number of colors.
moel@391
   143
        /// </param>
moel@391
   144
        /// <returns>
moel@391
   145
        /// The palette.
moel@391
   146
        /// </returns>
moel@391
   147
        /// <remarks>
moel@391
   148
        /// This palette is particularly appropriate for displaying periodic functions.
moel@391
   149
        /// </remarks>
moel@391
   150
        public static OxyPalette Hue(int numberOfColors)
moel@391
   151
        {
moel@391
   152
            return OxyPalette.Interpolate(
moel@391
   153
                numberOfColors,
moel@391
   154
                OxyColors.Red,
moel@391
   155
                OxyColors.Yellow,
moel@391
   156
                OxyColors.Green,
moel@391
   157
                OxyColors.Cyan,
moel@391
   158
                OxyColors.Blue,
moel@391
   159
                OxyColors.Magenta,
moel@391
   160
                OxyColors.Red);
moel@391
   161
        }
moel@391
   162
moel@391
   163
        /// <summary>
moel@391
   164
        /// Creates a 'jet' palette with the specified number of colors.
moel@391
   165
        /// </summary>
moel@391
   166
        /// <param name="numberOfColors">
moel@391
   167
        /// The number of colors to create for the palette.
moel@391
   168
        /// </param>
moel@391
   169
        /// <returns>
moel@391
   170
        /// A palette.
moel@391
   171
        /// </returns>
moel@391
   172
        /// <remarks>
moel@391
   173
        /// See http://www.mathworks.se/help/techdoc/ref/colormap.html.
moel@391
   174
        /// </remarks>
moel@391
   175
        public static OxyPalette Jet(int numberOfColors)
moel@391
   176
        {
moel@391
   177
            return OxyPalette.Interpolate(
moel@391
   178
                numberOfColors,
moel@391
   179
                OxyColors.DarkBlue,
moel@391
   180
                OxyColors.Cyan,
moel@391
   181
                OxyColors.Yellow,
moel@391
   182
                OxyColors.Orange,
moel@391
   183
                OxyColors.DarkRed);
moel@391
   184
        }
moel@391
   185
moel@391
   186
        /// <summary>
moel@391
   187
        /// Creates a rainbow palette with the specified number of colors.
moel@391
   188
        /// </summary>
moel@391
   189
        /// <param name="numberOfColors">
moel@391
   190
        /// The number of colors to create for the palette.
moel@391
   191
        /// </param>
moel@391
   192
        /// <returns>
moel@391
   193
        /// A palette.
moel@391
   194
        /// </returns>
moel@391
   195
        public static OxyPalette Rainbow(int numberOfColors)
moel@391
   196
        {
moel@391
   197
            return OxyPalette.Interpolate(
moel@391
   198
                numberOfColors,
moel@391
   199
                OxyColors.Violet,
moel@391
   200
                OxyColors.Indigo,
moel@391
   201
                OxyColors.Blue,
moel@391
   202
                OxyColors.Green,
moel@391
   203
                OxyColors.Yellow,
moel@391
   204
                OxyColors.Orange,
moel@391
   205
                OxyColors.Red);
moel@391
   206
        }
moel@391
   207
    }
moel@391
   208
}