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