Metoda zwracająca kolor z palety barw

0

Cześć,
Czy istnieje gdzieś w System.Windows.Forms metoda, która zwraca kolor z wybranej palety barw spośród enuma ChartColorPalette na podstawie parametru z wartością liczbową (oraz przedziału wartości)?
Ewentualnie, czy znacie jakąś użyteczna bibliotekę, która może posłużyć w tym celu lub prosty pomysł na implementację własnej metody.

Dzięki, pozdr

1

W klasie Color masz takie ... fabryki ??? się to nazywa?
(chyba, ze nie rozumiem pytania)

            //
        // Summary:
        //     Creates a System.Drawing.Color structure from the specified 8-bit color values
        //     (red, green, and blue). The alpha value is implicitly 255 (fully opaque). Although
        //     this method allows a 32-bit value to be passed for each color component, the
        //     value of each component is limited to 8 bits.
        //
        // Parameters:
        //   red:
        //     The red component value for the new System.Drawing.Color. Valid values are 0
        //     through 255.
        //
        //   green:
        //     The green component value for the new System.Drawing.Color. Valid values are
        //     0 through 255.
        //
        //   blue:
        //     The blue component value for the new System.Drawing.Color. Valid values are 0
        //     through 255.
        //
        // Returns:
        //     The System.Drawing.Color that this method creates.
        //
        // Exceptions:
        //   T:System.ArgumentException:
        //     red, green, or blue is less than 0 or greater than 255.
        public static Color FromArgb(int red, int green, int blue);
        //
        // Summary:
        //     Creates a System.Drawing.Color structure from the specified System.Drawing.Color
        //     structure, but with the new specified alpha value. Although this method allows
        //     a 32-bit value to be passed for the alpha value, the value is limited to 8 bits.
        //
        // Parameters:
        //   alpha:
        //     The alpha value for the new System.Drawing.Color. Valid values are 0 through
        //     255.
        //
        //   baseColor:
        //     The System.Drawing.Color from which to create the new System.Drawing.Color.
        //
        // Returns:
        //     The System.Drawing.Color that this method creates.
        //
        // Exceptions:
        //   T:System.ArgumentException:
        //     alpha is less than 0 or greater than 255.
        public static Color FromArgb(int alpha, Color baseColor);
        //
        // Summary:
        //     Creates a System.Drawing.Color structure from the four ARGB component (alpha,
        //     red, green, and blue) values. Although this method allows a 32-bit value to be
        //     passed for each component, the value of each component is limited to 8 bits.
        //
        // Parameters:
        //   alpha:
        //     The alpha component. Valid values are 0 through 255.
        //
        //   red:
        //     The red component. Valid values are 0 through 255.
        //
        //   green:
        //     The green component. Valid values are 0 through 255.
        //
        //   blue:
        //     The blue component. Valid values are 0 through 255.
        //
        // Returns:
        //     The System.Drawing.Color that this method creates.
        //
        // Exceptions:
        //   T:System.ArgumentException:
        //     alpha, red, green, or blue is less than 0 or greater than 255.
        public static Color FromArgb(int alpha, int red, int green, int blue);
        //
        // Summary:
        //     Creates a System.Drawing.Color structure from a 32-bit ARGB value.
        //
        // Parameters:
        //   argb:
        //     A value specifying the 32-bit ARGB value.
        //
        // Returns:
        //     The System.Drawing.Color structure that this method creates.
        public static Color FromArgb(int argb);
0
adamtt napisał(a):

Czy istnieje gdzieś w System.Windows.Forms metoda, która zwraca kolor z wybranej palety barw spośród enuma ChartColorPalette na podstawie parametru z wartością liczbową

Zgadując tylko na podstawie tego fragmentu powiedziałbym że chcesz zamienić inta na enuma ChartColorPalette.
Czyli jeśli dobrze czytam SO to będzie ChartColorPalette color = (ChartColorPalette)colorAsInt;

0

@AnyKtokolwiek: To zwróci mi obiekt Color na podstawie RGB, a chcę aby dla pewnego przedziału wartości została określona paleta kolorów i zwracać metodą dla przekazanej wartości z tego przedziału odpowiedni kolor

0

Może wyjaśnię na przykładzie. Mam zasymulować rozchodzenie się temperatury na płaszczyźnie. Wizualizacja polega na ustawianiu kolorów pixeli. Kolor symbolizuje temperaturę, czyli wartość liczbową, z palety kolorów (np. od niebieskiego do czerwonego).Szukam rozwiązania, które zwróci mi dla przekazanej wartości odpowiedni (dla przyjętego przedziału wartości) kolor. Fajnie by było, gdybym mógł wybrać paletę kolorów na wzór dostępnych w ChartColorPalette.

1 użytkowników online, w tym zalogowanych: 0, gości: 1