FastLED 3.9.15
Loading...
Searching...
No Matches
ring_screenmap.cpp
Go to the documentation of this file.
1// ring_screenmap.cpp
2#include "ring_screenmap.h"
3#include "FastLED.h"
4#include "fl/math/math.h"
5
6#ifndef TWO_PI
7#define TWO_PI 6.2831853071795864769252867665590057683943387987502116419498891846156328125724179972560696506842341359
8#endif
9
10fl::ScreenMap makeRingScreenMap(int numLeds, int gridWidth, int gridHeight,
11 float diameter) {
12 return fl::ScreenMap(numLeds, diameter, [=](int index, fl::vec2f &pt_out) {
13 float centerX = gridWidth / 2.0f;
14 float centerY = gridHeight / 2.0f;
15 float radius = fl::min(gridWidth, gridHeight) / 2.0f - 1;
16 float angle = (TWO_PI * index) / numLeds;
17 pt_out.x = centerX + fl::cos(angle) * radius;
18 pt_out.y = centerY + fl::sin(angle) * radius;
19 });
20}
#define TWO_PI
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
Definition math.h:71
vec2< float > vec2f
Definition geometry.h:333
enable_if< is_fixed_point< T >::value, T >::type cos(T angle) FL_NOEXCEPT
enable_if< is_fixed_point< T >::value, T >::type sin(T angle) FL_NOEXCEPT
fl::ScreenMap makeRingScreenMap(int numLeds, int gridWidth, int gridHeight, float diameter)
value_type y
Definition geometry.h:191
value_type x
Definition geometry.h:190