From 439620b2309c064f030ccc65947ea6ba9c10f795 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 20 Jan 2023 17:23:57 +0100 Subject: examples/pygments: init --- examples/pygments.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/pygments.lua (limited to 'examples') 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 @@ +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 = {}, +}) -- cgit v1.2.3