FastLED 3.9.15
Loading...
Searching...
No Matches
xypath_renderer.h
Go to the documentation of this file.
1
2#pragma once
3
4// #include "fl/assert.h"
5// #include "fl/function.h"
6// #include "fl/lut.h"
7// #include "fl/map_range.h"
8// #include "fl/math_macros.h"
9// #include "fl/raster.h"
10// #include "fl/xypath.h"
11#include "fl/function.h"
12#include "fl/ptr.h"
13#include "fl/tile2x2.h"
14#include "fl/transform.h"
15
16namespace fl {
17
19
20class XYPathRenderer : public Referent {
21 public:
22 XYPathRenderer(XYPathGeneratorPtr path,
24 vec2f at(float alpha);
25
26 Tile2x2_u8 at_subpixel(float alpha);
27
28 void rasterize(float from, float to, int steps, XYRasterU8Sparse &raster,
29 fl::function<uint8_t(float)> *optional_alpha_gen = nullptr);
30
31 // Overloaded to allow transform to be passed in.
32 vec2f at(float alpha, const TransformFloat &tx);
33
34 // Needed for drawing to the screen. When this called the rendering will
35 // be centered on the width and height such that 0,0 -> maps to .5,.5,
36 // which is convenient for drawing since each float pixel can be truncated
37 // to an integer type.
38 void setDrawBounds(uint16_t width, uint16_t height);
39 bool hasDrawBounds() const { return mDrawBoundsSet; }
40
42
44
49
50 void setScale(float scale);
51
52 vec2f compute(float alpha);
53
54 private:
55 XYPathGeneratorPtr mPath;
58 bool mDrawBoundsSet = false;
59 vec2f compute_float(float alpha, const TransformFloat &tx);
60};
61
62} // namespace fl
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
XYRaster raster(WIDTH, HEIGHT)
Referent()
Definition ptr.cpp:7
TransformFloat & transform()
Definition xypath.cpp:110
void rasterize(float from, float to, int steps, XYRasterU8Sparse &raster, fl::function< uint8_t(float)> *optional_alpha_gen=nullptr)
Definition xypath.cpp:65
vec2f compute(float alpha)
Definition xypath.cpp:119
Tile2x2_u8 at_subpixel(float alpha)
XYPathGeneratorPtr mPath
bool hasDrawBounds() const
TransformFloat mTransform
XYPathRenderer(XYPathGeneratorPtr path, TransformFloat transform=TransformFloat())
TransformFloat mGridTransform
vec2f compute_float(float alpha, const TransformFloat &tx)
void setDrawBounds(uint16_t width, uint16_t height)
Definition xypath.cpp:80
void onTransformFloatChanged()
Definition xypath.cpp:106
void setScale(float scale)
Definition xypath.cpp:112
void setTransform(const TransformFloat &transform)
vec2f at(float alpha)
Definition xypath.cpp:123
vec2< float > vec2f
Definition geometry.h:151
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
#define FASTLED_SMART_PTR(type)
Definition ptr.h:31