RoundedRectangle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "{{Useful Function}} <lowercasetitle></lowercasetitle> __NOTOC__ This function is make a rounded rectangle. ==Syntax== <syntaxhighlight lang="lua">bool roundedRectangle ( floa...")
 
No edit summary
Line 52: Line 52:
</section>
</section>


Written by: ExTasY (HUN)
Written by: ExTasY[https://wiki.multitheftauto.com/wiki/User:Extasy]

Revision as of 20:38, 2 February 2019

This function is make a rounded rectangle.

Syntax

bool roundedRectangle ( float startX, float startY, float width, float height [, int tocolor ( int red, int green, int blue [, int alpha = 255 ] ) , bool postGUI = false ] )

Exmaple

Click to collapse [-]
Client side
local sx, sy = guiGetScreenSize()
roundedRectangle(sx/2, sy/2, 100, 100, tocolor(0,0,0,200))

function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
	if (x and y and w and h) then
		if (not borderColor) then
			borderColor = tocolor(0, 0, 0, 200);
		end
		if (not bgColor) then
			bgColor = borderColor;
		end
		dxDrawRectangle(x, y, w, h, bgColor, postGUI);
		dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI);
		dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI);
		dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI);
		dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI);
	end
end

Code

Click to collapse [-]
Both side
function roundedRectangle(x, y, w, h, borderColor, bgColor, postGUI)
	if (x and y and w and h) then
		if (not borderColor) then
			borderColor = tocolor(0, 0, 0, 200);
		end
		if (not bgColor) then
			bgColor = borderColor;
		end
		dxDrawRectangle(x, y, w, h, bgColor, postGUI);
		dxDrawRectangle(x + 2, y - 1, w - 4, 1, borderColor, postGUI);
		dxDrawRectangle(x + 2, y + h, w - 4, 1, borderColor, postGUI);
		dxDrawRectangle(x - 1, y + 2, 1, h - 4, borderColor, postGUI);
		dxDrawRectangle(x + w, y + 2, 1, h - 4, borderColor, postGUI);
	end
end

Written by: ExTasY[1]