mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
most docs done, more get/set shenanigans
This commit is contained in:
parent
8745eab159
commit
3645cb03d7
@ -0,0 +1,17 @@
|
||||
# box
|
||||
|
||||
The box element is a rectangle that has a [supported Drawable][1] as its
|
||||
background.
|
||||
|
||||
## Methods
|
||||
|
||||
- `setBackground(background)` Using a supported Drawable (see above), set the
|
||||
background.
|
||||
- `getBackground()` Returns the background in use.
|
||||
- `setColor(red, green, blue, alpha)` Sets the background to the specified
|
||||
color. `alpha` is optional and defaults to `255`. Alternately, pass a table of
|
||||
color values (ex: `{red, green, blue, alpha}`).
|
||||
- `getColor()` Returns red, green, blue, and alpha color values of background.
|
||||
Errors if the background is not a color.
|
||||
|
||||
[1]: ../Drawables.md
|
@ -0,0 +1,22 @@
|
||||
# text
|
||||
|
||||
The text element is plain text in one color. Nothing special.
|
||||
|
||||
(**Note**: Other, more advanced text elements are planned, with support for
|
||||
things like line-wrapping and custom coloring and formatting of text.)
|
||||
|
||||
## Methods
|
||||
|
||||
- `setSize()` Unlike other elements, a size cannot be set. If this is called, it
|
||||
will fix the size of the text if it somehow was modified incorrectly.
|
||||
- `setWidth()` Width cannot be set. If called, will fix the size of the text.
|
||||
- `setHeight()` Height cannot be set. If called, will fix the size of the text.
|
||||
- `setText(text)` Sets the text of the element. Will resize element to fit text.
|
||||
Newlines are supported. Defaults to an empty string.
|
||||
- `getText()` Returns the text of the element.
|
||||
- `setFont()` Sets the font to be used on this element. Will resize to fit the
|
||||
text and font.
|
||||
- `setColor(red, green, blue, alpha)` Sets color of text. `alpha` is optional
|
||||
and defaults to `255`. Alternately, pass a table of color values (ex: `{red,
|
||||
green, blue, alpha}`).
|
||||
- `getColor()` Returns red, green, blue, and alpha values of color.
|
@ -0,0 +1,4 @@
|
||||
# window
|
||||
|
||||
Documentation has not been written yet, as this element is still under heavy
|
||||
development.
|
@ -6,6 +6,7 @@ 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) =>
|
||||
@ -56,10 +57,30 @@ element.__base.margin = (m) =>
|
||||
-- print ...
|
||||
-- }
|
||||
|
||||
element.__base.resize = element.__base.adjustSize
|
||||
|
||||
-- box.__base.background -- can't be done!
|
||||
|
||||
box.__base.color = (r, g, b, a) =>
|
||||
if r or g or b or a
|
||||
return @setColor r, g, b, a
|
||||
else
|
||||
return @getColor!
|
||||
|
||||
text.__base.text = (text) =>
|
||||
if text
|
||||
return @setText text
|
||||
else
|
||||
return @getText!
|
||||
|
||||
-- size probably needs redefine here, elemental size won't fall through...or will it?
|
||||
text.__base.font = (font) =>
|
||||
if font
|
||||
return @setFont font
|
||||
else
|
||||
return @getFont!
|
||||
|
||||
text.__base.color = (r, g, b, a) =>
|
||||
if r or g or b or a
|
||||
return @setColor r, g, b, a
|
||||
else
|
||||
return @getColor!
|
||||
|
Loading…
Reference in New Issue
Block a user