Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,27 @@
|
|||
local canvas = require "canvas"
|
||||
|
||||
local function line(c, x0, y0, x1, y1, col)
|
||||
local dx = math.abs(x1 - x0)
|
||||
local dy = math.abs(y1 - y0)
|
||||
local sx = (x0 < x1) ? 1 : -1
|
||||
local sy = (y0 < y1) ? 1 : -1
|
||||
local err = (dx > dy ? dx : - dy) // 2
|
||||
while true do
|
||||
c:set(x0, y0, col)
|
||||
if x0 == x1 and y0 == y1 then break end
|
||||
local e2 = err
|
||||
if e2 > -dx then
|
||||
err -= dy
|
||||
x0 += sx
|
||||
end
|
||||
if e2 < dy then
|
||||
err += dx
|
||||
y0 += sy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local c = canvas.new(400, 400)
|
||||
c:fill(0xffffff) -- white background
|
||||
line(c, 0, 0, 399, 399, 0x0000ff) -- draw a red diagonal
|
||||
io.contents("mybmp.bmp", c:tobmp()) -- save to a bitmap file
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
require "bitmap"
|
||||
|
||||
local bmp = bitmap.of(400, 400, color.white, "mybmp")
|
||||
bmp:line(0, 0, 399, 399, color.red)
|
||||
bmp:view()
|
||||
bmp:save() -- if required
|
||||
Loading…
Add table
Add a link
Reference in a new issue