libtcod
Loading...
Searching...
No Matches
color.hpp
Go to the documentation of this file.
1/* BSD 3-Clause License
2 *
3 * Copyright © 2008-2025, Jice and the libtcod contributors.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
34#pragma once
35#ifndef TCOD_COLOR_HPP_
36#define TCOD_COLOR_HPP_
37
38#include <algorithm>
39#include <array>
40#include <stdexcept>
41
42#include "color.h"
43#include "utility.h"
44
45namespace tcod {
46
53struct ColorRGB : public TCOD_ColorRGB {
54 public:
55
58 constexpr ColorRGB() noexcept : ColorRGB{0, 0, 0} {}
59
62 constexpr ColorRGB(uint8_t red, uint8_t green, uint8_t blue) noexcept : TCOD_ColorRGB{red, green, blue} {}
63
66 explicit constexpr ColorRGB(const TCOD_ColorRGB& rhs) noexcept : TCOD_ColorRGB{rhs} {}
67
70 explicit constexpr ColorRGB(const TCOD_ColorRGBA& rhs) noexcept : ColorRGB{rhs.r, rhs.g, rhs.b} {}
71
74 [[nodiscard]] constexpr operator const TCOD_ColorRGBA() const noexcept { return TCOD_ColorRGBA{r, g, b, 255}; }
75
78 [[nodiscard]] constexpr explicit operator TCOD_ColorRGB*() noexcept { return this; }
79
82 [[nodiscard]] constexpr explicit operator const TCOD_ColorRGB*() const noexcept { return this; }
83};
84
91struct ColorRGBA : public TCOD_ColorRGBA {
92 public:
93
96 constexpr ColorRGBA() noexcept : ColorRGBA{0, 0, 0, 255} {}
97
100 constexpr ColorRGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = 255) noexcept
101 : TCOD_ColorRGBA{red, green, blue, alpha} {}
102
105 explicit constexpr ColorRGBA(const TCOD_ColorRGB& rhs, uint8_t alpha = 255) noexcept
106 : TCOD_ColorRGBA{rhs.r, rhs.b, rhs.b, alpha} {}
107
110 explicit constexpr ColorRGBA(const TCOD_ColorRGBA& rhs) noexcept : TCOD_ColorRGBA{rhs} {}
111
114 [[nodiscard]] constexpr explicit operator TCOD_ColorRGB() const noexcept { return TCOD_ColorRGB{r, g, b}; };
115
118 [[nodiscard]] constexpr explicit operator TCOD_ColorRGBA*() noexcept { return this; }
119
122 [[nodiscard]] constexpr explicit operator const TCOD_ColorRGBA*() const noexcept { return this; }
123};
124} // namespace tcod
125// clang-format off
126// color constants uses to generate @ColorTable
165
220
221class TCODLIB_API TCODColor {
222public:
223 constexpr TCODColor() noexcept = default;
240 constexpr TCODColor(uint8_t r_, uint8_t g_, uint8_t b_) noexcept
241 : r{r_}, g{g_}, b{b_}
242 {}
243 constexpr TCODColor(int r_, int g_, int b_) noexcept
244 : r{static_cast<uint8_t>(r_)}, g{static_cast<uint8_t>(g_)}, b{static_cast<uint8_t>(b_)}
245 {}
246 constexpr TCODColor(const TCOD_color_t &col) noexcept: r{col.r}, g{col.g}, b{col.b} {} // Notice: not explicit!
247 TCODColor(float h, float s, float v) noexcept;
248
267 [[nodiscard]] constexpr bool operator==(const TCODColor& c) const noexcept
268 {
269 return (c.r == r && c.g == g && c.b == b);
270 }
271 [[nodiscard]] constexpr bool operator!=(const TCODColor& c) const noexcept
272 {
273 return !(*this == c);
274 }
275
291 [[nodiscard]] constexpr TCODColor operator*(const TCODColor& rhs) const noexcept
292 {
293 return TCODColor{
294 r * rhs.r / 255,
295 g * rhs.g / 255,
296 b * rhs.b / 255,
297 };
298 }
299
316 [[nodiscard]] constexpr TCODColor operator*(float value) const noexcept
317 {
318 return TCODColor{
319 static_cast<uint8_t>(std::clamp(r * value, 0.0f, 255.0f)),
320 static_cast<uint8_t>(std::clamp(g * value, 0.0f, 255.0f)),
321 static_cast<uint8_t>(std::clamp(b * value, 0.0f, 255.0f)),
322 };
323 }
324 [[nodiscard]] TCODLIB_API_INLINE_EXPORT friend TCODColor operator*(float value, const TCODColor& color) noexcept {
325 return color * value;
326 }
327
342 [[nodiscard]] constexpr TCODColor operator+(const TCODColor & rhs) const noexcept
343 {
344 return TCODColor{
345 std::clamp(r + rhs.r, 0, 255),
346 std::clamp(g + rhs.g, 0, 255),
347 std::clamp(b + rhs.b, 0, 255),
348 };
349 }
350
365 [[nodiscard]] constexpr TCODColor operator-(const TCODColor& rhs) const noexcept
366 {
367 return TCODColor{
368 std::clamp(r - rhs.r, 0, 255),
369 std::clamp(g - rhs.g, 0, 255),
370 std::clamp(b - rhs.b, 0, 255),
371 };
372 }
373
393 [[nodiscard]] static constexpr TCODColor lerp(const TCODColor &c1, const TCODColor &c2, float coef) noexcept
394 {
395 return TCODColor{
396 c1.r + static_cast<int>((c2.r - c1.r) * coef),
397 c1.g + static_cast<int>((c2.g - c1.g) * coef),
398 c1.b + static_cast<int>((c2.b - c1.b) * coef),
399 };
400 }
401
417 void setHSV(float h, float s, float v) noexcept;
418
438 void setHue(float h) noexcept;
439 void setSaturation(float s) noexcept;
440 void setValue(float v) noexcept;
441
456 void getHSV(float *h, float *s, float *v) const noexcept;
457
480 [[nodiscard]] float getHue() noexcept;
481 [[nodiscard]] float getSaturation() noexcept;
482 [[nodiscard]] float getValue() noexcept;
483
496 void shiftHue(float hshift) noexcept;
497
510 void scaleHSV(float sscale, float vscale) noexcept;
511
556 static void genMap(TCODColor *map, int nbKey, TCODColor const *keyColor, int const *keyIndex);
557 // clang-format on
558
559
584 template <int OutSize, typename KeyColors, typename KeyIndexes>
585 [[nodiscard]] static constexpr auto genMap(const KeyColors& key_colors, const KeyIndexes& key_indexes)
586 -> std::array<tcod::ColorRGB, OutSize> {
587 auto out = std::array<tcod::ColorRGB, OutSize>{};
588 if (key_colors.size() != key_indexes.size())
589 throw std::invalid_argument{"Key color and index arrays must be the same size."};
590 for (size_t segment = 1; segment < key_colors.size(); ++segment) { // Segment between two key colors/indexes.
591 const auto index_start = key_indexes.at(segment - 1);
592 const auto index_end = key_indexes.at(segment);
593 if (segment == 1 && index_start != 0) throw std::invalid_argument{"First key must be 0."};
594 if (segment == key_colors.size() - 1 && index_end != OutSize - 1) {
595 throw std::invalid_argument{"Last key must be at the end of the output size."};
596 }
597 if (!(index_start < index_end)) throw std::invalid_argument{"Key indexes must be in ascending order."};
598 const auto color_start = TCODColor{key_colors.at(segment - 1)};
599 const auto color_end = TCODColor{key_colors.at(segment)};
600 for (auto i = index_start; i <= index_end; ++i) {
601 const float interpolation = static_cast<float>(i - index_start) / (index_end - index_start);
602 out.at(i) = tcod::ColorRGB{TCODColor::lerp(color_start, color_end, interpolation)};
603 }
604 }
605 return out;
606 }
607
608
614 [[nodiscard]] constexpr explicit operator TCOD_ColorRGB() const noexcept { return {r, g, b}; }
615
621 [[nodiscard]] constexpr explicit operator TCOD_ColorRGBA() const noexcept { return {r, g, b, 255}; }
622
628 [[nodiscard]] constexpr explicit operator tcod::ColorRGB() const noexcept { return {r, g, b}; };
629
635 [[nodiscard]] constexpr explicit operator tcod::ColorRGBA() const noexcept { return {r, g, b, 255}; };
636
638 // color array
639 static const TCODColor colors [[deprecated]][TCOD_COLOR_NB][TCOD_COLOR_LEVELS];
640
641 // grey levels
642 static const TCODColor black [[deprecated("Replace with tcod::ColorRGB{0, 0, 0}")]];
643 static const TCODColor darkestGrey [[deprecated("Replace with tcod::ColorRGB{31, 31, 31}")]];
644 static const TCODColor darkerGrey [[deprecated("Replace with tcod::ColorRGB{63, 63, 63}")]];
645 static const TCODColor darkGrey [[deprecated("Replace with tcod::ColorRGB{95, 95, 95}")]];
646 static const TCODColor grey [[deprecated("Replace with tcod::ColorRGB{127, 127, 127}")]];
647 static const TCODColor lightGrey [[deprecated("Replace with tcod::ColorRGB{159, 159, 159}")]];
648 static const TCODColor lighterGrey [[deprecated("Replace with tcod::ColorRGB{191, 191, 191}")]];
649 static const TCODColor lightestGrey [[deprecated("Replace with tcod::ColorRGB{223, 223, 223}")]];
650 static const TCODColor white [[deprecated("Replace with tcod::ColorRGB{255, 255, 255}")]];
651
652 // sepia
653 static const TCODColor darkestSepia [[deprecated("Replace with tcod::ColorRGB{31, 24, 15}")]];
654 static const TCODColor darkerSepia [[deprecated("Replace with tcod::ColorRGB{63, 50, 31}")]];
655 static const TCODColor darkSepia [[deprecated("Replace with tcod::ColorRGB{94, 75, 47}")]];
656 static const TCODColor sepia [[deprecated("Replace with tcod::ColorRGB{127, 101, 63}")]];
657 static const TCODColor lightSepia [[deprecated("Replace with tcod::ColorRGB{158, 134, 100}")]];
658 static const TCODColor lighterSepia [[deprecated("Replace with tcod::ColorRGB{191, 171, 143}")]];
659 static const TCODColor lightestSepia [[deprecated("Replace with tcod::ColorRGB{222, 211, 195}")]];
660
661 // standard colors
662 static const TCODColor red [[deprecated("Replace with tcod::ColorRGB{255, 0, 0}")]];
663 static const TCODColor flame [[deprecated("Replace with tcod::ColorRGB{255, 63, 0}")]];
664 static const TCODColor orange [[deprecated("Replace with tcod::ColorRGB{255, 127, 0}")]];
665 static const TCODColor amber [[deprecated("Replace with tcod::ColorRGB{255, 191, 0}")]];
666 static const TCODColor yellow [[deprecated("Replace with tcod::ColorRGB{255, 255, 0}")]];
667 static const TCODColor lime [[deprecated("Replace with tcod::ColorRGB{191, 255, 0}")]];
668 static const TCODColor chartreuse [[deprecated("Replace with tcod::ColorRGB{127, 255, 0}")]];
669 static const TCODColor green [[deprecated("Replace with tcod::ColorRGB{0, 255, 0}")]];
670 static const TCODColor sea [[deprecated("Replace with tcod::ColorRGB{0, 255, 127}")]];
671 static const TCODColor turquoise [[deprecated("Replace with tcod::ColorRGB{0, 255, 191}")]];
672 static const TCODColor cyan [[deprecated("Replace with tcod::ColorRGB{0, 255, 255}")]];
673 static const TCODColor sky [[deprecated("Replace with tcod::ColorRGB{0, 191, 255}")]];
674 static const TCODColor azure [[deprecated("Replace with tcod::ColorRGB{0, 127, 255}")]];
675 static const TCODColor blue [[deprecated("Replace with tcod::ColorRGB{0, 0, 255}")]];
676 static const TCODColor han [[deprecated("Replace with tcod::ColorRGB{63, 0, 255}")]];
677 static const TCODColor violet [[deprecated("Replace with tcod::ColorRGB{127, 0, 255}")]];
678 static const TCODColor purple [[deprecated("Replace with tcod::ColorRGB{191, 0, 255}")]];
679 static const TCODColor fuchsia [[deprecated("Replace with tcod::ColorRGB{255, 0, 255}")]];
680 static const TCODColor magenta [[deprecated("Replace with tcod::ColorRGB{255, 0, 191}")]];
681 static const TCODColor pink [[deprecated("Replace with tcod::ColorRGB{255, 0, 127}")]];
682 static const TCODColor crimson [[deprecated("Replace with tcod::ColorRGB{255, 0, 63}")]];
683
684 // dark colors
685 static const TCODColor darkRed [[deprecated("Replace with tcod::ColorRGB{191, 0, 0}")]];
686 static const TCODColor darkFlame [[deprecated("Replace with tcod::ColorRGB{191, 47, 0}")]];
687 static const TCODColor darkOrange [[deprecated("Replace with tcod::ColorRGB{191, 95, 0}")]];
688 static const TCODColor darkAmber [[deprecated("Replace with tcod::ColorRGB{191, 143, 0}")]];
689 static const TCODColor darkYellow [[deprecated("Replace with tcod::ColorRGB{191, 191, 0}")]];
690 static const TCODColor darkLime [[deprecated("Replace with tcod::ColorRGB{143, 191, 0}")]];
691 static const TCODColor darkChartreuse [[deprecated("Replace with tcod::ColorRGB{95, 191, 0}")]];
692 static const TCODColor darkGreen [[deprecated("Replace with tcod::ColorRGB{0, 191, 0}")]];
693 static const TCODColor darkSea [[deprecated("Replace with tcod::ColorRGB{0, 191, 95}")]];
694 static const TCODColor darkTurquoise [[deprecated("Replace with tcod::ColorRGB{0, 191, 143}")]];
695 static const TCODColor darkCyan [[deprecated("Replace with tcod::ColorRGB{0, 191, 191}")]];
696 static const TCODColor darkSky [[deprecated("Replace with tcod::ColorRGB{0, 143, 191}")]];
697 static const TCODColor darkAzure [[deprecated("Replace with tcod::ColorRGB{0, 95, 191}")]];
698 static const TCODColor darkBlue [[deprecated("Replace with tcod::ColorRGB{0, 0, 191}")]];
699 static const TCODColor darkHan [[deprecated("Replace with tcod::ColorRGB{47, 0, 191}")]];
700 static const TCODColor darkViolet [[deprecated("Replace with tcod::ColorRGB{95, 0, 191}")]];
701 static const TCODColor darkPurple [[deprecated("Replace with tcod::ColorRGB{143, 0, 191}")]];
702 static const TCODColor darkFuchsia [[deprecated("Replace with tcod::ColorRGB{191, 0, 191}")]];
703 static const TCODColor darkMagenta [[deprecated("Replace with tcod::ColorRGB{191, 0, 143}")]];
704 static const TCODColor darkPink [[deprecated("Replace with tcod::ColorRGB{191, 0, 95}")]];
705 static const TCODColor darkCrimson [[deprecated("Replace with tcod::ColorRGB{191, 0, 47}")]];
706
707 // darker colors
708 static const TCODColor darkerRed [[deprecated("Replace with tcod::ColorRGB{127, 0, 0}")]];
709 static const TCODColor darkerFlame [[deprecated("Replace with tcod::ColorRGB{127, 31, 0}")]];
710 static const TCODColor darkerOrange [[deprecated("Replace with tcod::ColorRGB{127, 63, 0}")]];
711 static const TCODColor darkerAmber [[deprecated("Replace with tcod::ColorRGB{127, 95, 0}")]];
712 static const TCODColor darkerYellow [[deprecated("Replace with tcod::ColorRGB{127, 127, 0}")]];
713 static const TCODColor darkerLime [[deprecated("Replace with tcod::ColorRGB{95, 127, 0}")]];
714 static const TCODColor darkerChartreuse [[deprecated("Replace with tcod::ColorRGB{63, 127, 0}")]];
715 static const TCODColor darkerGreen [[deprecated("Replace with tcod::ColorRGB{0, 127, 0}")]];
716 static const TCODColor darkerSea [[deprecated("Replace with tcod::ColorRGB{0, 127, 63}")]];
717 static const TCODColor darkerTurquoise [[deprecated("Replace with tcod::ColorRGB{0, 127, 95}")]];
718 static const TCODColor darkerCyan [[deprecated("Replace with tcod::ColorRGB{0, 127, 127}")]];
719 static const TCODColor darkerSky [[deprecated("Replace with tcod::ColorRGB{0, 95, 127}")]];
720 static const TCODColor darkerAzure [[deprecated("Replace with tcod::ColorRGB{0, 63, 127}")]];
721 static const TCODColor darkerBlue [[deprecated("Replace with tcod::ColorRGB{0, 0, 127}")]];
722 static const TCODColor darkerHan [[deprecated("Replace with tcod::ColorRGB{31, 0, 127}")]];
723 static const TCODColor darkerViolet [[deprecated("Replace with tcod::ColorRGB{63, 0, 127}")]];
724 static const TCODColor darkerPurple [[deprecated("Replace with tcod::ColorRGB{95, 0, 127}")]];
725 static const TCODColor darkerFuchsia [[deprecated("Replace with tcod::ColorRGB{127, 0, 127}")]];
726 static const TCODColor darkerMagenta [[deprecated("Replace with tcod::ColorRGB{127, 0, 95}")]];
727 static const TCODColor darkerPink [[deprecated("Replace with tcod::ColorRGB{127, 0, 63}")]];
728 static const TCODColor darkerCrimson [[deprecated("Replace with tcod::ColorRGB{127, 0, 31}")]];
729
730 // darkest colors
731 static const TCODColor darkestRed [[deprecated("Replace with tcod::ColorRGB{63, 0, 0}")]];
732 static const TCODColor darkestFlame [[deprecated("Replace with tcod::ColorRGB{63, 15, 0}")]];
733 static const TCODColor darkestOrange [[deprecated("Replace with tcod::ColorRGB{63, 31, 0}")]];
734 static const TCODColor darkestAmber [[deprecated("Replace with tcod::ColorRGB{63, 47, 0}")]];
735 static const TCODColor darkestYellow [[deprecated("Replace with tcod::ColorRGB{63, 63, 0}")]];
736 static const TCODColor darkestLime [[deprecated("Replace with tcod::ColorRGB{47, 63, 0}")]];
737 static const TCODColor darkestChartreuse [[deprecated("Replace with tcod::ColorRGB{31, 63, 0}")]];
738 static const TCODColor darkestGreen [[deprecated("Replace with tcod::ColorRGB{0, 63, 0}")]];
739 static const TCODColor darkestSea [[deprecated("Replace with tcod::ColorRGB{0, 63, 31}")]];
740 static const TCODColor darkestTurquoise [[deprecated("Replace with tcod::ColorRGB{0, 63, 47}")]];
741 static const TCODColor darkestCyan [[deprecated("Replace with tcod::ColorRGB{0, 63, 63}")]];
742 static const TCODColor darkestSky [[deprecated("Replace with tcod::ColorRGB{0, 47, 63}")]];
743 static const TCODColor darkestAzure [[deprecated("Replace with tcod::ColorRGB{0, 31, 63}")]];
744 static const TCODColor darkestBlue [[deprecated("Replace with tcod::ColorRGB{0, 0, 63}")]];
745 static const TCODColor darkestHan [[deprecated("Replace with tcod::ColorRGB{15, 0, 63}")]];
746 static const TCODColor darkestViolet [[deprecated("Replace with tcod::ColorRGB{31, 0, 63}")]];
747 static const TCODColor darkestPurple [[deprecated("Replace with tcod::ColorRGB{47, 0, 63}")]];
748 static const TCODColor darkestFuchsia [[deprecated("Replace with tcod::ColorRGB{63, 0, 63}")]];
749 static const TCODColor darkestMagenta [[deprecated("Replace with tcod::ColorRGB{63, 0, 47}")]];
750 static const TCODColor darkestPink [[deprecated("Replace with tcod::ColorRGB{63, 0, 31}")]];
751 static const TCODColor darkestCrimson [[deprecated("Replace with tcod::ColorRGB{63, 0, 15}")]];
752
753 // light colors
754 static const TCODColor lightRed [[deprecated("Replace with tcod::ColorRGB{255, 63, 63}")]];
755 static const TCODColor lightFlame [[deprecated("Replace with tcod::ColorRGB{255, 111, 63}")]];
756 static const TCODColor lightOrange [[deprecated("Replace with tcod::ColorRGB{255, 159, 63}")]];
757 static const TCODColor lightAmber [[deprecated("Replace with tcod::ColorRGB{255, 207, 63}")]];
758 static const TCODColor lightYellow [[deprecated("Replace with tcod::ColorRGB{255, 255, 63}")]];
759 static const TCODColor lightLime [[deprecated("Replace with tcod::ColorRGB{207, 255, 63}")]];
760 static const TCODColor lightChartreuse [[deprecated("Replace with tcod::ColorRGB{159, 255, 63}")]];
761 static const TCODColor lightGreen [[deprecated("Replace with tcod::ColorRGB{63, 255, 63}")]];
762 static const TCODColor lightSea [[deprecated("Replace with tcod::ColorRGB{63, 255, 159}")]];
763 static const TCODColor lightTurquoise [[deprecated("Replace with tcod::ColorRGB{63, 255, 207}")]];
764 static const TCODColor lightCyan [[deprecated("Replace with tcod::ColorRGB{63, 255, 255}")]];
765 static const TCODColor lightSky [[deprecated("Replace with tcod::ColorRGB{63, 207, 255}")]];
766 static const TCODColor lightAzure [[deprecated("Replace with tcod::ColorRGB{63, 159, 255}")]];
767 static const TCODColor lightBlue [[deprecated("Replace with tcod::ColorRGB{63, 63, 255}")]];
768 static const TCODColor lightHan [[deprecated("Replace with tcod::ColorRGB{111, 63, 255}")]];
769 static const TCODColor lightViolet [[deprecated("Replace with tcod::ColorRGB{159, 63, 255}")]];
770 static const TCODColor lightPurple [[deprecated("Replace with tcod::ColorRGB{207, 63, 255}")]];
771 static const TCODColor lightFuchsia [[deprecated("Replace with tcod::ColorRGB{255, 63, 255}")]];
772 static const TCODColor lightMagenta [[deprecated("Replace with tcod::ColorRGB{255, 63, 207}")]];
773 static const TCODColor lightPink [[deprecated("Replace with tcod::ColorRGB{255, 63, 159}")]];
774 static const TCODColor lightCrimson [[deprecated("Replace with tcod::ColorRGB{255, 63, 111}")]];
775
776 // lighter colors
777 static const TCODColor lighterRed [[deprecated("Replace with tcod::ColorRGB{255, 127, 127}")]];
778 static const TCODColor lighterFlame [[deprecated("Replace with tcod::ColorRGB{255, 159, 127}")]];
779 static const TCODColor lighterOrange [[deprecated("Replace with tcod::ColorRGB{255, 191, 127}")]];
780 static const TCODColor lighterAmber [[deprecated("Replace with tcod::ColorRGB{255, 223, 127}")]];
781 static const TCODColor lighterYellow [[deprecated("Replace with tcod::ColorRGB{255, 255, 127}")]];
782 static const TCODColor lighterLime [[deprecated("Replace with tcod::ColorRGB{223, 255, 127}")]];
783 static const TCODColor lighterChartreuse [[deprecated("Replace with tcod::ColorRGB{191, 255, 127}")]];
784 static const TCODColor lighterGreen [[deprecated("Replace with tcod::ColorRGB{127, 255, 127}")]];
785 static const TCODColor lighterSea [[deprecated("Replace with tcod::ColorRGB{127, 255, 191}")]];
786 static const TCODColor lighterTurquoise [[deprecated("Replace with tcod::ColorRGB{127, 255, 223}")]];
787 static const TCODColor lighterCyan [[deprecated("Replace with tcod::ColorRGB{127, 255, 255}")]];
788 static const TCODColor lighterSky [[deprecated("Replace with tcod::ColorRGB{127, 223, 255}")]];
789 static const TCODColor lighterAzure [[deprecated("Replace with tcod::ColorRGB{127, 191, 255}")]];
790 static const TCODColor lighterBlue [[deprecated("Replace with tcod::ColorRGB{127, 127, 255}")]];
791 static const TCODColor lighterHan [[deprecated("Replace with tcod::ColorRGB{159, 127, 255}")]];
792 static const TCODColor lighterViolet [[deprecated("Replace with tcod::ColorRGB{191, 127, 255}")]];
793 static const TCODColor lighterPurple [[deprecated("Replace with tcod::ColorRGB{223, 127, 255}")]];
794 static const TCODColor lighterFuchsia [[deprecated("Replace with tcod::ColorRGB{255, 127, 255}")]];
795 static const TCODColor lighterMagenta [[deprecated("Replace with tcod::ColorRGB{255, 127, 223}")]];
796 static const TCODColor lighterPink [[deprecated("Replace with tcod::ColorRGB{255, 127, 191}")]];
797 static const TCODColor lighterCrimson [[deprecated("Replace with tcod::ColorRGB{255, 127, 159}")]];
798
799 // lightest colors
800 static const TCODColor lightestRed [[deprecated("Replace with tcod::ColorRGB{255, 191, 191}")]];
801 static const TCODColor lightestFlame [[deprecated("Replace with tcod::ColorRGB{255, 207, 191}")]];
802 static const TCODColor lightestOrange [[deprecated("Replace with tcod::ColorRGB{255, 223, 191}")]];
803 static const TCODColor lightestAmber [[deprecated("Replace with tcod::ColorRGB{255, 239, 191}")]];
804 static const TCODColor lightestYellow [[deprecated("Replace with tcod::ColorRGB{255, 255, 191}")]];
805 static const TCODColor lightestLime [[deprecated("Replace with tcod::ColorRGB{239, 255, 191}")]];
806 static const TCODColor lightestChartreuse [[deprecated("Replace with tcod::ColorRGB{223, 255, 191}")]];
807 static const TCODColor lightestGreen [[deprecated("Replace with tcod::ColorRGB{191, 255, 191}")]];
808 static const TCODColor lightestSea [[deprecated("Replace with tcod::ColorRGB{191, 255, 223}")]];
809 static const TCODColor lightestTurquoise [[deprecated("Replace with tcod::ColorRGB{191, 255, 239}")]];
810 static const TCODColor lightestCyan [[deprecated("Replace with tcod::ColorRGB{191, 255, 255}")]];
811 static const TCODColor lightestSky [[deprecated("Replace with tcod::ColorRGB{191, 239, 255}")]];
812 static const TCODColor lightestAzure [[deprecated("Replace with tcod::ColorRGB{191, 223, 255}")]];
813 static const TCODColor lightestBlue [[deprecated("Replace with tcod::ColorRGB{191, 191, 255}")]];
814 static const TCODColor lightestHan [[deprecated("Replace with tcod::ColorRGB{207, 191, 255}")]];
815 static const TCODColor lightestViolet [[deprecated("Replace with tcod::ColorRGB{223, 191, 255}")]];
816 static const TCODColor lightestPurple [[deprecated("Replace with tcod::ColorRGB{239, 191, 255}")]];
817 static const TCODColor lightestFuchsia [[deprecated("Replace with tcod::ColorRGB{255, 191, 255}")]];
818 static const TCODColor lightestMagenta [[deprecated("Replace with tcod::ColorRGB{255, 191, 239}")]];
819 static const TCODColor lightestPink [[deprecated("Replace with tcod::ColorRGB{255, 191, 223}")]];
820 static const TCODColor lightestCrimson [[deprecated("Replace with tcod::ColorRGB{255, 191, 207}")]];
821
822 // desaturated colors
823 static const TCODColor desaturatedRed [[deprecated("Replace with tcod::ColorRGB{127, 63, 63}")]];
824 static const TCODColor desaturatedFlame [[deprecated("Replace with tcod::ColorRGB{127, 79, 63}")]];
825 static const TCODColor desaturatedOrange [[deprecated("Replace with tcod::ColorRGB{127, 95, 63}")]];
826 static const TCODColor desaturatedAmber [[deprecated("Replace with tcod::ColorRGB{127, 111, 63}")]];
827 static const TCODColor desaturatedYellow [[deprecated("Replace with tcod::ColorRGB{127, 127, 63}")]];
828 static const TCODColor desaturatedLime [[deprecated("Replace with tcod::ColorRGB{111, 127, 63}")]];
829 static const TCODColor desaturatedChartreuse [[deprecated("Replace with tcod::ColorRGB{95, 127, 63}")]];
830 static const TCODColor desaturatedGreen [[deprecated("Replace with tcod::ColorRGB{63, 127, 63}")]];
831 static const TCODColor desaturatedSea [[deprecated("Replace with tcod::ColorRGB{63, 127, 95}")]];
832 static const TCODColor desaturatedTurquoise [[deprecated("Replace with tcod::ColorRGB{63, 127, 111}")]];
833 static const TCODColor desaturatedCyan [[deprecated("Replace with tcod::ColorRGB{63, 127, 127}")]];
834 static const TCODColor desaturatedSky [[deprecated("Replace with tcod::ColorRGB{63, 111, 127}")]];
835 static const TCODColor desaturatedAzure [[deprecated("Replace with tcod::ColorRGB{63, 95, 127}")]];
836 static const TCODColor desaturatedBlue [[deprecated("Replace with tcod::ColorRGB{63, 63, 127}")]];
837 static const TCODColor desaturatedHan [[deprecated("Replace with tcod::ColorRGB{79, 63, 127}")]];
838 static const TCODColor desaturatedViolet [[deprecated("Replace with tcod::ColorRGB{95, 63, 127}")]];
839 static const TCODColor desaturatedPurple [[deprecated("Replace with tcod::ColorRGB{111, 63, 127}")]];
840 static const TCODColor desaturatedFuchsia [[deprecated("Replace with tcod::ColorRGB{127, 63, 127}")]];
841 static const TCODColor desaturatedMagenta [[deprecated("Replace with tcod::ColorRGB{127, 63, 111}")]];
842 static const TCODColor desaturatedPink [[deprecated("Replace with tcod::ColorRGB{127, 63, 95}")]];
843 static const TCODColor desaturatedCrimson [[deprecated("Replace with tcod::ColorRGB{127, 63, 79}")]];
844
845 // metallic
846 static const TCODColor brass [[deprecated("Replace with tcod::ColorRGB{191, 151, 96}")]];
847 static const TCODColor copper [[deprecated("Replace with tcod::ColorRGB{197, 136, 124}")]];
848 static const TCODColor gold [[deprecated("Replace with tcod::ColorRGB{229, 191, 0}")]];
849 static const TCODColor silver [[deprecated("Replace with tcod::ColorRGB{203, 203, 203}")]];
850
851 // miscellaneous
852 static const TCODColor celadon [[deprecated("Replace with tcod::ColorRGB{172, 255, 175}")]];
853 static const TCODColor peach [[deprecated("Replace with tcod::ColorRGB{255, 159, 127}")]];
855
856 uint8_t r{};
857 uint8_t g{};
858 uint8_t b{};
859
860 private:
861};
862#endif // TCOD_COLOR_HPP_
Definition color.hpp:221
void setHSV(float h, float s, float v) noexcept
After this function is called, the r,g,b fields of the color are calculated according to the h,...
void scaleHSV(float sscale, float vscale) noexcept
constexpr operator tcod::ColorRGB() const noexcept
Allow explicit conversions to tcod::ColorRGB.
Definition color.hpp:628
constexpr TCODColor operator*(const TCODColor &rhs) const noexcept
c1 = c2 * c3 => c1.r = c2.r * c3.r / 255 c1.g = c2.g * c3.g / 255 c1.b = c2.b * c3....
Definition color.hpp:291
constexpr bool operator==(const TCODColor &c) const noexcept
if (myColor == TCODColor::yellow) { ... } if (myColor != TCODColor::white) { ... }...
Definition color.hpp:267
constexpr TCODColor operator*(float value) const noexcept
c1 = c2 * v => c1.r = TCOD_CLAMP(0, 255, c2.r * v) c1.g = TCOD_CLAMP(0, 255, c2.g * v) c1....
Definition color.hpp:316
void setHue(float h) noexcept
These functions set only a single component in the HSV color space.
constexpr TCODColor operator+(const TCODColor &rhs) const noexcept
c1 = c1 + c2 => c1.r = TCOD_MIN(255, c1.r + c2.r) c1.g = TCOD_MIN(255, c1.g + c2.g) c1....
Definition color.hpp:342
void getHSV(float *h, float *s, float *v) const noexcept
float getHue() noexcept
Should you need to extract only one of the HSV components, these functions are what you should call.
constexpr TCODColor operator-(const TCODColor &rhs) const noexcept
c1 = c1 - c2 => c1.r = TCOD_MAX(0, c1.r - c2.r) c1.g = TCOD_MAX(0, c1.g - c2.g) c1....
Definition color.hpp:365
void shiftHue(float hshift) noexcept
The hue shift value is the number of grades the color's hue will be shifted.
constexpr TCODColor(uint8_t r_, uint8_t g_, uint8_t b_) noexcept
You can create your own colours using a set of constructors, both for RGB and HSV values.
Definition color.hpp:240
static void genMap(TCODColor *map, int nbKey, TCODColor const *keyColor, int const *keyIndex)
You can define a color map from an array of color keys.
static constexpr TCODColor lerp(const TCODColor &c1, const TCODColor &c2, float coef) noexcept
c1 = lerp (c2, c3, coef) => c1.r = c2.r + (c3.r - c2.r ) * coef c1.g = c2.g + (c3....
Definition color.hpp:393
Color handling module.
The libtcod namespace.
Definition bresenham.hpp:157
A 4-channel RGBA color struct.
Definition color.h:92
A 3-channel RGB color struct.
Definition color.h:50
A C++ RGBA color, used to handle conversions between color types.
Definition color.hpp:91
constexpr ColorRGBA() noexcept
Default construct a black ColorRGBA object.
Definition color.hpp:96
constexpr ColorRGBA(const TCOD_ColorRGBA &rhs) noexcept
Construct a ColorRGBA object from an TCOD_ColorRGBA struct.
Definition color.hpp:110
constexpr ColorRGBA(const TCOD_ColorRGB &rhs, uint8_t alpha=255) noexcept
Construct a ColorRGBA object by adding an alpha channel to an RGB object.
Definition color.hpp:105
constexpr ColorRGBA(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha=255) noexcept
Construct a ColorRGBA object with the provided color and alpha.
Definition color.hpp:100
A C++ RGB color, used to handle conversions between color types.
Definition color.hpp:53
constexpr ColorRGB(const TCOD_ColorRGB &rhs) noexcept
Construct a ColorRGB object from an TCOD_ColorRGB struct.
Definition color.hpp:66
constexpr ColorRGB(const TCOD_ColorRGBA &rhs) noexcept
Construct a ColorRGB object from an RGBA color, truncating the alpha.
Definition color.hpp:70
constexpr ColorRGB() noexcept
Default construct a black ColorRGB object.
Definition color.hpp:58
constexpr ColorRGB(uint8_t red, uint8_t green, uint8_t blue) noexcept
Construct a ColorRGB object with the provided color.
Definition color.hpp:62
Common C macro definitions.