1 #ifndef DALI_CONSTANTS_H
2 #define DALI_CONSTANTS_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <math.h> // M_PI
25 #include <dali/public-api/math/compile-time-math.h>
26 #include <dali/public-api/math/vector3.h>
27 #include <dali/public-api/math/vector4.h>
32 * @addtogroup dali_core_common
37 * @brief ParentOrigin constants.
39 * Note that for 2D layouting, the typical Z position is 0.5f (not 0.0f).
42 namespace ParentOrigin
44 static constexpr float TOP = 0.0f;
45 static constexpr float BOTTOM = 1.0f;
46 static constexpr float LEFT = 0.0f;
47 static constexpr float RIGHT = 1.0f;
48 static constexpr float MIDDLE = 0.5f;
49 static constexpr Vector3 TOP_LEFT(0.0f, 0.0f, 0.5f);
50 static constexpr Vector3 TOP_CENTER(0.5f, 0.0f, 0.5f);
51 static constexpr Vector3 TOP_RIGHT(1.0f, 0.0f, 0.5f);
52 static constexpr Vector3 CENTER_LEFT(0.0f, 0.5f, 0.5f);
53 static constexpr Vector3 CENTER(0.5f, 0.5f, 0.5f);
54 static constexpr Vector3 CENTER_RIGHT(1.0f, 0.5f, 0.5f);
55 static constexpr Vector3 BOTTOM_LEFT(0.0f, 1.0f, 0.5f);
56 static constexpr Vector3 BOTTOM_CENTER(0.5f, 1.0f, 0.5f);
57 static constexpr Vector3 BOTTOM_RIGHT(1.0f, 1.0f, 0.5f);
58 static constexpr Vector3 DEFAULT(TOP_LEFT);
59 } // namespace ParentOrigin
62 * @brief AnchorPoint constants.
64 * Note that for 2D layouting, the typical Z position is 0.5f (not 0.0f).
69 static constexpr float TOP = 0.0f;
70 static constexpr float BOTTOM = 1.0f;
71 static constexpr float LEFT = 0.0f;
72 static constexpr float RIGHT = 1.0f;
73 static constexpr float MIDDLE = 0.5f;
74 static constexpr Vector3 TOP_LEFT(0.0f, 0.0f, 0.5f);
75 static constexpr Vector3 TOP_CENTER(0.5f, 0.0f, 0.5f);
76 static constexpr Vector3 TOP_RIGHT(1.0f, 0.0f, 0.5f);
77 static constexpr Vector3 CENTER_LEFT(0.0f, 0.5f, 0.5f);
78 static constexpr Vector3 CENTER(0.5f, 0.5f, 0.5f);
79 static constexpr Vector3 CENTER_RIGHT(1.0f, 0.5f, 0.5f);
80 static constexpr Vector3 BOTTOM_LEFT(0.0f, 1.0f, 0.5f);
81 static constexpr Vector3 BOTTOM_CENTER(0.5f, 1.0f, 0.5f);
82 static constexpr Vector3 BOTTOM_RIGHT(1.0f, 1.0f, 0.5f);
83 static constexpr Vector3 DEFAULT(CENTER);
84 } // namespace AnchorPoint
87 * @brief Color Constants.
89 * Color is represented by the Vector4 class (see vector4.h).
94 static constexpr Vector4 BLACK(0.0f, 0.0f, 0.0f, 1.0f);
95 static constexpr Vector4 WHITE(1.0f, 1.0f, 1.0f, 1.0f);
96 static constexpr Vector4 RED(1.0f, 0.0f, 0.0f, 1.0f);
97 static constexpr Vector4 GREEN(0.0f, 1.0f, 0.0f, 1.0f);
98 static constexpr Vector4 BLUE(0.0f, 0.0f, 1.0f, 1.0f);
99 static constexpr Vector4 YELLOW(1.0f, 1.0f, 0.0f, 1.0f);
100 static constexpr Vector4 MAGENTA(1.0f, 0.0f, 1.0f, 1.0f);
101 static constexpr Vector4 CYAN(0.0f, 1.0f, 1.0f, 1.0f);
102 static constexpr Vector4 TRANSPARENT(0.0f, 0.0f, 0.0f, 0.0f);
107 * @brief Math constants.
112 static constexpr float MACHINE_EPSILON_0 = Epsilon<0>::value;
113 static constexpr float MACHINE_EPSILON_1 = Epsilon<1>::value;
114 static constexpr float MACHINE_EPSILON_10 = Epsilon<10>::value;
115 static constexpr float MACHINE_EPSILON_100 = Epsilon<100>::value;
116 static constexpr float MACHINE_EPSILON_1000 = Epsilon<1000>::value;
117 static constexpr float MACHINE_EPSILON_10000 = Epsilon<10000>::value;
119 // float is preferred to double for performance on ARM targets
120 static constexpr float PI = static_cast<float>(M_PI); ///< Pi
121 static constexpr float PI_2 = static_cast<float>(M_PI_2); ///< Pi/2
122 static constexpr float PI_4 = static_cast<float>(M_PI_4); ///< Pi/4
123 static constexpr float PI_OVER_180 = Dali::Math::PI / 180.0f; ///< Constant used to convert degree to radian
124 static constexpr float ONE80_OVER_PI = 180.0f / Dali::Math::PI; ///< Constant used to convert radian to degree
129 static constexpr Vector4 DEFAULT_BACKGROUND_COLOR = Color::BLACK;
130 static constexpr Vector4 DEBUG_BACKGROUND_COLOR(0.2f, 0.5f, 0.2f, 1.0f); ///< Dark green, useful for debugging visuals (texture / shader issues / culling etc.).
137 #endif // DALI_CONSTANTS_H