24 static int sUniqueName = 0;
25 int id = ++sUniqueName;
68 for (
int i = 0; i < steps; ++i) {
71 if (optional_alpha_gen) {
73 uint8_t a8 = (*optional_alpha_gen)(alpha);
87 tx.set_scale_x((width - 1.0f) * 0.5f);
90 tx.set_offset_x(width * 0.5f);
99 tx.set_scale_y((height - 1.0f) * 0.5f);
100 tx.set_offset_y(height * 0.5f);
130 auto path = PointPathPtr::New(
x,
y);
131 return XYPathPtr::New(path);
135 LinePathParamsPtr
p = LinePathParamsPtr::New();
141 auto path = LinePathPtr::New(
p);
142 return XYPathPtr::New(path);
147 return XYPathPtr::New(path);
151 auto path = CirclePathPtr::New();
152 return XYPathPtr::New(path);
156 CirclePathPtr path = CirclePathPtr::New();
157 XYPathPtr out = XYPathPtr::New(path);
158 out->setDrawBounds(width, height);
163 HeartPathPtr path = HeartPathPtr::New();
164 return XYPathPtr::New(path);
168 HeartPathPtr path = HeartPathPtr::New();
169 XYPathPtr out = XYPathPtr::New(path);
170 out->setDrawBounds(width, height);
175 ArchimedeanSpiralPathPtr path = ArchimedeanSpiralPathPtr::New();
176 XYPathPtr out = XYPathPtr::New(path);
177 out->setDrawBounds(width, height);
182 ArchimedeanSpiralPathPtr path = ArchimedeanSpiralPathPtr::New();
183 XYPathPtr out = XYPathPtr::New(path);
189 RosePathPtr path = RosePathPtr::New(params);
190 XYPathPtr out = XYPathPtr::New(path);
191 if (width > 0 && height > 0) {
192 out->setDrawBounds(width, height);
199 PhyllotaxisPathPtr path = PhyllotaxisPathPtr::New(args);
200 XYPathPtr out = XYPathPtr::New(path);
201 if (width > 0 && height > 0) {
202 out->setDrawBounds(width, height);
209 GielisCurvePathPtr path = GielisCurvePathPtr::New(params);
210 XYPathPtr out = XYPathPtr::New(path);
211 if (width > 0 && height > 0) {
212 out->setDrawBounds(width, height);
219 CatmullRomPathPtr path = CatmullRomPathPtr::New(params);
220 XYPathPtr out = XYPathPtr::New(path);
221 if (width > 0 && height > 0) {
222 out->setDrawBounds(width, height);
234 if (!drawbounds.
empty()) {
235 path->setDrawBounds(drawbounds);
237 XYPathPtr out = XYPathPtr::New(path);
242 if (path->hasDrawBounds(&bounds)) {
243 if (!bounds.
mMin.is_zero()) {
246 "Bounds with an origin other than 0,0 is not supported yet");
248 auto w = bounds.
width();
250 out->setDrawBounds(w, h);
279 return MAX(1, 200 * diff);
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
XYRaster raster(WIDTH, HEIGHT)
void scale(uint8_t scale)
fl::function< uint8_t(float)> AlphaFunction
static XYPathPtr NewGielisCurvePath(uint16_t width=0, uint16_t height=0, const Ptr< GielisCurveParams > ¶ms=NewPtr< GielisCurveParams >())
int calculateSteps(float from, float to)
void drawColor(const CRGB &color, float from, float to, Leds *leds, int steps=-1)
static XYPathPtr NewCustomPath(const fl::function< vec2f(float)> &path, const rect< int > &drawbounds=rect< int >(), const TransformFloat &transform=TransformFloat(), const Str &name=xypath_detail::unique_missing_name())
static XYPathPtr NewHeartPath()
static XYPathPtr NewArchimedeanSpiralPath()
Tile2x2_u8 at_subpixel(float alpha)
void setScale(float scale)
static XYPathPtr NewCatmullRomPath(uint16_t width=0, uint16_t height=0, const Ptr< CatmullRomParams > ¶ms=NewPtr< CatmullRomParams >())
static XYPathPtr NewPointPath(float x, float y)
bool hasDrawBounds() const
void setDrawBounds(uint16_t width, uint16_t height)
void drawGradient(const Gradient &gradient, float from, float to, Leds *leds, int steps=-1)
void setTransform(const TransformFloat &transform)
static XYPathPtr NewLinePath(float x0, float y0, float x1, float y1)
XYPathRendererPtr mPathRenderer
static XYPathPtr NewPhyllotaxisPath(uint16_t width=0, uint16_t height=0, const Ptr< PhyllotaxisParams > &args=NewPtr< PhyllotaxisParams >())
XYPath(XYPathGeneratorPtr path, TransformFloat transform=TransformFloat())
static XYPathPtr NewRosePath(uint16_t width=0, uint16_t height=0, const Ptr< RosePathParams > ¶ms=NewPtr< RosePathParams >())
void rasterize(float from, float to, int steps, XYRasterU8Sparse &raster, AlphaFunction *optional_alpha_gen=nullptr)
static XYPathPtr NewCirclePath()
TransformFloat & transform()
TransformFloat & transform()
void rasterize(float from, float to, int steps, XYRasterU8Sparse &raster, fl::function< uint8_t(float)> *optional_alpha_gen=nullptr)
vec2f compute(float alpha)
Tile2x2_u8 at_subpixel(float alpha)
TransformFloat mTransform
TransformFloat mGridTransform
vec2f compute_float(float alpha, const TransformFloat &tx)
void setDrawBounds(uint16_t width, uint16_t height)
void onTransformFloatChanged()
void setScale(float scale)
ThreadLocal< XYRasterU8Sparse > tls_raster
fl::Str unique_missing_name(const fl::Str &prefix)
XYRasterU8Sparse XYRaster
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
ThreadLocalFake< T > ThreadLocal
Ptr< T > NewPtr(Args... args)
FASTLED_FORCE_INLINE U map_range(T value, T in_min, T in_max, U out_min, U out_max)
Implements a simple red square effect for 2D LED grids.
static FASTLED_NAMESPACE_BEGIN uint8_t const p[]
Representation of an RGB pixel (Red, Green, Blue)