Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.

Answered Obtaining the width of a Shape

  • Wednesday, October 28, 2009 8:38 PM
     
     
    Is there a way to find the width of a shape?  The ImageList class has the GetWidthOfImage, but there's no equivalent in the Shapes class.

    I've only been playing with SB for almost a week now, so forgive me if this is trivial.

    What I am attempting to do is to load an image into a Shape object, zoom it and then find the width of that Shape image.

    Maybe there's a better way to do what I'm attempting.  Is there a way to resize an ImageList image before stuffing it into a Shape object (has to be a Shape so I can move it).

    Thanks in advance for any help.

    The program I'm writting is: GTK593

    (BTW, is there a way to get a permanent publish ID?)
    • Changed Type aadams Thursday, October 29, 2009 4:12 AM It was really a question
    •  

All Replies

  • Wednesday, October 28, 2009 9:53 PM
    Moderator
     
     Answered
    I think the easiest way is to programatically keep track of the Zoom scaling - this would also be faster than constantly calling a GetWidth type function even if it existed for Shapes.

    For example the ball scaling is held in variable ballScale and the width/height can be calculated from this and the original image dimensions:

    ballImage = ImageList.LoadImage("http://icons.iconarchive.com/icons/fasticon/world-cup-2006/ball-icon.jpg")
    ballWidth = ImageList.GetWidthOfImage(ballImage)
    ballHeight = ImageList.GetHeightOfImage(ballImage)
    ball = Shapes.AddImage(ballImage)
    Shapes.Move(ball,(GraphicsWindow.Width-ballWidth)/2,(GraphicsWindow.Height-ballHeight)/2) 'Center the ball

    For ballScale = 0.1 To 10 Step 0.1
      Shapes.Zoom(ball,ballScale,ballScale)
      GraphicsWindow.Title = "Image width is "+ballScale*ballWidth
      Program.Delay(100)
    EndFor


    I think the publish IDs are pretty permanemt - sometimes the 'sample of the month' gets a special ID set by Vijaye such as 'ASTEROIDS'.

    BTW, this thread is really a question, and the 'getOpacity' is more of a discussion or observation rather than question - there is also a sticky thread for reporting Bugs (so they don't get overlooked).
    • Marked As Answer by aadams Thursday, October 29, 2009 4:12 AM
    •  
  • Thursday, October 29, 2009 4:13 AM
     
     
    Thanks again!  Don't know why I didn't think of that.... it's been a long day!

    Oh, and sorry about the miss-categorizing the question.  I've changed the type to a question, and will change the other to discussion.
  • Thursday, October 29, 2009 4:14 AM
     
     
    Oh, and as for the publish ID's.  What's happening for me is each time I publish it gives me a new ID.  So if I want to share it with others, I have to re-announce the ID.  I was hoping there was a way to have an ID stick so that my friends, kids, students, etc... would always have the latest and greatest.
  • Thursday, October 29, 2009 9:42 PM
     
     
    Not sure if this is the best way...

     Import the current ID. 
     Cut and paste your new code into that window, removing the old code.
     Click publish.

     QFL408 becomes QFL408-0

    Then you just have to give the revision number
  • Saturday, August 04, 2012 2:56 AM
     
     
    is there a way to delete the old version