gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
half_grayscale_v.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
17color_t halfGrayscaleV(color_t pixel, const Coords &coords, const Size &size) {
18 if (coords.x <= size.x / 2) {
19 return pixel;
20 }
21
22 float r, g, b;
23 colorComponents(pixel, r, g, b);
24
25 float gray = r * 0.299 + g * 0.587 + b * 0.113;
26 return color(gray, gray, gray);
27}
28
29} // namespace shader
30} // namespace ui
constexpr color_t color(const float red, const float green, const float blue)
Convert normalized color components into an RGB565 value.
Definition color.hpp:31
void colorComponents(color_t color, float &red, float &green, float &blue)
Split an RGB565 color value into normalized components.
uint16_t color_t
An RGB565 color value. 5 bits red, 6 bits green, 5 bits blue.
Definition color.hpp:13
color_t halfGrayscaleV(color_t pixel, const Coords &coords, const Size &size)
A pixel shader that converts the right half of an image to grayscale.
Definition half_grayscale_v.hpp:17
A struct for storing the pixel coordinates of various UI elements.
Definition coords.hpp:17
coord_t x
The horizontal coordinate.
Definition coords.hpp:19
A struct that holds the number of pixels that a widget would take up on the screen.
Definition size.hpp:17
uisize_t x
The width of the widget.
Definition size.hpp:19