Closed bluenote10 closed 1 month ago
Thank you for reporting this! I knew I had under-tested some of the plotters code, but some of that label drawing is pretty bad too.
The fuzziness is almost certainly due to me trying to automatically scale the plotters output based on DPI scaling. It seems like the more correct approach is going to be to let it be pixel-perfect rendering, and require that the plotters-integrator worry about dpi scaling themselves.
As for where to report the issue, I'm happy with most issues being reported on this repository -- it's where most users might actually encounter a bug. I can always create a separate issue and link them if I think someone else might tackle it, but right now I'm usually the person to fix something in Kludgine!
Things are looking better! I can't seem to figure out how the labels are sized -- I put a lot of logging code in, and I notice plotters measures the chart caption, but not the labels. My picture shows two series because I was trying to see if that would cause it to measure the text... but it didn't.
The issues were not what I originally suspected. It was that to draw a pixel-perfect 1px wide line, the coordinates need to be offset because lyon generates a rectangle centered on the path coordinates. To ensure the 1px wide line isn't split across two lines with Kludgine's subpixel rendering support, the coordinates need to be offset by 1/2 a pixel, or more generalized, half of the stroke width.
Beyond that, the text drawing code didn't support anchoring or alignment or rotation. This plot doesn't rotate text, but in theory everything is handled correctly now -- don't hesitate to let me know if you run into other issues! If you test the main branch, be sure to use cargo update
to get Kludgine's changes.
Actually I'm reopening this because I'd like to have you weigh in on what's happening with the labels, if you know more about how plotters works.
Thanks for the fix!
Actually I'm reopening this because I'd like to have you weigh in on what's happening with the labels, if you know more about how plotters works.
In my opinion, this looks pretty much what I would expect now, so closing the issue should be fine. In case anything else comes up I'll let you know. I also don't have much expertise with plotters, mainly just trying things out so far.
I noticed that the
plotters
integration has some minor rendering issues when compared to the "reference" plotters backend. Given the two minimal reproduction examples:Example using cushy/kludgine backend
```rust // Note that this requires to enable the corresponding plotters feature, // i.e., default-feature = false will not work. use cushy::widget::MakeWidget; use cushy::widgets::Canvas; use cushy::Run; use plotters::prelude::*; pub fn basic_plot( root: &DrawingArea, ) -> Result<(), BoxExample using plain plotters backend
```rust use plotters::prelude::*; fn main() -> Result<(), BoxThe cushy/kludgine based output is:
The plotters based output is:
The main issue is that text labels are wrongly aligned. Minor issues are that the line anti-aliasing doesn't look as good, and that the grid get aliased instead of being pixel perfect (but likely that is expected if the size of the drawing area doesn't allow for integer multiples of the grid size).
Since I'm not entirely sure if this a cushy or kludgine issue (or even further upstream?), I decided to report it on cushy. Do you generally prefer such issues being raised further upstream if possible?
Note that the lack of clipping is an upsteam issue in plotters https://github.com/plotters-rs/plotters/issues/622