Jump to content

Rounded rectangle (dynamic button)


mehmet

Recommended Posts

Posted

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) 


 

Posted (edited)
13 minutes ago, stPatrick said:

Better.

I make the menu. If rendering 100-200 rectangle is a lot? (1 button = 9 Rectangle)

Edited by mehmet
Posted
1 hour ago, stPatrick said:

Yes, there are many, but there is no better solution.
Only the images.

can CEF be better?

  • Moderators
Posted

You might also be able to use CEF to create button textures. (Haven't done it before, but it looks to me that it is very well possible)

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
4 hours ago, IIYAMA said:

You might also be able to use CEF to create button textures. (Haven't done it before, but it looks to me that it is very well possible)

 

Thank you, but I decided to use an image.?

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