Stretchable button/background texture

I’m wondering if it’s possible to imitate iOS’s CenterRect texture stretching using existing Corona libraries? The basic idea is that you define a rect area in the center of the image that you can scale, without distorting the outside quadrants. If not are there any third party libraries that do something similar? I’ve tried using xScale/yScale on images and it just stretches the whole thing without preserving corners.

Would you be able to posts some end result screenshots of what you want to do exactly ?

Basically I have an image like this: 

(Figure 2.4 in the linked iOS documentation) 

3by3grid_2x.png

There is a property of a texture that allows you to slice an image into 9 quadrants. The center quadrant becomes known as the “center rect” with its own x, y, width, height property. (X,Y being where the center rect is positioned relative to the original image, w and h are the dimensions of the center rect.) Then when you apply an xScale or yScale to the image, it only stretches the portion you designated as the center rect so you can get different sized images like this: 

ss2-stretchedtexture_2x.png

If you want to use this method for UI buttons, you should look at the widget.newButton (9-Slice Construction). Its a little bit different than what Apple does in term of setting it up, but the end result would be the same.

Thanks nmichaud, I’ll look into that.

Would you be able to posts some end result screenshots of what you want to do exactly ?

Basically I have an image like this: 

(Figure 2.4 in the linked iOS documentation) 

3by3grid_2x.png

There is a property of a texture that allows you to slice an image into 9 quadrants. The center quadrant becomes known as the “center rect” with its own x, y, width, height property. (X,Y being where the center rect is positioned relative to the original image, w and h are the dimensions of the center rect.) Then when you apply an xScale or yScale to the image, it only stretches the portion you designated as the center rect so you can get different sized images like this: 

ss2-stretchedtexture_2x.png

If you want to use this method for UI buttons, you should look at the widget.newButton (9-Slice Construction). Its a little bit different than what Apple does in term of setting it up, but the end result would be the same.

Thanks nmichaud, I’ll look into that.