Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(examples): add colors_rgb example #476

Merged
merged 1 commit into from
Sep 10, 2023
Merged

docs(examples): add colors_rgb example #476

merged 1 commit into from
Sep 10, 2023

Conversation

joshka
Copy link
Member

@joshka joshka commented Sep 9, 2023

Helpful for diagnosing what's happening with #475

colors_rgb

@codecov
Copy link

codecov bot commented Sep 9, 2023

Codecov Report

Merging #476 (37f0194) into main (0c68ebe) will not change coverage.
Report is 2 commits behind head on main.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #476   +/-   ##
=======================================
  Coverage   90.06%   90.06%           
=======================================
  Files          40       41    +1     
  Lines       11166    11166           
=======================================
  Hits        10057    10057           
  Misses       1109     1109           

see 2 files with indirect coverage changes

examples/colors.rs Outdated Show resolved Hide resolved
@kdheepak
Copy link
Collaborator

kdheepak commented Sep 9, 2023

Do you think this should just be a separate demo?

@joshka
Copy link
Member Author

joshka commented Sep 9, 2023

Do you think this should just be a separate demo?

Yes probably. I wasn't sure about it myself, so just went with adding code, but it wouldn't hurt.

@orhun
Copy link
Member

orhun commented Sep 9, 2023

Works great!

It isn't really intuitive from the demo so I'd also say that we should have this as a separate example.

@joshka
Copy link
Member Author

joshka commented Sep 9, 2023

I tweaked a bunch of stuff in the updated example:

  • Modified color grid to be smooth by mirroring blue channel every 16 pixels instead of starting at 0
  • Changed to buf.cell_mut() this is noticeably faster to render than using Paragraph
  • App-ified and Widget-ified implementation
    • Removed manual Error printing (returning Result<()> handles this automatically)
    • panic hook and Drop impl (because I kept getting index out of bounds errors when playing around with generating the grid)
  • Simplified everything as much as possible

Made with VHS

@joshka joshka force-pushed the example-color-rgb branch 2 times, most recently from 369cb41 to a38b3c6 Compare September 9, 2023 09:16
@joshka
Copy link
Member Author

joshka commented Sep 9, 2023

  • Added example to cargo toml and fixed commit message

@joshka joshka changed the title docs(examples): add rgb page to color example docs(examples): add colors_rgb example Sep 9, 2023
examples/colors_rgb.rs Outdated Show resolved Hide resolved
@joshka
Copy link
Member Author

joshka commented Sep 9, 2023

moved the init/restore/panic hook to the bottom of the file to make the example really hyper focus on the application logic and example rather than the generic terminal parts.

@joshka joshka requested review from kdheepak and orhun September 10, 2023 00:09
@joshka joshka merged commit 6b8725f into main Sep 10, 2023
31 checks passed
@joshka joshka deleted the example-color-rgb branch September 10, 2023 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants