-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRoundedRect.lua
More file actions
35 lines (30 loc) · 829 Bytes
/
RoundedRect.lua
File metadata and controls
35 lines (30 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local mexico = require "mexico"
--
-- Mexico wrapper for a corona rounded rectangle.
--
local RoundedRect = mexico.class(mexico.DisplayObject)
--
-- Magic new function, since corona creates the object
-- and not we.
--
RoundedRect.new = function(styles)
local l = styles.left or 0
local t = styles.top or 0
local w = styles.width or display.contentWidth
local h = styles.height or display.contentHeight
local r = styles.cornerRadius or h / 2
return display.newRoundedRect(l, t, w, h, r)
end
--
-- Constructor
--
function RoundedRect:init(styles)
local styles = table.mexico.clone(styles)
styles["left"] = nil
styles["top"] = nil
styles["width"] = nil
styles["height"] = nil
styles["cornerRadius"] = nil
mexico.DisplayObject.init(self, styles)
end
return RoundedRect