return function(draw) function draw:rrect(m, x, y, w, h, r) local rtl, rtr, rbl, rbr = r[1] or 8, r[2], r[3], r[4] rtr = rtr or rtl rbl = rbl or rtl rbr = rbr or rbl local ml, mr, Ml, Mr, Mt, Mb = math.min(rtl, rbl), math.min(rtr, rbr), math.max(rtl, rbl), math.max(rtr, rbr), math.max(rtl, rtr), math.max(rbl, rbr) if m == FILL then self :rect(m, x + Ml, y + Mt, w - Ml - Mr, h - Mt - Mb) :rect(m, x + rtl, y, w - rtl - rtr, Mt) -- top :rect(m, x + rbl, y + h - Mb, w - rbl - rbr, Mb) -- bottom :rect(m, x, y + rtl, Ml, h - rtl - rbl) -- left :rect(m, x + w - Mr, y + rtr, Mr, h - rtr - rbr) -- right end self :line(x + rtl, y, x + w - rtr, y) :line(x, y + rtl, x, y + h - rbl) :line(x + rbl, y + h, x + w - rbr, y + h) :line(x + w, y + rtr, x + w, y + h - rbr) :arc(m, x + rtl, y + rtl, rtl, math.pi, math.pi * 1.5) :arc(m, x + w - rtr, y + rtr, rtr, math.pi * 1.5, math.pi * 2) :arc(m, x + w - rbr, y + h - rbr, rbr, 0, math.pi / 2) :arc(m, x + rbl, y + h - rbl, rbl, math.pi / 2, math.pi) return self end end