FastLED 3.10.10
Loading...
Searching...
No Matches
gfx.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/noexcept.h"
4
40
42#include "fl/gfx/crgb.h"
43#include "fl/gfx/draw_mode.h"
44
45// IWYU pragma: begin_keep
46#include "fl/gfx/canvas.h"
47#include "fl/gfx/primitives.h"
48// IWYU pragma: end_keep
49
50namespace fl {
51
54
56template<typename Coord>
58
61template<typename RGB_T>
62class Canvas {
64
65 public:
66 FASTLED_FORCE_INLINE Canvas(fl::span<RGB_T> buf, int w, int h) : mImpl(buf, w, h) {}
67 FASTLED_FORCE_INLINE Canvas(fl::shared_ptr<RGB_T> ptr, int w, int h) : mImpl(ptr, w, h) {}
68
69 FASTLED_FORCE_INLINE int size() const { return mImpl.size(); }
70 FASTLED_FORCE_INLINE RGB_T& at(int x, int y) { return mImpl.at(x, y); }
71 FASTLED_FORCE_INLINE const RGB_T& at(int x, int y) const { return mImpl.at(x, y); }
72 FASTLED_FORCE_INLINE bool has(int x, int y) const { return mImpl.has(x, y); }
73
74 template<int hRadius, int vRadius>
76 mImpl.template blurGaussian<hRadius, vRadius>(dimFactor);
77 }
78
79 template<int hRadius, int vRadius>
81 mImpl.template blurGaussian<hRadius, vRadius>(dimFactor);
82 }
83
84 template<int hRadius, int vRadius>
88
89 template<typename Coord>
90 FASTLED_FORCE_INLINE void drawLine(const RGB_T& color, Coord x0, Coord y0, Coord x1, Coord y1,
92 mImpl.drawLine(color, x0, y0, x1, y1, mode);
93 }
94
95 template<typename Coord>
96 FASTLED_FORCE_INLINE void drawDisc(const RGB_T& color, Coord cx, Coord cy, Coord r,
98 mImpl.drawDisc(color, cx, cy, r, mode);
99 }
100
101 template<typename Coord>
102 FASTLED_FORCE_INLINE void drawRing(const RGB_T& color, Coord cx, Coord cy, Coord r, Coord thickness,
104 mImpl.drawRing(color, cx, cy, r, thickness, mode);
105 }
106
107 template<typename Coord>
108 FASTLED_FORCE_INLINE void drawStrokeLine(const RGB_T& color, Coord x0, Coord y0, Coord x1, Coord y1,
109 Coord thickness, LineCap cap = LineCap::FLAT,
111 mImpl.drawStrokeLine(color, x0, y0, x1, y1, thickness, cap, mode);
112 }
113
114 template<typename Coord, int MAXN = FL_GFX_POLYGON_DEFAULT_MAXN,
121
122 template<typename Coord, int N, int MAXN = FL_GFX_POLYGON_DEFAULT_MAXN,
129};
130
132class CanvasRGB : protected Canvas<CRGB> {
133 public:
134 using Canvas<CRGB>::Canvas;
135 using Canvas<CRGB>::size;
136 using Canvas<CRGB>::at;
137 using Canvas<CRGB>::has;
139 using Canvas<CRGB>::drawLine;
140 using Canvas<CRGB>::drawDisc;
141 using Canvas<CRGB>::drawRing;
144};
145
146} // namespace fl
#define FL_GFX_POLYGON_DEFAULT_CHUNK
Definition canvas.h:70
#define FL_GFX_POLYGON_DEFAULT_MAXN
Default drawPolygon tier (MAXN vertex cap, CHUNK accumulator px) Both kernels keep their whole workin...
Definition canvas.h:62
Canvas types for gfx primitives (implementation)
FASTLED_FORCE_INLINE bool has(int x, int y) const
Definition gfx.h:72
FASTLED_FORCE_INLINE int size() const
Definition gfx.h:69
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:90
FASTLED_FORCE_INLINE const RGB_T & at(int x, int y) const
Definition gfx.h:71
FASTLED_FORCE_INLINE void drawPolygon(const RGB_T &color, const PolyPoint< Coord >(&pts)[N], DrawMode mode=DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
Definition gfx.h:125
FASTLED_FORCE_INLINE Canvas(fl::span< RGB_T > buf, int w, int h)
Definition gfx.h:66
FASTLED_FORCE_INLINE void blurGaussian()
Definition gfx.h:85
FASTLED_FORCE_INLINE RGB_T & at(int x, int y)
Definition gfx.h:70
FASTLED_FORCE_INLINE Canvas(fl::shared_ptr< RGB_T > ptr, int w, int h)
Definition gfx.h:67
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:102
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:96
gfx::Canvas< RGB_T > mImpl
Definition gfx.h:63
FASTLED_FORCE_INLINE void blurGaussian(alpha8 dimFactor)
Definition gfx.h:75
FASTLED_FORCE_INLINE void blurGaussian(alpha16 dimFactor)
Definition gfx.h:80
FASTLED_FORCE_INLINE void drawPolygon(const RGB_T &color, fl::span< const PolyPoint< Coord > > pts, DrawMode mode=DrawMode::DRAW_MODE_BLEND) FL_NO_EXCEPT
Definition gfx.h:117
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:108
Convenience alias for CRGB canvas — use fl::CanvasRGB for no-template syntax.
Definition gfx.h:132
Defines the 8-bit red, green, and blue (RGB) pixel type in the fl namespace.
PolyFill
Fill backend for drawPolygon Both backends use the even-odd rule and the same row/vertex conventions;...
Definition canvas.h:38
LineCap
Line cap styles for stroke operations.
Definition canvas.h:20
Polygon vertex (x, y coordinate pair) for drawPolygon C++11 aggregate: PolyPoint<float> p{3....
Definition canvas.h:25
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
gfx::PolyPoint< Coord > PolyPoint
Polygon vertex (x, y coordinate pair) for drawPolygon.
Definition gfx.h:57
gfx::LineCap LineCap
Line cap style.
Definition gfx.h:53
DrawMode
Definition draw_mode.h:5
@ DRAW_MODE_BLEND
Definition draw_mode.h:5
Base definition for an LED controller.
#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:138