Creating rotated rounded rectangles

  • Hi,

    I am looking for a way to create rounded rectangles that are rotated 45 degrees (so a 'rounded diamond' if you want).

    At the moment I don't see a simple way to achieve this.
    - I could compose it by for drawing 4 lines and, in theory, 4 splines .
    But with the constraint for splines that "Please note that the values for the x coordinates have to be in a increasing order.", the ones on the side will have to split in 2 parts as well I suppose.
    So that seems to become very complex very quick.
    - I could just load an image containing the shape I need (but then I don't have control over the size or color anymore).

    At the moment I am going to go for the second one, but is there maybe an option that I am missing ?
    The polygones have a rotate function but it does not seem to exist for (rounded) rectangles.
    I cant immediately find a way to draw on a rotated view or something.

    Sidenote: I am using stemwin, so I don't have access to the latest versions anymore I am afraid.

    Regards,
    Bram

  • Hello,

    Sidenote: I am using stemwin, so I don't have access to the latest versions anymore I am afraid.


    The latest versions are compiled by SEGGER. You can find it here: emWin: STM32 microcontrollers.

    If your rectangles are not constant, the first that comes to mind is using Memory Devices option. But you need a good enough high-performance MCU for fast rotating and enough memory space, depending on the size of your rectangles and how often do you need to rotate them. Just create a memory device, then draw a rectangle into it, then rotate the device using GUI_MEMDEV_Rotate...() functions. There you can choose rotation speed and quality. Then draw the device on the screen. Here you go.

    Regards,

    Anthony

  • Hi,

    until we add such a function to emWin, one way to do this would be by drawing anti-aliased lines and anti-aliased arcs.

    However, the results won't be 100% accurate, as a slight difference in line thickness between the lines and the arc may become visible. High-resolution coordinates would also have to be used, so that the positioning of the lines and arcs is accurate enough.

    If your hardware supports SVG, using the SVG module would render the most accurate result. However, as not many hardware targets offer a vector-based GPU, this is most likely not a viable option for you either.

    Using a memory device to rotate the rectangle as Anthony suggested is memory intensive, but it is the solution that will offer the best results.

    Best regards,
    Florian

    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: https://www.segger.com/ticket/

    Or you can contact us via e-mail.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!