Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About
This pull request adds two new functions, GLIR_PrintOVLine and GLIR_PrintOHLine, to the GLIR (Graphics Library for Interactive RISC-V) codebase. These functions are designed to print overlapping vertical and horizontal lines on the screen, respectively, without requiring the screen to be cleared before each update.
Motivation
I was creating a CMPUT 229 lab assignment using GLIR (mostly printing plain, solid-colored, straight lines) that had many screen updates. I tried using the Clear and Refresh method for the updates, but realized it resulted in annoying flickers due to the latency from needing to clear the screen and printing many lines. The Batch Print method would also be excessive for this lab assignment and slow. Due to these limitations, I decided to make my own function that overlaps the line underneath by printing a straight line and filling the areas that the line does not span the default terminal color. It is essentially following the Clear and Refresh method without clearing the screen, thus, reduce the aforementioned flickers.
Usage
GLIR_PrintOVLine
The GLIR_PrintOVLine function takes four arguments:
This function prints an overlapping vertical line on the screen between the points (Row1, Col) and (Row2, Col). It ensures that the area outside the line (above Row1 and below Row2) remains the default background, allowing for overlapping lines without screen clearing. This feature is particularly useful for smooth animations and eliminates flickering caused by frequent screen clears.
GLIR_PrintOHLine
The GLIR_PrintOHLine function takes four arguments:
Similarly, this function prints an overlapping horizontal line on the screen between the points (Row, Col1) and (Row, Col2). It maintains a default background outside the line's range (to the left of Col1 and to the right of Col2), allowing for seamless overlapping of lines without the need for screen clearing.
Implementation
Both functions use the existing GLIR_PrintString function to print the line characters and leverage the GLIR_SetColor and GLIR_RestoreSettings functions to manage the line color.
Remarks
These additions provide efficient alternatives for updating the screen in graphics-intensive applications with many updates and enhance the GLIR library's capabilities.
I am open to feedback and willing to make any necessary changes to this pull request. Please don't hesitate to reach out if there are any suggestions or improvements that you would like to discuss.