FastLED 3.9.15
Loading...
Searching...
No Matches
xypaths.cpp
Go to the documentation of this file.
1
2
3#include "fl/xypath.h"
4#include "fl/vector.h"
5#include "fl/map_range.h"
6
7
8#include "xypaths.h"
9
10using namespace fl;
11
12namespace {
13 Ptr<CatmullRomParams> make_path(int width, int height) {
14 // make a triangle.
17 points.push_back(vec2f(0.0f, 0.0f));
18 points.push_back(vec2f(width / 3, height / 2));
19 points.push_back(vec2f(width - 3, height - 1));
20 points.push_back(vec2f(0.0f, height - 1));
21 points.push_back(vec2f(0.0f, 0.0f));
22 for (auto &p : points) {
23 p.x = map_range<float, float>(p.x, 0.0f, width - 1, -1.0f, 1.0f);
24 p.y = map_range<float, float>(p.y, 0.0f, height - 1, -1.0f, 1.0f);
25 params->addPoint(p);
26 }
27 return params;
28 }
29}
30
31fl::vector<XYPathPtr> CreateXYPaths(int width, int height) {
33 out.push_back(XYPath::NewCirclePath(width, height));
34 out.push_back(XYPath::NewRosePath(width, height));
35 out.push_back(XYPath::NewHeartPath(width, height));
37 out.push_back(XYPath::NewPhyllotaxisPath(width, height));
38 out.push_back(XYPath::NewGielisCurvePath(width, height));
39 out.push_back(XYPath::NewCatmullRomPath(width, height, make_path(width, height)));
40 return out;
41}
void push_back(const T &value)
Definition vector.h:442
void push_back(const T &value)
Definition vector.h:919
Definition ptr.h:118
static XYPathPtr NewGielisCurvePath(uint16_t width=0, uint16_t height=0, const Ptr< GielisCurveParams > &params=NewPtr< GielisCurveParams >())
Definition xypath.cpp:207
static XYPathPtr NewHeartPath()
Definition xypath.cpp:162
static XYPathPtr NewArchimedeanSpiralPath(uint16_t width, uint16_t height)
Definition xypath.cpp:174
static XYPathPtr NewCatmullRomPath(uint16_t width=0, uint16_t height=0, const Ptr< CatmullRomParams > &params=NewPtr< CatmullRomParams >())
Definition xypath.cpp:217
static XYPathPtr NewPhyllotaxisPath(uint16_t width=0, uint16_t height=0, const Ptr< PhyllotaxisParams > &args=NewPtr< PhyllotaxisParams >())
Definition xypath.cpp:197
static XYPathPtr NewRosePath(uint16_t width=0, uint16_t height=0, const Ptr< RosePathParams > &params=NewPtr< RosePathParams >())
Definition xypath.cpp:187
static XYPathPtr NewCirclePath()
Definition xypath.cpp:150
Ptr< CatmullRomParams > make_path(int width, int height)
Definition xypaths.cpp:13
InlinedVector< T, INLINED_SIZE > vector_inlined
Definition vector.h:1034
vec2< float > vec2f
Definition geometry.h:151
Ptr< T > NewPtr(Args... args)
Definition ptr.h:451
HeapVector< T > vector
Definition vector.h:1028
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max)
Definition map_range.h:26
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]
Definition noise.cpp:30
fl::vector< XYPathPtr > CreateXYPaths(int width, int height)
Definition xypaths.cpp:31