diff --git a/lib/misc.lua b/lib/misc.lua new file mode 100644 index 0000000..198bf14 --- /dev/null +++ b/lib/misc.lua @@ -0,0 +1,9 @@ +function parseHexColor(text) + local r = tonumber('0x' .. string.sub(text, -8, -7)) + local g = tonumber('0x' .. string.sub(text, -6, -5)) + local b = tonumber('0x' .. string.sub(text, -4, -3)) + local a = tonumber('0x' .. string.sub(text, -2)) + + return r, g, b, a +end + diff --git a/samples/calc.lua b/samples/calc.lua new file mode 100644 index 0000000..3034a6c --- /dev/null +++ b/samples/calc.lua @@ -0,0 +1,29 @@ + +function on_alarm() + ui:show_text("Введите выражение") +end + +function on_click() + ui:show_edit_dialog("Введите выражение") +end + +function on_dialog_action(text) + if text == "" then + on_alarm() + else + ui:show_text(calculate_string(text)) + end +end + +function sqrt(x) + return math.sqrt(x) +end + +function pow(x, y) + return math.pow(x,y) +end + +function calculate_string(str) + return load("return "..str) +end +