Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
RoundedRectangle class — Gideros Forum

RoundedRectangle class

totebototebo Member
edited September 2017 in Code snippets
You're welcome. :)
RoundedRectangle = Core.class( Path2D )
 
function RoundedRectangle:init( width,height,radius )
 
	local diameter = radius*2
	if width < height then
		if diameter > width then
			radius = width/2
		end
	else
		if diameter > height then
			radius = height/2
		end
	end
 
	width = width-(radius*2)
	height = height-(radius*2)
	local x = radius
	local svg_path = "M" .. x .. ",0 h" .. width .. " a" .. radius .. "," .. radius .. " 0 0 1 " .. radius .. "," .. radius .. " v" .. height .. " a" .. radius .. "," .. radius .. " 0 0 1 -" .. radius .. "," .. radius .. " h-" .. width .. " a" .. radius .. "," .. radius .. " 0 0 1 -" .. radius .. ",-" .. radius .. " v-" .. height .. " a" .. radius .. "," .. radius .. " 0 0 1 " .. radius .. ",-" .. radius .. " z"	
	self:setSvgPath(svg_path) 
 
end
My Gideros games: www.totebo.com
+1 -1 (+4 / -0 )Share on Facebook
Sign In or Register to comment.