Skip to content

Commit

Permalink
lua: add math module
Browse files Browse the repository at this point in the history
lua: make all modules global by default
doc: update docs
  • Loading branch information
and3rson committed Feb 24, 2024
1 parent 36bd5fa commit e968ed3
Show file tree
Hide file tree
Showing 20 changed files with 869 additions and 157 deletions.
10 changes: 4 additions & 6 deletions docs/lua/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

Функції для роботи з введенням.

.. contents::
:local:
:depth: 1

Приклад:

.. code-block:: lua
:linenos:
local controller = require("controller")
local display = require("display")
display.set_cursor(32, 32)
while true do
Expand Down Expand Up @@ -56,9 +57,6 @@ controller.get_state()
.. code-block:: lua
:linenos:
local controller = require("controller")
local display = require("display")
display.set_cursor(0, 32)
while true do
Expand Down
25 changes: 7 additions & 18 deletions docs/lua/display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

Основні функції для роботи з дисплеєм.

.. contents::
:local:
:depth: 1

Приклад:

.. code-block:: lua
:linenos:
local display = require("display")
display.set_cursor(0, 0)
display.print("Hello,", "world!", 69, 420, "nice")
Expand Down Expand Up @@ -53,8 +55,6 @@ color565(r, g, b)
.. code-block:: lua
:linenos:
local display = require("display")
local color = display.color565(255, 0, 0)
display.draw_line(0, 0, 100, 100, color)
Expand Down Expand Up @@ -94,8 +94,6 @@ set_font(font)
.. code-block:: lua
:linenos:
local display = require("display")
display.set_font("6x13")
display.set_cursor(8, 32)
display.print("Привіт,")
Expand Down Expand Up @@ -183,8 +181,6 @@ draw_line(x1, y1, x2, y2, color)
.. code-block:: lua
:linenos:
local display = require("display")
local color = display.color565(255, 0, 0)
display.draw_line(0, 0, 100, 100, color)
Expand Down Expand Up @@ -283,20 +279,17 @@ draw_bitmap(id, x, y)
:type id: number
:param id: Ідентифікатор зображення, отриманий з :lua:func:`resources.load_bitmap`.
:type x: number
:param x: Координата x.
:param x: Координата x верхнього лівого кута зображення.
:type y: number
:param y: Координата y.
:param y: Координата y верхнього лівого кута зображення.

Приклад використання:

.. code-block:: lua
:linenos:
local display = require("display")
local resources = require("resources")
local face = resources.load_bitmap("face.bmp", display.color565(0, 0, 0))
display.draw_bitmap(face, 50, 80)
display.draw_bitmap(face, 50, 80) -- Виводить зображення на екран у точці (50, 80)
set_buffered(value)
^^^^^^^^^^^^^^^^^^^
Expand All @@ -319,8 +312,6 @@ set_buffered(value)
.. code-block:: lua
:linenos:
local display = require("display")
-- Вимикаємо буферизацію екрану:
display.set_buffered(false)
Expand All @@ -337,8 +328,6 @@ set_buffered(value)
.. code-block:: lua
:linenos:
local display = require("display")
while true do
-- Заповнюємо екран чорним кольором:
display.fill_screen(display.color565(0, 0, 0))
Expand Down
1 change: 1 addition & 0 deletions docs/lua/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Lua API
display
controller
resources
math
utils
Loading

0 comments on commit e968ed3

Please sign in to comment.