allow updating screen via web interface

This commit is contained in:
arne 2025-10-07 02:02:13 +02:00
commit 8986c51d4d
4 changed files with 54 additions and 26 deletions

View file

@ -88,10 +88,6 @@
z-index: -1;
}
dt code {
white-space: nowrap;
}
@media screen and (min-width: 800px) {
body {
padding: 72px;
@ -102,8 +98,39 @@
<body>
<h1>inkblot</h1>
<p>Welcome to your inkblot. You can use the text field below to enter and send Lua scripts that will change what is displayed on your screen. At the bottom of the screen you can get a short list of functions available for drawing.</p>
<form method="POST" id="blot" action="/draw">
<textarea></textarea>
<form method="POST" id="blot" action="/draw" enctype="multipart/form-data">
<textarea name="script">local math = require("math")
local paper = require("paper")
paper.init()
paper.set_rotation("portrait")
paper.clear()
local width = paper.get_width()
local height = paper.get_height()
print(
'width: ' .. width,
'height: ' .. height
)
paper.clear()
paper.fill_rect(0, 0, width, height, 0x22)
for i = 0, 4 do
local off = 40 * i
local color
if i % 2 == 0 then
color = 0x22
else
color = 0xDD
end
paper.fill_rect(off, off, width - off, height - off, color)
end
paper.update()</textarea>
<button type="submit">Draw</button>
</form>
<h2>How to draw</h2>
@ -141,12 +168,6 @@
<dt><code>paper.draw_line(x1, y1, x2, y2, color)</code></dt>
<dd>Draw a line from <code>(x1,y1)</code> to <code>(x2,y2)</code> in the given <code>color</code>.</dd>
<dt><code>paper.draw_hline(x, y, length, color)</code></dt>
<dd>Draw a horizontal line from <code>(x,y)</code> with the given <code>length</code> in the given <code>color</code>.</dd>
<dt><code>paper.draw_vline(x, y, length, color)</code></dt>
<dd>Draw a vertical line from <code>(x,y)</code> with the given <code>length</code> in the given <code>color</code>.</dd>
<dt><code>paper.draw_circle(x, y, radius, color)</code> / <code>paper.fill_circle(x, y, radius, color)</code></dt>
<dd>Draw an outline around a circle at <code>(x,y)</code> with the given <code>radius</code> in the given <code>color</code>. <code>fill_circle</code> draws the same circle with a solid filling.</dd>