Is it possible to rotate an Ellipse object?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Is it possible to rotate an Ellipse object?

      I want to rotate a FillEllipse. I test it with an Image and rotate it with Memory Device in simulation it work's but on target I haven't enough memory.
      Is it possible to rotate a drawn ellipse object, as the folowing code shows?

      GUI_SetColor(0xff);
      GUI_FillEllipse(100, 180, 50, 70);
    • Hi,

      Unfortunately, this is not possible.


      EDIT: Actually it is..


      The only way I could image is to use memory devices. Sorry.

      Maybe you can define the ellipse as a polygon (of course, this would require some memors for the points) and then use the function GUI_RotatePolygon().

      Like this:

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Defines
      11. *
      12. **********************************************************************
      13. */
      14. #define X_RADIUS 50
      15. #define Y_RADIUS 70
      16. /*********************************************************************
      17. *
      18. * Static data
      19. *
      20. **********************************************************************
      21. */
      22. static GUI_POINT _aPoints[1000];
      23. static GUI_POINT _aPointsWork[1000];
      24. /*********************************************************************
      25. *
      26. * Static code
      27. *
      28. **********************************************************************
      29. */
      30. /*********************************************************************
      31. *
      32. * _cbBk
      33. */
      34. static void _cbBk(WM_MESSAGE * pMsg) {
      35. switch (pMsg->MsgId) {
      36. case WM_PAINT:
      37. GUI_SetBkColor(GUI_BLACK);
      38. GUI_Clear();
      39. break;
      40. default:
      41. WM_DefaultProc(pMsg);
      42. break;
      43. }
      44. }
      45. /*********************************************************************
      46. *
      47. * Public code
      48. *
      49. **********************************************************************
      50. */
      51. /*********************************************************************
      52. *
      53. * MainTask
      54. */
      55. void MainTask(void) {
      56. int x;
      57. int y;
      58. int NumPoints;
      59. GUI_Init();
      60. GUI_Clear();
      61. //
      62. // Create polygon
      63. //
      64. NumPoints = 0;
      65. GUI_DrawEllipse(X_RADIUS + 1, Y_RADIUS, X_RADIUS, Y_RADIUS);
      66. for (y = 0; y < Y_RADIUS + 1; y++) {
      67. for (x = X_RADIUS; x < X_RADIUS * 2 + 1; x++) {
      68. if (GUI_GetPixelIndex(x, y) == 0xFFFFFFFF) {
      69. _aPoints[NumPoints].x = x;
      70. _aPoints[NumPoints].y = y;
      71. NumPoints++;
      72. }
      73. }
      74. }
      75. for (y = Y_RADIUS; y < Y_RADIUS * 2 + 1; y++) {
      76. for (x = X_RADIUS * 2 + 1; x > X_RADIUS; x--) {
      77. if (GUI_GetPixelIndex(x, y) == 0xFFFFFFFF) {
      78. _aPoints[NumPoints].x = x;
      79. _aPoints[NumPoints].y = y;
      80. NumPoints++;
      81. }
      82. }
      83. }
      84. for (y = Y_RADIUS * 2 + 1; y > Y_RADIUS; y--) {
      85. for (x = X_RADIUS; x > 0; x--) {
      86. if (GUI_GetPixelIndex(x, y) == 0xFFFFFFFF) {
      87. _aPoints[NumPoints].x = x;
      88. _aPoints[NumPoints].y = y;
      89. NumPoints++;
      90. }
      91. }
      92. }
      93. for (y = Y_RADIUS; y > 0; y--) {
      94. for (x = 0; x < X_RADIUS; x++) {
      95. if (GUI_GetPixelIndex(x, y) == 0xFFFFFFFF) {
      96. _aPoints[NumPoints].x = x;
      97. _aPoints[NumPoints].y = y;
      98. NumPoints++;
      99. }
      100. }
      101. }
      102. GUI_Clear();
      103. GUI_RotatePolygon(_aPointsWork, _aPoints, NumPoints, 45.0f);
      104. GUI_DrawPolygon(_aPointsWork, NumPoints, 100, 100);
      105. while (1) {
      106. GUI_Delay(100);
      107. }
      108. }
      109. /*************************** End of file ****************************/
      Display All




      Regards,
      Sven
      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: segger.com/ticket/

      Or you can contact us via e-mail.