gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
glow.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "../../core/color.hpp"
5#include "../../core/coords.hpp"
6#include "../../core/size.hpp"
7
8namespace ui {
9namespace shader {
10
19template <unsigned int frequency>
20color_t glow(color_t pixel, const Coords &coords, const Size &size, time_t time) {
21 float r, g, b;
22 colorComponents(pixel, r, g, b);
23
24 float ratio = .5f - sin(time * (6.283f / (float)frequency)) / 2.f;
25
26 return blend(pixel, ui::COLOR_WHITE, ratio);
27}
28
29} // namespace shader
30} // namespace ui
void colorComponents(color_t color, float &red, float &green, float &blue)
Split an RGB565 color value into normalized components.
color_t blend(color_t color1, color_t color2, float ratio=0.5f)
Blend two colors, preserving apparent brightness.
uint16_t color_t
An RGB565 color value. 5 bits red, 6 bits green, 5 bits blue.
Definition color.hpp:13
@ COLOR_WHITE
Definition color.hpp:87
color_t glow(color_t pixel, const Coords &coords, const Size &size, time_t time)
A pixel shader that smoothly cycles between an image's original color and white.
Definition glow.hpp:20
A struct for storing the pixel coordinates of various UI elements.
Definition coords.hpp:17
A struct that holds the number of pixels that a widget would take up on the screen.
Definition size.hpp:17