summaryrefslogtreecommitdiffstats
path: root/examples/pygments.lua
blob: 453f53f05c3d6eb0744612b470ceb2b50d32b6bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package.cpath = package.cpath .. ";../target/debug/?.so"
package.path = package.path .. ";../lua-bindings/?.lua"

local dia = require("diaphragm")

dia.draw({
	draw = function(self)
		local p = io.popen("pygmentize -f pango -O style=nord ./pygments.lua")
		local content = p:read("a")

		if content == nil then
			return
		end

		local font = dia.text.font({ family = "Fira Code" })
		local text = dia.text.new({
			content = string.sub(content, 5, -6),
			font = font,
			width = 1920,
		})

		dia.rectangle
			.surrounding(text, {
				-- fill_color = "#282828"
				fill_color = "#1e1e27",
			})
			:draw()
		text:draw()
		dia.constraint.inset(text, self)
	end,
	output = {},
})