DevLabs > DevLabs Forums > Small Basic > Ellipse is moving and I do not know why
Ask a questionAsk a question
 

General DiscussionEllipse is moving and I do not know why

  • Wednesday, November 04, 2009 12:36 PMgemione Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hello Community,

    The code below is not a big thing, I know, but the result is not what one expected.
    groesse = 5

    For i = 2 To 6
         GraphicsWindow.FillEllipse(100,150,groesse,groesse)
         groesse = groesse * i
            
      EndFor 

    This circle is moving instead just growing and I do not know why.

    Small Basic Version 0.7

    maybe a bug or is x and y not the center of the ellipse?

    Thanks for help

     

     

All Replies

  • Wednesday, November 04, 2009 12:56 PMJason Jacques Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    You are correct in saying that x and y are not the centre of the shape. It represents the top left corner of the bounding box for the shape (before any rotation, if applicable, is applied).

    The following code demonstrates how to centre a shape as well as demonstrating the difference:

    size = 100
    x = GraphicsWindow.Width / 2 ' Centre of window
    y = GraphicsWindow.Height / 2
    ' Offset
    GraphicsWindow.FillEllipse(x, y, size, size)
    ' Centred
    GraphicsWindow.FillEllipse(x - (size/2), y - (size/2), size, size) 

    Best,

    Jason.
  • Wednesday, November 04, 2009 2:53 PMgemione Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks Jason for your quick reply.