Primitives
A window, and one frame's worth of drawing. Every call goes to the target
bound by natiny.window.bind; natiny.render.set_color holds until the next one
changes it.
Filled shapes on the top row, the same ones outlined below.
local natiny = require("natiny")
natiny.backend.init()
local win = natiny.window.create("Primitives", 900, 600)
natiny.window.set_scale_mode(win, natiny.window.SCALE_MODE_STRETCH)
local BG = natiny.color.from_hex("#151E2C")
local OBJECT = natiny.color.from_hex("#A9B3C5")
local ACCENT = natiny.color.from_hex("#F8F9FD")
local function color(c)
natiny.render.set_color(c)
end
natiny.backend.loop(function(dt)
natiny.window.bind(win, function()
natiny.render.clear(BG)
-- filled, on the top row
color(ACCENT)
natiny.render.rectangle(50, 80, 180, 120)
color(OBJECT)
natiny.render.circle(350, 140, 65)
color(ACCENT)
natiny.render.triangle(500, 205, 590, 75, 680, 205)
color(OBJECT)
natiny.render.poly(800, 140, 6, 60, 0)
-- the same shapes, outlined, on the bottom row
color(ACCENT)
natiny.render.rectangle_outline(50, 340, 180, 120, 3)
color(OBJECT)
natiny.render.circle_outline(350, 400, 65, 3)
color(ACCENT)
natiny.render.triangle_outline(500, 465, 590, 335, 680, 465, 3)
color(OBJECT)
natiny.render.poly_outline(800, 400, 6, 60, 0, 3)
-- a line is its own primitive: two points and a width
color(OBJECT)
natiny.render.line(50, 270, 850, 270, 2)
end)
end)
natiny.backend.shutdown()