Hello
Guest
Home
Help
Search
Login
Register
2D Toolkit Forum
»
2D Toolkit
»
Support
»
Convert desired runtime width to scale
« previous
next »
Print
Pages: [
1
]
Author
Topic: Convert desired runtime width to scale (Read 4522 times)
Intrawebs
2D Toolkit
Newbie
Posts: 16
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
Logged
unikronsoftware
Administrator
Hero Member
Posts: 9709
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;
Logged
Intrawebs
2D Toolkit
Newbie
Posts: 16
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.
Logged
Print
Pages: [
1
]
« previous
next »
2D Toolkit Forum
»
2D Toolkit
»
Support
»
Convert desired runtime width to scale