Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
@SpineyPete
SpineyPete / rounded_rect_ngon.lua
Created April 22, 2021 09:12
Generates a rounded rectangle n-gon, renderable with a triangle fan.
function roundrectpoly(x, y, w, h, r, n)
-- required args
assert(x ~= nil and type(x) == "number")
assert(y ~= nil and type(y) == "number")
assert(w ~= nil and type(w) == "number")
assert(h ~= nil and type(h) == "number")
-- optional args
assert(r == nil or type(r) == "number")