This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local love = love | |
local lg = love.graphics | |
local random = love.math.random | |
local function dist(x1, y1, x2, y2) | |
return math.sqrt((x2 - x1)^2 + (y2 - y1)^2) | |
end | |
local function length(x, y) | |
return math.sqrt(x^2 + y^2) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function love.graphics.roundrect(mode, x, y, width, height, xround, yround) | |
local points = {} | |
local precision = (xround + yround) * .1 | |
local tI, hP = table.insert, .5*math.pi | |
if xround > width*.5 then xround = width*.5 end | |
if yround > height*.5 then yround = height*.5 end | |
local X1, Y1, X2, Y2 = x + xround, y + yround, x + width - xround, y + height - yround | |
local sin, cos = math.sin, math.cos | |
for i = 0, precision do | |
local a = (i/precision-1)*hP |