FastLED 3.9.15
Loading...
Searching...
No Matches
draw_visitor.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#include "crgb.h"
6#include "fl/geometry.h"
7#include "fl/gradient.h"
8#include "fl/namespace.h"
9#include "fl/unused.h"
10#include "fl/xymap.h"
11
12namespace fl {
13
14// Draws a uint8_t value to a CRGB array, blending it with the existing color.
16 XYDrawComposited(const CRGB &color, const XYMap &xymap, CRGB *out);
17 void draw(const vec2<int> &pt, uint32_t index, uint8_t value);
18 const CRGB mColor;
21};
22
24 XYDrawGradient(const Gradient &gradient, const XYMap &xymap, CRGB *out);
25 void draw(const vec2<int> &pt, uint32_t index, uint8_t value);
29};
30
32 CRGB *out)
33 : mColor(color), mXYMap(xymap), mOut(out) {}
34
35inline void XYDrawComposited::draw(const vec2<int> &pt, uint32_t index,
36 uint8_t value) {
38 CRGB &c = mOut[index];
39 CRGB blended = mColor;
40 blended.fadeToBlackBy(255 - value);
41 c = CRGB::blendAlphaMaxChannel(blended, c);
42}
43
45 const XYMap &xymap, CRGB *out)
46 : mGradient(gradient), mXYMap(xymap), mOut(out) {}
47
48inline void XYDrawGradient::draw(const vec2<int> &pt, uint32_t index,
49 uint8_t value) {
51 CRGB c = mGradient.colorAt(value);
52 mOut[index] = c;
53}
54
55} // namespace fl
XYMap xymap(WIDTH, HEIGHT, SERPENTINE)
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
static CRGB blendAlphaMaxChannel(const CRGB &upper, const CRGB &lower)
Definition crgb.cpp:59
CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.cpp:111
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55
XYDrawComposited(const CRGB &color, const XYMap &xymap, CRGB *out)
void draw(const vec2< int > &pt, uint32_t index, uint8_t value)
const Gradient mGradient
XYDrawGradient(const Gradient &gradient, const XYMap &xymap, CRGB *out)
void draw(const vec2< int > &pt, uint32_t index, uint8_t value)
const XYMap mXYMap
#define FASTLED_UNUSED(x)
Definition unused.h:3