Pop.Box/extensions/streamlined_get_set.moon

38 lines
915 B
Plaintext
Raw Normal View History

2017-04-30 21:13:56 +00:00
--- @todo doc me (and add me to config.ld)
-- Adds methods to elements using a single function for get and set operations.
-- ex: instead of getWidth() and setWidth(value), width() and width(value)
import graphics from love
import sub, len from string
path = sub ..., 1, len(...) - len "/extensions/streamlined_get_set"
element = require "#{path}/elements/element"
box = require "#{path}/elements/box"
text = require "#{path}/elements/text"
element.__base.position = (x, y) =>
if x or y
return @setPosition x, y
else
return @getPosition!
element.__base.size = (w, h) =>
if w or h
return @setSize w, h
else
return @getSize!
element.__base.width = (w) =>
if w
return @setWidth w
else
return @getWidth!
2017-04-30 21:14:26 +00:00
element.__base.height = (h) =>
2017-04-30 21:13:56 +00:00
if h
return @setHeight h
else
return @getHeight!
--- @todo continue copying from old version... (and add new things or whatever)