miniassimp

view include/miniassimp/color4.h @ 0:879c81d94345

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 28 Jan 2019 18:19:26 +0200
parents
children
line source
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
6 Copyright (c) 2006-2018, assimp team
10 All rights reserved.
12 Redistribution and use of this software in source and binary forms,
13 with or without modification, are permitted provided that the following
14 conditions are met:
16 * Redistributions of source code must retain the above
17 copyright notice, this list of conditions and the
18 following disclaimer.
20 * Redistributions in binary form must reproduce the above
21 copyright notice, this list of conditions and the
22 following disclaimer in the documentation and/or other
23 materials provided with the distribution.
25 * Neither the name of the assimp team, nor the names of its
26 contributors may be used to endorse or promote products
27 derived from this software without specific prior
28 written permission of the assimp team.
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ---------------------------------------------------------------------------
42 */
43 /** @file color4.h
44 * @brief RGBA color structure, including operators when compiling in C++
45 */
46 #pragma once
47 #ifndef AI_COLOR4D_H_INC
48 #define AI_COLOR4D_H_INC
50 #include "defs.h"
52 #ifdef __cplusplus
54 // ----------------------------------------------------------------------------------
55 /** Represents a color in Red-Green-Blue space including an
56 * alpha component. Color values range from 0 to 1. */
57 // ----------------------------------------------------------------------------------
58 template <typename TReal>
59 class aiColor4t
60 {
61 public:
62 aiColor4t() AI_NO_EXCEPT : r(), g(), b(), a() {}
63 aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
64 : r(_r), g(_g), b(_b), a(_a) {}
65 explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
67 public:
68 // combined operators
69 const aiColor4t& operator += (const aiColor4t& o);
70 const aiColor4t& operator -= (const aiColor4t& o);
71 const aiColor4t& operator *= (TReal f);
72 const aiColor4t& operator /= (TReal f);
74 public:
75 // comparison
76 bool operator == (const aiColor4t& other) const;
77 bool operator != (const aiColor4t& other) const;
78 bool operator < (const aiColor4t& other) const;
80 // color tuple access, rgba order
81 inline TReal operator[](unsigned int i) const;
82 inline TReal& operator[](unsigned int i);
84 /** check whether a color is (close to) black */
85 inline bool IsBlack() const;
87 public:
89 // Red, green, blue and alpha color values
90 TReal r, g, b, a;
91 }; // !struct aiColor4D
93 typedef aiColor4t<ai_real> aiColor4D;
95 #else
97 struct aiColor4D {
98 ai_real r, g, b, a;
99 };
101 #endif // __cplusplus
103 #endif // AI_COLOR4D_H_INC