Jump to content

Funcion: dxDrawProgressBar


Otto

Recommended Posts

Que tal, he creado mi primera función a base de algunos de mis conocimientos, aquí la comparto con la comunidad:

local unlerp = function(from,to,lerp) return (lerp-from)/(to-from) end 
  
function dxDrawProgressBar( startX, startY, width, height, progress, color, backColor ) 
        local progress = math.max( 0, (math.min( 100, progress) ) ) 
        local wBar = width*.18 
        for i = 0, 4 do 
                --back 
                local startPos = (wBar*i + (width*.025)*i) + startX 
                dxDrawRectangle( startPos, startY, wBar, height, backColor ) 
                --progress 
                local eInterval = (i*20) 
                local localProgress = math.min( 1, unlerp( eInterval, eInterval + 20, progress ) ) 
                        if localProgress > 0 then 
                                dxDrawRectangle( startPos, startY, wBar*localProgress, height, color ) 
                        end 
        end 
end 

Link de la función en la wiki

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...