PicoGraphics: Add create_pen_hsv to p4, p8 and rgb332 pens.

This commit is contained in:
Phil Howard 2023-02-13 10:38:50 +00:00 committed by Phil Howard
parent bbeac41785
commit f4b0434229
4 changed files with 24 additions and 0 deletions

View File

@ -372,6 +372,7 @@ namespace pimoroni {
void set_thickness(uint t) override {};
int update_pen(uint8_t i, uint8_t r, uint8_t g, uint8_t b) override;
int create_pen(uint8_t r, uint8_t g, uint8_t b) override;
int create_pen_hsv(float h, float s, float v) override;
int reset_pen(uint8_t i) override;
void set_pixel(const Point &p) override;
@ -402,6 +403,7 @@ namespace pimoroni {
void set_thickness(uint t) override {};
int update_pen(uint8_t i, uint8_t r, uint8_t g, uint8_t b) override;
int create_pen(uint8_t r, uint8_t g, uint8_t b) override;
int create_pen_hsv(float h, float s, float v) override;
int reset_pen(uint8_t i) override;
void set_pixel(const Point &p) override;
@ -423,6 +425,7 @@ namespace pimoroni {
void set_pen(uint8_t r, uint8_t g, uint8_t b) override;
void set_thickness(uint t) override {};
int create_pen(uint8_t r, uint8_t g, uint8_t b) override;
int create_pen_hsv(float h, float s, float v) override;
void set_pixel(const Point &p) override;
void set_pixel_span(const Point &p, uint l) override;
void set_pixel_dither(const Point &p, const RGB &c) override;

View File

@ -44,6 +44,13 @@ namespace pimoroni {
}
return -1;
}
int PicoGraphics_PenP4::create_pen_hsv(float h, float s, float v) {
uint8_t r;
uint8_t g;
uint8_t b;
from_hsv(h, s, v, r, g, b);
return create_pen(r, g, b);
}
int PicoGraphics_PenP4::reset_pen(uint8_t i) {
palette[i] = {0, 0, 0};
used[i] = false;

View File

@ -39,6 +39,13 @@ namespace pimoroni {
}
return -1;
}
int PicoGraphics_PenP8::create_pen_hsv(float h, float s, float v) {
uint8_t r;
uint8_t g;
uint8_t b;
from_hsv(h, s, v, r, g, b);
return create_pen(r, g, b);
}
int PicoGraphics_PenP8::reset_pen(uint8_t i) {
palette[i] = {0, 0, 0};
used[i] = false;

View File

@ -18,6 +18,13 @@ namespace pimoroni {
int PicoGraphics_PenRGB332::create_pen(uint8_t r, uint8_t g, uint8_t b) {
return rgb_to_rgb332(r, g, b);
}
int PicoGraphics_PenRGB332::create_pen_hsv(float h, float s, float v) {
uint8_t r;
uint8_t g;
uint8_t b;
from_hsv(h, s, v, r, g, b);
return rgb_to_rgb332(r, g, b);
}
void PicoGraphics_PenRGB332::set_pixel(const Point &p) {
uint8_t *buf = (uint8_t *)frame_buffer;
buf[p.y * bounds.w + p.x] = color;