Jump to content

Rounded rectangle (dynamic button)


mehmet

Recommended Posts

Hello, I want to create a button with rounded corners. Pictures will not work. I need to create a dynamic button. How to do it right? and well optimized.

They say this is a bad way for server performance. + visible pixels (
 

local x,y = guiGetScreenSize() 
local sx,sy = 400,200 
local size = 45 -- pixel size to cut 
  
function performRendering() 
  for i=1,sy do 
    local dg = math.min(i,size) -- limit it to the size 
    if i > sy-size then 
      dg = sy-math.max(sy-size,i) -- limit it to the size for bottom parts 
    end 
    local csx = sx-1/dg*size -- use our lovely y = k/x function 
    dxDrawRectangle(x/2-csx/2,y/2-sy/2+i,csx,1,tocolor(0,0,0,200)) -- draw the magic at the middle 
  end 
end 
addEventHandler("onClientRender",getRootElement(),performRendering) 


 

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...