FastLED 3.9.15
Loading...
Searching...
No Matches
math.h
Go to the documentation of this file.
1
2#pragma once
3
4#include "fl/clamp.h"
5#include "fl/map_range.h"
6#include "fl/math_macros.h"
7#include <math.h>
8
9namespace fl {
10
11template <typename T> inline T floor(T value) {
12 if (value >= 0) {
13 return static_cast<T>(static_cast<int>(value));
14 }
15 return static_cast<T>(::floor(static_cast<float>(value)));
16}
17
18template <typename T> inline T ceil(T value) {
19 if (value <= 0) {
20 return static_cast<T>(static_cast<int>(value));
21 }
22 return static_cast<T>(::ceil(static_cast<float>(value)));
23}
24
25// Arduino will define this in the global namespace as macros, so we can't
26// define them ourselves.
27// template <typename T>
28// inline T abs(T value) {
29// return (value < 0) ? -value : value;
30// }
31
32// template <typename T>
33// inline T min(T a, T b) {
34// return (a < b) ? a : b;
35// }
36
37// template <typename T>
38// inline T max(T a, T b) {
39// return (a > b) ? a : b;
40// }
41
42} // namespace fl
T ceil(T value)
Definition math.h:18
T floor(T value)
Definition math.h:11
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16