Add background image to weather

This commit is contained in:
Tyler Perkins 2021-12-21 16:28:57 -05:00
parent 076b905c72
commit 14cf97ac33
8 changed files with 13 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

BIN
img/sky.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
img/square.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

View File

@ -21,6 +21,7 @@ dashboard::panel::panel* OVERLAY = new dashboard::panel::def_overlay();
// Locations of all static images used // Locations of all static images used
const char* IMAGE_LOCATIONS[] = { const char* IMAGE_LOCATIONS[] = {
"bmp_24.png", "bmp_24.png",
"sky.png",
}; };
size_t IMAGE_LOCATIONS_LENGTH = sizeof(IMAGE_LOCATIONS)/sizeof(IMAGE_LOCATIONS[0]); size_t IMAGE_LOCATIONS_LENGTH = sizeof(IMAGE_LOCATIONS)/sizeof(IMAGE_LOCATIONS[0]);

View File

@ -37,7 +37,6 @@ def_overlay::~def_overlay(){
void def_overlay::draw(){ void def_overlay::draw(){
//create the texture if this is the first time running draw //create the texture if this is the first time running draw
if(_texture == nullptr){ if(_texture == nullptr){
std::cerr << "IN FIRST SETUP\n";
initTexture(); initTexture();
update(); update();
update_texture(); update_texture();
@ -89,6 +88,8 @@ void def_overlay::update_texture() {
SDL_SetRenderDrawColor(board::getRenderer(), SDL_SetRenderDrawColor(board::getRenderer(),
0x00, 0x00, 0x00, 0x00); 0x00, 0x00, 0x00, 0x00);
SDL_RenderClear(board::getRenderer());
//set the new color //set the new color
SDL_SetRenderDrawColor(board::getRenderer(), SDL_SetRenderDrawColor(board::getRenderer(),
DEF_OVERLAY_BAR_RED, DEF_OVERLAY_BAR_GREEN, DEF_OVERLAY_BAR_RED, DEF_OVERLAY_BAR_GREEN,
@ -112,16 +113,14 @@ void def_overlay::update_texture() {
DEF_OVERLAY_TEXT_BLUE, DEF_OVERLAY_TEXT_ALPHA); DEF_OVERLAY_TEXT_BLUE, DEF_OVERLAY_TEXT_ALPHA);
//show the date and time //show the date and time
TTF_SizeText(board::getFont({ "Roboto_Mono/RobotoMono-Medium.ttf", 28 }), TTF_SizeText(board::getFont({ "Roboto_Mono/RobotoMono-Medium.ttf", 50 }),
date_time.c_str(), date_time.c_str(),
&tgt.w, &tgt.h); &tgt.w, &tgt.h);
tgt.x = SCREEN_WIDTH - tgt.w + 25; tgt.x = SCREEN_WIDTH - tgt.w + 25;
tgt.y = -5; tgt.y = -5;
SDL_RenderCopy(board::getRenderer(), SDL_RenderCopy(board::getRenderer(),
board::getString(date_time.c_str(), board::getString(date_time.c_str(),
{ "Roboto_Mono/RobotoMono-Medium.ttf", 28 }), NULL, &tgt); { "Roboto_Mono/RobotoMono-Medium.ttf", 50 }), NULL, &tgt);
SDL_SetRenderTarget(board::getRenderer(), NULL); SDL_SetRenderTarget(board::getRenderer(), NULL);

View File

@ -22,8 +22,8 @@ namespace dashboard::panel {
constexpr uint8_t DEF_OVERLAY_TEXT_BLUE = 0xCC; constexpr uint8_t DEF_OVERLAY_TEXT_BLUE = 0xCC;
constexpr uint8_t DEF_OVERLAY_TEXT_ALPHA = 0xFF; constexpr uint8_t DEF_OVERLAY_TEXT_ALPHA = 0xFF;
constexpr uint8_t DEF_OVERLAY_BAR_RED = 0x00; constexpr uint8_t DEF_OVERLAY_BAR_RED = 0xD3;
constexpr uint8_t DEF_OVERLAY_BAR_GREEN = 0x00; constexpr uint8_t DEF_OVERLAY_BAR_GREEN = 0xD3;
constexpr uint8_t DEF_OVERLAY_BAR_BLUE = 0x00; constexpr uint8_t DEF_OVERLAY_BAR_BLUE = 0xD3;
constexpr uint8_t DEF_OVERLAY_BAR_ALPHA = 0xCC; constexpr uint8_t DEF_OVERLAY_BAR_ALPHA = 0x7F;
} }

View File

@ -88,6 +88,10 @@ void weather::update_texture(){
SDL_SetRenderTarget(board::getRenderer(), _texture); SDL_SetRenderTarget(board::getRenderer(), _texture);
SDL_RenderClear(board::getRenderer()); SDL_RenderClear(board::getRenderer());
//background image
SDL_RenderCopy(board::getRenderer(),
board::getImage("sky.png"), NULL, NULL);
//title //title
tgt.x = 50; tgt.x = 50;
tgt.y = 50; tgt.y = 50;