Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
|
|
@ -0,0 +1,33 @@
|
|||
local canvas = require "canvas"
|
||||
|
||||
local function trunc(x) return x >= 0 ? math.floor(x) : math.ceil(x) end
|
||||
|
||||
local function circle(c, cx, cy, r, col)
|
||||
local d = trunc((5 - r * 4) / 4)
|
||||
local x = 0
|
||||
local y = r
|
||||
repeat
|
||||
c:set(cx + x, cy + y, col)
|
||||
c:set(cx + x, cy - y, col)
|
||||
c:set(cx - x, cy + y, col)
|
||||
c:set(cx - x, cy - y, col)
|
||||
c:set(cx + y, cy + x, col)
|
||||
c:set(cx + y, cy - x, col)
|
||||
c:set(cx - y, cy + x, col)
|
||||
c:set(cx - y, cy - x, col)
|
||||
if d < 0 then
|
||||
d += 2 * x + 1
|
||||
else
|
||||
d += 2 * (x - y) + 1
|
||||
y -= 1
|
||||
end
|
||||
++x
|
||||
until x > y
|
||||
end
|
||||
|
||||
local c = canvas.new(400, 400)
|
||||
c:fill(0xffffff) -- white background
|
||||
|
||||
-- Draw a blue circle with centre at (200, 200) and radius 100.
|
||||
circle(c, 200, 200, 100, 0xff0000)
|
||||
io.contents("mybmp.bmp", c:tobmp()) -- save to a bitmap file
|
||||
Loading…
Add table
Add a link
Reference in a new issue