Hello Guest

Author Topic: Convert desired runtime width to scale  (Read 3601 times)

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Convert desired runtime width to scale
« on: January 28, 2013, 08:35:10 am »
I have a header graphic with rounded corners on either side and text in the middle.  The graphic also has a background behind the text.  The size of the text is dynamic.  So thats 4 sprites (left, center, right, text).  I already have code running that sets up the positioning of all of these and I know exactly how long I need the middle background graphic to be.  That graphic is a tiling graphic, so I need to scale it on the x to fit the width of the text.  Is there a way to do this, a way to convert the known and desired width of the graphic and have it scale?

You can see what Im trying to do here
http://i.imgur.com/9Yi9MM2.png

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Convert desired runtime width to scale
« Reply #1 on: January 28, 2013, 10:00:40 am »
If it is a tiling graphic, surely you'll need to duplicate + clip the last one to get it to fit, rather than scaling?


If you wanna scale, you can work it out by
xscale = xdistance / bounds.width;

Intrawebs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Convert desired runtime width to scale
« Reply #2 on: January 28, 2013, 04:28:33 pm »
DOH!  Of course I can duplicate it, dont know why I didn't think of that.  I'll also try the other suggestion.  Thanks.