Search code examples
visual-c++activexteechart

How to rotate rectangle


I have created a rectangle on canvas. I wanted to know that how can we rotate the rectangle 30 degree.

m_ctrlChart.GetCanvas().Rectangle(10, 50, 60, 100); 

I am not able to find any API which will help me to rotate rectangle. Thanks


Solution

  • I'm afraid the functions to do this are internal. However, you could use a Rectangle tool that supports rotation. Ie:

      TChart1.Tools.Add tcRectangle
      TChart1.Tools.Items(0).asRectangle.Shape.Angle = 30
      With TChart1.Tools.Items(0).asRectangle
        .Shape.Transparency = 0
        .Shape.Color = vbRed
        .Left = 10
        .Top = 50
        .Width = 50
        .Height = 50
      End With
    

    Of course you can always calculate the coordinates yourself using trigonometric functions as @selva-kumar says.