summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/pygments.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/pygments.lua b/examples/pygments.lua
new file mode 100644
index 0000000..453f53f
--- /dev/null
+++ b/examples/pygments.lua
@@ -0,0 +1,32 @@
1package.cpath = package.cpath .. ";../target/debug/?.so"
2package.path = package.path .. ";../lua-bindings/?.lua"
3
4local dia = require("diaphragm")
5
6dia.draw({
7 draw = function(self)
8 local p = io.popen("pygmentize -f pango -O style=nord ./pygments.lua")
9 local content = p:read("a")
10
11 if content == nil then
12 return
13 end
14
15 local font = dia.text.font({ family = "Fira Code" })
16 local text = dia.text.new({
17 content = string.sub(content, 5, -6),
18 font = font,
19 width = 1920,
20 })
21
22 dia.rectangle
23 .surrounding(text, {
24 -- fill_color = "#282828"
25 fill_color = "#1e1e27",
26 })
27 :draw()
28 text:draw()
29 dia.constraint.inset(text, self)
30 end,
31 output = {},
32})