none
Shapes.Zoom(scaleX) after setting Shape/Control Size RRS feed

  • Question

  • Is there a problem with Zooming about the X-axis after Setting Shape/Control size?

    After setting size it doesn't seem to Zoom about the centre of X-axis.

    PVF410-2


    Tuesday, September 1, 2015 10:08 AM
    Moderator

Answers

  • So, this is a bug?

    Thanks!


    Ed Price, Azure & Power BI Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    I don't think so, it is how it works - it could be done some other way, but if it was changed then many old programs wouldn't work, and it seems reasonable to zoom about center, while keeping the position defined as the unzoomed position.

    Usually when I move a shape I move its center by ofsetting by half width and half height.  If the height and width or postion were changed when a shape is zoomed this would make it much harder to control.

    Shapes.Move(sprite,x-width/2,y-height/2)

    where x,y is the center (zoomed or unzoomed), the position isthe top left of the unzoomed shape, so we can use the unzoomed position and width and height to center the shape easily on a coordinate x,y regardless of how it is zoomed (or rotated).

    EDIT

    If we were starting from scratch we might define a shape position at its center?

    Finally we can also use Controls.SetSize in place of Shapes.Zoom for a different effect.

      'Shapes.Zoom(rectangle, scale, scale)
      Controls.SetSize(rectangle, scale*GraphicsWindow.Width, scale*GraphicsWindow.Height)
    

    Saturday, September 5, 2015 10:03 AM
    Moderator

All replies

  • (translated by Google translator)

    Why do you say "... Zoom about the centre of X-axis."?

    I see that the program is working well.

    Tuesday, September 1, 2015 5:40 PM
  • Good question.

    Type in Shapes.Zoom and read the information that comes up on the rhs of the ide.

    It's how the Zoom member of Shapes works.

    Shapes.Zoom(shapeName, scaleX, scaleY).

    Here's a sample of what it's handy at doing: JRP437.

    Tuesday, September 1, 2015 11:20 PM
    Moderator
  • (translated by Google translator)

    I looked at the documentation of instruction "Shapes.Zoom". I did not see there the words "Zoom about the centre". In my documentation these words do not exist.

    So thank you for the information.

    Wednesday, September 2, 2015 5:44 AM
  • Here's some code that shows a rectangle of GraphicsWindow size being placed at 0,0.

    Then zoomed down as small as it can be.

    Notice at the end, the rectangle hasn't moved. It's still at 0,0.

    http://smallbasic.com/program/?BVN282

    Wednesday, September 2, 2015 6:35 AM
    Moderator
  • (translated by Google translator)

    A fine example. Many thanks.

    Wednesday, September 2, 2015 4:10 PM
  • So, this is a bug?

    Thanks!


    Ed Price, Azure & Power BI Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    Saturday, September 5, 2015 8:46 AM
    Owner
  • So, this is a bug?

    Thanks!


    Ed Price, Azure & Power BI Customer Program Manager (Blog, Small Basic, Wiki Ninjas, Wiki)

    Answer an interesting question? Create a wiki article about it!

    I don't think so, it is how it works - it could be done some other way, but if it was changed then many old programs wouldn't work, and it seems reasonable to zoom about center, while keeping the position defined as the unzoomed position.

    Usually when I move a shape I move its center by ofsetting by half width and half height.  If the height and width or postion were changed when a shape is zoomed this would make it much harder to control.

    Shapes.Move(sprite,x-width/2,y-height/2)

    where x,y is the center (zoomed or unzoomed), the position isthe top left of the unzoomed shape, so we can use the unzoomed position and width and height to center the shape easily on a coordinate x,y regardless of how it is zoomed (or rotated).

    EDIT

    If we were starting from scratch we might define a shape position at its center?

    Finally we can also use Controls.SetSize in place of Shapes.Zoom for a different effect.

      'Shapes.Zoom(rectangle, scale, scale)
      Controls.SetSize(rectangle, scale*GraphicsWindow.Width, scale*GraphicsWindow.Height)
    

    Saturday, September 5, 2015 10:03 AM
    Moderator