CANVAS Line DPI

Hi there,

canvas lines are showing a low resolution on 4K Monitors?
It possbile to so set the dpi

  • on the lines?
  • on the complete Canvas?

Alternative: PIL ?

BR
Gerhard

I don’t think they are shown in low resolution, more likely they don’t look pretty because don’t have anti-aliasing.

I don’t know if the canvas manages anti-aliasing out of the box. Try to do some research about it…

If it doesn’t, I don’t think PIL would be the right thing for you, because it looks like you are trying to draw on the canvas directly (that is on the client), while PIL would work only on the server side.

I think the Canvas is a bitmap, despite the SVG-like methods.

Could you create an SVG image instead? That should scale to any monitor (or printer).

It might not be relevant, but you might find this helpful

https://anvil-extras.readthedocs.io/en/latest/guides/modules/utils.html#correct-canvas-resolution


from anvil_extras.utils import correct_canvas_resolution

class MyForm(MyFormTemplate):
     ...

     def canvas_reset(self, **event_args):
         c = self.canvas
         correct_canvas_resolution(c)
         ...

The code is based on this post:

1 Like

Ciao Stefano,

you are totally right!

BR
Gerhard

Hi,

thank you for the response, this would work for me.
I will let you now!
Gerhard

Hi,
this was indeed helpful.
The Resolution went sharp!

Task Solved!

Thank you
Gerhard

1 Like

I’d like to start by expressing my gratitude for developing this utility. I’ve encountered a minor issue when working with transformers. Specifically, when I employ canvas.transform() , it doesn’t seem to set correctly. I suspect the dpi might not be updating post-transformation. While I’ve managed to find an alternative solution by avoiding the transformer, I thought it would be helpful to bring this to your attention.

Hi @chad63e, this would be better as a separate thread or better a post on anvil-extras GitHub discussion page. And include a clone to demonstrate the issue.