--draws a texture which is a composite of a and b at x,y, split at p (where p is a 0-1 percentage of some value you wish to represent)
--h if true assumes the bar splits horizontally, or vertically if false, r can be true or false, if true it inverts p (-p + 1)
--a and b are texture handles, this seems to work best with 32 bit textures and images with at least a 1 pixel transparent border
--a is the "empty" texture and b is the "full" texture.
drawbar = function(a,b,x,y,p,h,r)
if p > 1 then p = 1 end
if p < 0 then p = 0 end
local iw = a:getWidth()
local ih = a:getHeight()
local y2 = y+ih
local x2 = x+iw
if r then p = -p + 1 end
if h then --horizontal bar
local xc = x+(p*iw)
gr.drawImage(a,x,y,xc,y2,0,0,p,1)
gr.drawImage(b,xc,y,xc+iw,y2,p,0,1,1)
else --vertical bar
local yc = y+(p*ih)
gr.drawImage(a,x,y,x2,yc,0,0,1,p)
gr.drawImage(b,x,yc,x2,yc+ih,0,p,1,1)
end
end
this is useful if you want to draw gauges like the retail energy/afterburner gauges.