Skip to content

Conversation

@Demkeys
Copy link
Contributor

@Demkeys Demkeys commented Oct 5, 2025

Hello, I have added a feature to allow the user to specify a background color using the -B flag, similar to how they would specify a color with the -C flag. There is no default value for -B so if user doesn't specify it, it never gets set.

image image

Implementation:

  • Added a bg_color field of type Option to the Cli struct.
  • Added rain_bg_color() to get background color in Option<u8,u8,u8> form.
  • bg_color being Option allows us to ignore bg_color if user hasn't specified the -B flag. If bg_color is passed in through CLI arguments, then SetBackgroundColor() sets the background color to that color.
  • In setup_terminal() I wasn't sure if I could put the logic into the same execute!() call so I made a separate one to call SetBackgroundColor().

Notes:
One small caveat is that background color won't fully take effect until the program has drawn characters on all cells visible on the screen, so for the first few seconds of the runtime you'll see something like this:
image

But that only lasts for a few seconds, and eventually the background color fills the entire screen.

@Demkeys Demkeys closed this Oct 6, 2025
@Demkeys Demkeys reopened this Oct 6, 2025
@Demkeys
Copy link
Contributor Author

Demkeys commented Oct 6, 2025

Accidentally closed. Reopened it.

@cowboy8625
Copy link
Owner

Hey I like this! I've been thinking about doing this my self! Thanks! :)

Copy link
Owner

@cowboy8625 cowboy8625 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small comments, but over all looks good. I still need to test.

@Demkeys
Copy link
Contributor Author

Demkeys commented Oct 9, 2025

Ok done. Also thanks for the tip about Clear()!

@cowboy8625
Copy link
Owner

Awesome! Thanks for your interest in the project!

@cowboy8625 cowboy8625 merged commit 22c8e54 into cowboy8625:master Oct 9, 2025
6 checks passed
@cowboy8625 cowboy8625 added the enhancement New feature or request label Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants