Drawing coordinates calculation algorithm based on the size / resolution of the screen

Hello,

In our application, we receive instructions to draw several forms (lines, points, circles, polygons, ...) to display directions icons.

The biggest problem is that I have to indicate the coordinates for the drawing of the shapes but there are several resolutions of screens for watches. So I can’t put static coordinates.

Is there a smart algorithm or method to calculate the exact coordinates to draw shapes based on the screen format / size / resolution?

Thanks in advance

  • I would (and do) use dc.getWidth()/dc.getHeight()/dc.getFontHeight() to figure out the screen location for things, and the width/height of things like drawing a graph..

    It's easy to do at runtime. No exact algorithm, as too much depends on what you are drawing and how you want it to look.  If you want something like a different size bitmap for different resolution screens, that can be done with resource overrides, like resources-round-240x240 and resources-round-454x454

  • as Jim said, you can (and I guess lots of do) use dc.getWidth() in a var, let's say gW, and after use a relative position,

    for exemple if you want to draw a vertical line in the middle, you can use for x = gW*0.5 etc.