Here it is. It's not perfect, because if scaled small gaps can appear in the seams. In a later implementation I used repeated textures instead to solve that problem, but it felt like a hack. May look at making a more robust version at some point.
@SinisterSoft released a window example a while ago which does 9-patches. I think I have one somewhere, I'll trawl through my junk folder and see if I can find it
@totebo, I managed to get round the gaps issue by using a RenderTarget and drawing the shapes into that first
function Gui:image9(m,ib,i,w,h,left,right,top,bottom,fh,fv)local tx,ty,tw,th=i:getRegion()local w3,h3=tw/3,th/3local l,r,t,b=left or w3,right or w3,top or h3,bottom or h3
local tx2,tx3=tx+l,tx+tw-r
local ty2,ty3=ty+t,ty+th-b
local tx4,ty4=tx+tw,ty+th
if fh then
tx,tx2,tx3,tx4=tx4,tx3,tx2,tx
l,r=r,l
endif vh then
ty,ty2,ty3,ty4=ty4,ty3,ty2,ty
t,b=b,t
endlocal x2,x3=l,w-r
local y2,y3=t,h-b
m:setVertexArray(0,0,x2,0,x2,y2,0,y2,
x2,0,x3,0,x3,y2,x2,y2,
x3,0,w,0,w,y2,x3,y2,
0,y2,x2,y2,x2,y3,0,y3,
x2,y2,x3,y2,x3,y3,x2,y3,
x3,y2,w,y2,w,y3,x3,y3,
0,y3,x2,y3,x2,h,0,h,
x2,y3,x3,y3,x3,h,x2,h,
x3,y3,w,y3,w,h,x3,h)
m:setIndexArray(1,2,3,1,3,4,
5,6,7,5,7,8,
9,10,11,9,11,12,
13,14,15,13,15,16,
17,18,19,17,19,20,
21,22,23,21,23,24,
25,26,27,25,27,28,
29,30,31,29,31,32,
33,34,35,33,35,36)
m:setTextureCoordinateArray(tx,ty,tx2,ty,tx2,ty2,tx,ty2,
tx2,ty,tx3,ty,tx3,ty2,tx2,ty2,
tx3,ty,tx4,ty,tx4,ty2,tx3,ty2,
tx,ty2,tx2,ty2,tx2,ty3,tx,ty3,
tx2,ty2,tx3,ty2,tx3,ty3,tx2,ty3,
tx3,ty2,tx4,ty2,tx4,ty3,tx3,ty3,
tx,ty3,tx2,ty3,tx2,ty4,tx,ty4,
tx2,ty3,tx3,ty3,tx3,ty4,tx2,ty4,
tx3,ty3,tx4,ty3,tx4,ty4,tx3,ty4)
m:setTexture(ib)return l,r,t,b
end
Comments
Likes: oleg
Likes: oleg
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
@totebo, I managed to get round the gaps issue by using a RenderTarget and drawing the shapes into that first
Likes: oleg, totebo
Falling Animals | Breaky Wall | Exetor | Mini Putt Golfing | Ninja Fruit Master | Descent | Descent Infinity | Peaky Climb | Buzzy Beez
http://SinisterSoft.com
http://facebook.com/WhatRhymesWithMartians
Likes: oleg, vitalitymobile, antix
http://SinisterSoft.com
http://facebook.com/WhatRhymesWithMartians
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
Likes: vitalitymobile, SinisterSoft, antix
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
http://SinisterSoft.com
http://facebook.com/WhatRhymesWithMartians
I want to dynamically change the size Sprite1:goSize(500,99)
at any moment in the game
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
http://SinisterSoft.com
http://facebook.com/WhatRhymesWithMartians
Likes: SinisterSoft
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
Yes
Likes: SinisterSoft
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
Likes: SinisterSoft, antix
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
Likes: SinisterSoft, vitalitymobile
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
Likes: totebo
http://SinisterSoft.com
http://facebook.com/WhatRhymesWithMartians
Likes: SinisterSoft
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
http://SinisterSoft.com
http://facebook.com/WhatRhymesWithMartians
Likes: SinisterSoft, antix
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
(Thanks, in case google mis-translated)
Likes: oleg
http://SinisterSoft.com
http://facebook.com/WhatRhymesWithMartians
Likes: vitalitymobile
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
"And does it work with @2, @3 etc?"
I did not check
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
Likes: totebo
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
so fast working:
stage:addChild(clon(a,200,30))
instead:
stage:addChild(wall(200,30,50,24))
Likes: antix
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
https://github.com/razorback456/gideros_tools/commit/9e65a621b86ed16d8ddb1a4af80a00e5f5fc3738
Likes: SinisterSoft, Apollo14
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні
my games: https://play.google.com/store/apps/dev?id=5762368610208429197
Слава Україні