Fix for Canvas.rows() output being 1 row/col too large when Canvas::new() is passed particular values #15
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.
Fixes #14, where output string can be 1 row and/or col too large resulting in additional white space when given width is divisible by 2 and/or height is divisible by 4.
The only time this issue occurs is when
Canvas::new()
is called and the given width/height are divisible by the 'braille-pixel' ratio, where width is divisible by 2 and height by 4. For example if a width of 12 is given, the Canvas struct'swidth
would be 6 and whenrows()
is called, themaxrow
variable would be off by one and cause an additional empty column to appear in the output string. Another example, if a height of 4 is given, the Canvas'height
would be 1 and whenrows()
is called, themaxcol
variable would be set to 1, allowing the loop to run an additional iteration and inserting an empty row in the output string.Prior to this fix, the following code:
Would output the following:
And with the fix the output is instead:
Let me know if there's anything else I could do or if there's an issue with this pull request. Thank you!