FastLED 3.10.8
Loading...
Searching...
No Matches
gfx.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/noexcept.h"
4
35
37#include "fl/gfx/crgb.h"
38#include "fl/gfx/draw_mode.h"
39
40// IWYU pragma: begin_keep
41#include "fl/gfx/canvas.h"
42#include "fl/gfx/primitives.h"
43// IWYU pragma: end_keep
44
45namespace fl {
46
49
52template<typename RGB_T>
53class Canvas {
55
56 public:
57 FASTLED_FORCE_INLINE Canvas(fl::span<RGB_T> buf, int w, int h) : mImpl(buf, w, h) {}
58 FASTLED_FORCE_INLINE Canvas(fl::shared_ptr<RGB_T> ptr, int w, int h) : mImpl(ptr, w, h) {}
59
60 FASTLED_FORCE_INLINE int size() const { return mImpl.size(); }
61 FASTLED_FORCE_INLINE RGB_T& at(int x, int y) { return mImpl.at(x, y); }
62 FASTLED_FORCE_INLINE const RGB_T& at(int x, int y) const { return mImpl.at(x, y); }
63 FASTLED_FORCE_INLINE bool has(int x, int y) const { return mImpl.has(x, y); }
64
65 template<int hRadius, int vRadius>
67 mImpl.template blurGaussian<hRadius, vRadius>(dimFactor);
68 }
69
70 template<int hRadius, int vRadius>
72 mImpl.template blurGaussian<hRadius, vRadius>(dimFactor);
73 }
74
75 template<int hRadius, int vRadius>
79
80 template<typename Coord>
81 FASTLED_FORCE_INLINE void drawLine(const RGB_T& color, Coord x0, Coord y0, Coord x1, Coord y1,
83 mImpl.drawLine(color, x0, y0, x1, y1, mode);
84 }
85
86 template<typename Coord>
87 FASTLED_FORCE_INLINE void drawDisc(const RGB_T& color, Coord cx, Coord cy, Coord r,
89 mImpl.drawDisc(color, cx, cy, r, mode);
90 }
91
92 template<typename Coord>
93 FASTLED_FORCE_INLINE void drawRing(const RGB_T& color, Coord cx, Coord cy, Coord r, Coord thickness,
95 mImpl.drawRing(color, cx, cy, r, thickness, mode);
96 }
97
98 template<typename Coord>
99 FASTLED_FORCE_INLINE void drawStrokeLine(const RGB_T& color, Coord x0, Coord y0, Coord x1, Coord y1,
100 Coord thickness, LineCap cap = LineCap::FLAT,
102 mImpl.drawStrokeLine(color, x0, y0, x1, y1, thickness, cap, mode);
103 }
104};
105
107class CanvasRGB : protected Canvas<CRGB> {
108 public:
109 using Canvas<CRGB>::Canvas;
110 using Canvas<CRGB>::size;
111 using Canvas<CRGB>::at;
112 using Canvas<CRGB>::has;
114 using Canvas<CRGB>::drawLine;
115 using Canvas<CRGB>::drawDisc;
116 using Canvas<CRGB>::drawRing;
118};
119
120} // namespace fl
Canvas types for gfx primitives (implementation)
FASTLED_FORCE_INLINE bool has(int x, int y) const
Definition gfx.h:63
FASTLED_FORCE_INLINE int size() const
Definition gfx.h:60
FASTLED_FORCE_INLINE void drawLine(const RGB_T &color, Coord x0, Coord y0, Coord x1, Coord y1, DrawMode mode=DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
Definition gfx.h:81
FASTLED_FORCE_INLINE const RGB_T & at(int x, int y) const
Definition gfx.h:62
FASTLED_FORCE_INLINE Canvas(fl::span< RGB_T > buf, int w, int h)
Definition gfx.h:57
FASTLED_FORCE_INLINE void blurGaussian()
Definition gfx.h:76
FASTLED_FORCE_INLINE RGB_T & at(int x, int y)
Definition gfx.h:61
FASTLED_FORCE_INLINE Canvas(fl::shared_ptr< RGB_T > ptr, int w, int h)
Definition gfx.h:58
FASTLED_FORCE_INLINE void drawRing(const RGB_T &color, Coord cx, Coord cy, Coord r, Coord thickness, DrawMode mode=DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
Definition gfx.h:93
FASTLED_FORCE_INLINE void drawDisc(const RGB_T &color, Coord cx, Coord cy, Coord r, DrawMode mode=DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
Definition gfx.h:87
gfx::Canvas< RGB_T > mImpl
Definition gfx.h:54
FASTLED_FORCE_INLINE void blurGaussian(alpha8 dimFactor)
Definition gfx.h:66
FASTLED_FORCE_INLINE void blurGaussian(alpha16 dimFactor)
Definition gfx.h:71
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) FL_NO_EXCEPT
Definition gfx.h:99
Convenience alias for CRGB canvas — use fl::CanvasRGB for no-template syntax.
Definition gfx.h:107
#define FASTLED_FORCE_INLINE
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
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
gfx::LineCap LineCap
Line cap style.
Definition gfx.h:48
DrawMode
Definition draw_mode.h:5
@ DRAW_MODE_BLEND
Definition draw_mode.h:5
Base definition for an LED controller.
Definition crgb.hpp:179
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