2020-10-27 21:47:15 +01:00
|
|
|
--[[
|
|
|
|
This module makes use of cairo surfaces
|
|
|
|
For documentation take a look at the C docs:
|
|
|
|
https://www.cairographics.org/
|
|
|
|
They can be applied to lua by changing the naming conventions
|
|
|
|
and adjusting for the missing namespaces (and classes)
|
|
|
|
for example:
|
|
|
|
cairo_rectangle(cr, 1, 1, 1, 1) in C would be written as
|
|
|
|
cr:rectangle(1, 1, 1, 1) in lua
|
|
|
|
and
|
|
|
|
cairo_fill(cr) in C would be written as
|
|
|
|
cr:fill() in lua
|
|
|
|
--]]
|
|
|
|
|
|
|
|
local cairo = require("lgi").cairo
|
|
|
|
local gears = require("gears")
|
|
|
|
|
|
|
|
function create_tiled_wallpaper(str, s, args_table)
|
|
|
|
-- user input
|
|
|
|
args_table = args_table or {}
|
|
|
|
local fg = args_table.fg or "#ff0000"
|
|
|
|
local bg = args_table.bg or "#00ffff"
|
|
|
|
local offset_x = args_table.offset_x
|
|
|
|
local offset_y = args_table.offset_y
|
|
|
|
local font = args_table.font or "Hack"
|
|
|
|
local font_size = tonumber(args_table.font_size) or 16
|
|
|
|
local zickzack_bool = args_table.zickzack or false
|
|
|
|
local padding = args_table.padding or 100
|
2021-08-27 20:01:22 +02:00
|
|
|
|
2020-10-27 21:47:15 +01:00
|
|
|
-- create cairo image wallpaper
|
|
|
|
local img = cairo.ImageSurface(cairo.Format.RGB24, padding, padding)
|
|
|
|
cr = cairo.Context(img)
|
|
|
|
|
|
|
|
cr:set_source(gears.color(bg))
|
|
|
|
cr:paint()
|
|
|
|
|
|
|
|
cr:set_source(gears.color(fg))
|
|
|
|
|
|
|
|
cr:set_font_size(font_size)
|
|
|
|
cr:select_font_face(font)
|
|
|
|
|
2021-08-27 20:01:22 +02:00
|
|
|
if zickzack_bool then
|
2020-10-27 21:47:15 +01:00
|
|
|
cr:set_source(gears.color(fg))
|
2021-08-27 20:01:22 +02:00
|
|
|
cr:move_to(padding / 2 + font_size, padding / 2 + font_size)
|
2020-10-27 21:47:15 +01:00
|
|
|
cr:show_text(str)
|
2021-08-27 20:01:22 +02:00
|
|
|
end
|
|
|
|
|
2020-10-27 21:47:15 +01:00
|
|
|
cr:set_source(gears.color(fg))
|
|
|
|
cr:move_to(font_size, font_size)
|
|
|
|
cr:show_text(str)
|
2021-08-27 20:01:22 +02:00
|
|
|
|
2020-10-27 21:47:15 +01:00
|
|
|
-- tile cairo image
|
2021-08-27 20:01:22 +02:00
|
|
|
gears.wallpaper.tiled(img, s, { x = offset_x, y = offset_y })
|
|
|
|
end
|
2020-10-27 21:47:15 +01:00
|
|
|
|
|
|
|
return create_tiled_wallpaper
|