FastLED 3.9.15
Loading...
Searching...
No Matches
gfx.h
Go to the documentation of this file.
1#pragma once
2
33
35#include "fl/gfx/crgb.h"
36#include "fl/gfx/draw_mode.h"
37
38// IWYU pragma: begin_keep
39#include "fl/gfx/canvas.h"
40#include "fl/gfx/primitives.h"
41// IWYU pragma: end_keep
42
43namespace fl {
44
47
50template<typename RGB_T>
51class Canvas {
53
54 public:
55 FASTLED_FORCE_INLINE Canvas(fl::span<RGB_T> buf, int w, int h) : mImpl(buf, w, h) {}
56 FASTLED_FORCE_INLINE Canvas(fl::shared_ptr<RGB_T> ptr, int w, int h) : mImpl(ptr, w, h) {}
57
58 FASTLED_FORCE_INLINE int size() const { return mImpl.size(); }
59 FASTLED_FORCE_INLINE RGB_T& at(int x, int y) { return mImpl.at(x, y); }
60 FASTLED_FORCE_INLINE const RGB_T& at(int x, int y) const { return mImpl.at(x, y); }
61 FASTLED_FORCE_INLINE bool has(int x, int y) const { return mImpl.has(x, y); }
62
63 template<int hRadius, int vRadius>
65 mImpl.template blurGaussian<hRadius, vRadius>(dimFactor);
66 }
67
68 template<int hRadius, int vRadius>
70 mImpl.template blurGaussian<hRadius, vRadius>(dimFactor);
71 }
72
73 template<int hRadius, int vRadius>
77
78 template<typename Coord>
79 FASTLED_FORCE_INLINE void drawLine(const RGB_T& color, Coord x0, Coord y0, Coord x1, Coord y1,
81 mImpl.drawLine(color, x0, y0, x1, y1, mode);
82 }
83
84 template<typename Coord>
85 FASTLED_FORCE_INLINE void drawDisc(const RGB_T& color, Coord cx, Coord cy, Coord r,
87 mImpl.drawDisc(color, cx, cy, r, mode);
88 }
89
90 template<typename Coord>
91 FASTLED_FORCE_INLINE void drawRing(const RGB_T& color, Coord cx, Coord cy, Coord r, Coord thickness,
93 mImpl.drawRing(color, cx, cy, r, thickness, mode);
94 }
95
96 template<typename Coord>
97 FASTLED_FORCE_INLINE void drawStrokeLine(const RGB_T& color, Coord x0, Coord y0, Coord x1, Coord y1,
98 Coord thickness, LineCap cap = LineCap::FLAT,
100 mImpl.drawStrokeLine(color, x0, y0, x1, y1, thickness, cap, mode);
101 }
102};
103
105class CanvasRGB : protected Canvas<CRGB> {
106 public:
107 using Canvas<CRGB>::Canvas;
108 using Canvas<CRGB>::size;
109 using Canvas<CRGB>::at;
110 using Canvas<CRGB>::has;
112 using Canvas<CRGB>::drawLine;
113 using Canvas<CRGB>::drawDisc;
114 using Canvas<CRGB>::drawRing;
116};
117
118} // namespace fl
Canvas types for gfx primitives (implementation)
FASTLED_FORCE_INLINE bool has(int x, int y) const
Definition gfx.h:61
FASTLED_FORCE_INLINE int size() const
Definition gfx.h:58
FASTLED_FORCE_INLINE const RGB_T & at(int x, int y) const
Definition gfx.h:60
FASTLED_FORCE_INLINE void drawDisc(const RGB_T &color, Coord cx, Coord cy, Coord r, DrawMode mode=DrawMode::DRAW_MODE_BLEND)
Definition gfx.h:85
FASTLED_FORCE_INLINE void drawRing(const RGB_T &color, Coord cx, Coord cy, Coord r, Coord thickness, DrawMode mode=DrawMode::DRAW_MODE_BLEND)
Definition gfx.h:91
FASTLED_FORCE_INLINE void drawLine(const RGB_T &color, Coord x0, Coord y0, Coord x1, Coord y1, DrawMode mode=DrawMode::DRAW_MODE_BLEND)
Definition gfx.h:79
FASTLED_FORCE_INLINE Canvas(fl::span< RGB_T > buf, int w, int h)
Definition gfx.h:55
FASTLED_FORCE_INLINE void blurGaussian()
Definition gfx.h:74
FASTLED_FORCE_INLINE RGB_T & at(int x, int y)
Definition gfx.h:59
FASTLED_FORCE_INLINE Canvas(fl::shared_ptr< RGB_T > ptr, int w, int h)
Definition gfx.h:56
FASTLED_FORCE_INLINE void drawStrokeLine(const RGB_T &color, Coord x0, Coord y0, Coord x1, Coord y1, Coord thickness, LineCap cap=LineCap::FLAT, DrawMode mode=DrawMode::DRAW_MODE_BLEND)
Definition gfx.h:97
gfx::Canvas< RGB_T > mImpl
Definition gfx.h:52
FASTLED_FORCE_INLINE void blurGaussian(alpha8 dimFactor)
Definition gfx.h:64
FASTLED_FORCE_INLINE void blurGaussian(alpha16 dimFactor)
Definition gfx.h:69
Convenience alias for CRGB canvas — use fl::CanvasRGB for no-template syntax.
Definition gfx.h:105
Defines the 8-bit red, green, and blue (RGB) pixel type in the fl namespace.
LineCap
Line cap styles for stroke operations.
Definition canvas.h:19
gfx::LineCap LineCap
Line cap style.
Definition gfx.h:46
DrawMode
Definition draw_mode.h:5
@ DRAW_MODE_BLEND
Definition draw_mode.h:5
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_FORCE_INLINE
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
Unsigned 16-bit alpha / brightness — UNORM16.
Definition alpha.h:87
Unsigned 8-bit alpha / brightness — UNORM8.
Definition alpha.h:42
Simple rectangular canvas for graphics operations Combines a pixel buffer with dimensions for cache-o...
Definition canvas.h:66