lcd.drawLine¶
since 1.1.0
Draw a line.
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
x1 |
number | yes | X coordinate of the start point |
y1 |
number | yes | Y coordinate of the start point |
x2 |
number | yes | X coordinate of the end point |
y2 |
number | yes | Y coordinate of the end point |
Returns¶
Nothing.
Examples¶
-- a simple graph of the last N samples
local function drawGraph(samples, n, x, y, w, h, min, max)
local step = w / (n - 1)
local prevX, prevY
for i = 1, n do
local v = samples[i] or min
local px = x + (i - 1) * step
local py = y + h - (v - min) / (max - min) * h
if prevX then lcd.drawLine(prevX, prevY, px, py) end
prevX, prevY = px, py
end
end
Use lcd.pen(PEN_DOTTED) before drawing for dotted lines (grid lines, thresholds).
Used in¶
Real-world usage¶
Called 133 times across 9 open-source Ethos Lua projects. A few short excerpts: