Sakingod Posted October 2, 2018 Posted October 2, 2018 Hello, there's a way to transform this: to this -> ? first image code -> function dxDrawRoundedBorder(x, y, w, h, borderColor, postGUI) if (x) and (y) and (w) and (h) then borderColor = borderColor or tocolor(255, 255, 255, 230) dxDrawRectangle(x - 1, y + 1, 1, h - 2, borderColor, postGUI) -- left dxDrawRectangle(x + w, y + 1, 1, h - 2, borderColor, postGUI)-- right dxDrawRectangle(x + 1, y - 1, w - 2, 1, borderColor, postGUI) -- top dxDrawRectangle(x + 1, y + h, w - 2, 1, borderColor, postGUI) -- bottom dxDrawRectangle(x, y, 1, 1, borderColor, postGUI) dxDrawRectangle(x + w - 1, y, 1, 1, borderColor, postGUI) dxDrawRectangle(x, y + h - 1, 1, 1, borderColor, postGUI) dxDrawRectangle(x + w - 1, y + h - 1, 1, 1, borderColor, postGUI) end end
' A F . Posted October 2, 2018 Posted October 2, 2018 the useful function from wiki function dxDrawRoundedRectangle(x, y, rx, ry, color, radius) rx = rx - radius * 2 ry = ry - radius * 2 x = x + radius y = y + radius if (rx >= 0) and (ry >= 0) then dxDrawRectangle(x, y, rx, ry, color) dxDrawRectangle(x, y - radius, rx, radius, color) dxDrawRectangle(x, y + ry, rx, radius, color) dxDrawRectangle(x - radius, y, radius, ry, color) dxDrawRectangle(x + rx, y, radius, ry, color) dxDrawCircle(x, y, radius, 180, 270, color, color, 7) dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7) dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7) dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7) end end example function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function dxDrawRoundedRectangle(x, y, rx, ry, color, radius) rx = rx - radius * 2 ry = ry - radius * 2 x = x + radius y = y + radius if (rx >= 0) and (ry >= 0) then dxDrawRectangle(x, y, rx, ry, color) dxDrawRectangle(x, y - radius, rx, radius, color) dxDrawRectangle(x, y + ry, rx, radius, color) dxDrawRectangle(x - radius, y, radius, ry, color) dxDrawRectangle(x + rx, y, radius, ry, color) dxDrawCircle(x, y, radius, 180, 270, color, color, 7) dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7) dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7) dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7) end end -- # example addEventHandler ( "onClientRender" , root , function ( ) local hover = isMouseInPosition ( 300 , 300 , 170 , 30 ) ; dxDrawRoundedRectangle(300,300,170,30, hover and tocolor(200,200,200,200) or tocolor(0,0,0,200), 10) dxDrawText("Button",300,300,470,330,hover and tocolor(0,0,0,200) or tocolor(255,255,255,200),1,'default-bold','center','center') end ) good luck Dis ; AF.#0941
iMr.WiFi..! Posted October 2, 2018 Posted October 2, 2018 7 hours ago, Default#^ said: the useful function from wiki function dxDrawRoundedRectangle(x, y, rx, ry, color, radius) rx = rx - radius * 2 ry = ry - radius * 2 x = x + radius y = y + radius if (rx >= 0) and (ry >= 0) then dxDrawRectangle(x, y, rx, ry, color) dxDrawRectangle(x, y - radius, rx, radius, color) dxDrawRectangle(x, y + ry, rx, radius, color) dxDrawRectangle(x - radius, y, radius, ry, color) dxDrawRectangle(x + rx, y, radius, ry, color) dxDrawCircle(x, y, radius, 180, 270, color, color, 7) dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7) dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7) dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7) end end example function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end function dxDrawRoundedRectangle(x, y, rx, ry, color, radius) rx = rx - radius * 2 ry = ry - radius * 2 x = x + radius y = y + radius if (rx >= 0) and (ry >= 0) then dxDrawRectangle(x, y, rx, ry, color) dxDrawRectangle(x, y - radius, rx, radius, color) dxDrawRectangle(x, y + ry, rx, radius, color) dxDrawRectangle(x - radius, y, radius, ry, color) dxDrawRectangle(x + rx, y, radius, ry, color) dxDrawCircle(x, y, radius, 180, 270, color, color, 7) dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7) dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7) dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7) end end -- # example addEventHandler ( "onClientRender" , root , function ( ) local hover = isMouseInPosition ( 300 , 300 , 170 , 30 ) ; dxDrawRoundedRectangle(300,300,170,30, hover and tocolor(200,200,200,200) or tocolor(0,0,0,200), 10) dxDrawText("Button",300,300,470,330,hover and tocolor(0,0,0,200) or tocolor(255,255,255,200),1,'default-bold','center','center') end ) good luck Where "dxDrawCircle" 's function? Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة ليس عليك اسعاد الجميع , ولكن عليك بإن لا تؤذي أحداً =========You do not have to make everyone happy, But you should not hurt anyone Want to contact with me? Discord: JustCarry#2616 (Always there)Skype: Live:JustCarry10 (Not always)
Rockyz Posted October 2, 2018 Posted October 2, 2018 55 minutes ago, iMr.WiFi..! said: Where "dxDrawCircle" 's function? well, its an default mta function https://wiki.multitheftauto.com/wiki/DxDrawCircle
iMr.WiFi..! Posted October 2, 2018 Posted October 2, 2018 12 minutes ago, #,xiRocKyz said: well, its an default mta function https://wiki.multitheftauto.com/wiki/DxDrawCircle Wow, I didn't know about it. Thanks < 3 Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة ليس عليك اسعاد الجميع , ولكن عليك بإن لا تؤذي أحداً =========You do not have to make everyone happy, But you should not hurt anyone Want to contact with me? Discord: JustCarry#2616 (Always there)Skype: Live:JustCarry10 (Not always)
sanyisasha Posted October 3, 2018 Posted October 3, 2018 On 02/10/2018 at 13:47, #,xiRocKyz said: well, its an default mta function https://wiki.multitheftauto.com/wiki/DxDrawCircle Interesting. When i last used this it was usefull. It's in my "old" (2018 jun's) core I have to test it's performance better than the usefull one, or it's the same just implemented.
Master_MTA Posted October 4, 2018 Posted October 4, 2018 On 02/10/2018 at 05:05, Default#^ said: luck it's not work good with postgui =true the color of corner doesn't appear so u can use function dxDrawRoundedRectangle(x,y,width,height,raduis,color,postgui) dxDrawRectangle(x,y+raduis,width+1,height-(raduis*2),color,postgui)--horezantal rectangle dxDrawRectangle(x+raduis,y,width-(raduis*2),height+1,color,postgui)--vertical rectangle for k=180,270 do--left top local co=math.cos(math.rad(k))* raduis local si=math.sin(math.rad(k))* raduis dxDrawLine((x+raduis)+co,(y+raduis)+si,x+raduis,y+raduis,color,1,postgui) end for k=270,360 do--right top local co=math.cos(math.rad(k))* raduis local si=math.sin(math.rad(k))* raduis dxDrawLine((x+width-raduis)+co,(y+raduis)+si,x+width-raduis,y+raduis,color,1,postgui) end for k=90,180 do--left bottom local co=math.cos(math.rad(k))* raduis local si=math.sin(math.rad(k))* raduis dxDrawLine((x+raduis)+co,(y+height-raduis)+si,x+raduis,y+height-raduis,color,1,postgui) end local k=360 while(k<=(360+90))do if k~= 360 then local co=math.cos(math.rad(k))* raduis local si=math.sin(math.rad(k))* raduis dxDrawLine((x-raduis+width)+co,(y+height-raduis)+si,x+width-raduis,y+height-raduis,color,1,postgui) end k=k+1; end end Skype : 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001 every thing is gonna be alright every thing is gonna be okay it's gonna be a good good life that's what my therapist say
Moderators Pirulax Posted October 9, 2018 Moderators Posted October 9, 2018 On 04/10/2018 at 00:47, sanyisasha said: Interesting. When i last used this it was usefull. It's in my "old" (2018 jun's) core I have to test it's performance better than the usefull one, or it's the same just implemented. The circle shader is by far the fastest one(nearly 5x times faster than the in-built dxDrawCricle one, since it depends on CPU rather than GPU, which, as you know, isn't used too often in MTA, so, take use of it.)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now