feat(canvas): add scale factor to canvas options#122
feat(canvas): add scale factor to canvas options#122Wybxc wants to merge 3 commits intoratatui:mainfrom
Conversation
junkdog
left a comment
There was a problem hiding this comment.
neat trick for nicer-looking rendering :)
orhun
left a comment
There was a problem hiding this comment.
looking good to me, would be nice to address Adrian's points :)
| /// | ||
| /// Panics if `scale` is not positive. | ||
| pub fn scale(mut self, scale: f64) -> Self { | ||
| if scale <= 0.0 { |
There was a problem hiding this comment.
should it be scale < 0.0? i guess 0 is not a valid scale.
i think it would be good to set a restriction the upper bounds too, maybe 4.0 - it's already at x16 memory consumption. i haven't tried it locally, but i guess setting really high values would cause the canvas to fail somehow.
otherwise i think it LGTM 👍
There was a problem hiding this comment.
should it be
scale < 0.0? i guess 0 is not a valid scale.
When the scale is set to 0, the graphic will not be displayed, so it is reasonable to throw an error when scale=0.
i think it would be good to set a restriction the upper bounds too, maybe 4.0 - it's already at x16 memory consumption.
Excessively high scaling requires substantial hardware resources, but it is not impossible to run. In such cases, I believe a hard error should not be issued - after all, with sufficient computational resources, it remains feasible to execute. A warning, or even just a note in the documentation to caution users, would suffice.
There was a problem hiding this comment.
so it is reasonable to throw an error when scale=0.
i can't read if statements 😅 yeah, i agree - scale=0 should throw.
Excessively high scaling
do values above 3-4 have any visual impact?
what happens to the canvas/tab/browser/system if it allocates more memory than the user has available? (i can take a look after work too)
There was a problem hiding this comment.
do values above 3-4 have any visual impact?
In fact, 3x resolution has reached the limit of what is discernible. Perhaps I should make this point clearer in the documentation.
what happens to the canvas/tab/browser/system if it allocates more memory than the user has available? (i can take a look after work too)
First, the running speed will slow down. If increased further, the entire webpage (Firefox) or the <canvas> element (Safari/Chrome) will stop functioning. However, in any case, the browser's security measures are well-implemented and will not allow a webpage to consume all system resources.
There was a problem hiding this comment.
if there's no discernible difference except resource consumption past 3x, i think we can restrict the range to <= 3 (or 4). or is there ever a reason for higher scale values?
There was a problem hiding this comment.
would be also nice to document the side effects of slightly high values
This Pull Request introduces a
scaleoption to the canvas options. Setting the scale to a value greater than 1 enables rendering graphics at a higher internal resolution, producing sharper output.scale=1.0:
scale=2.0: