theme: Refactor xresource wallpaper to expose the vectorial logo

This commit is contained in:
Emmanuel Lepage Vallee 2016-12-11 00:05:02 -05:00
parent e01de8d977
commit 12e1bd6747
1 changed files with 119 additions and 89 deletions

View File

@ -46,23 +46,8 @@ function theme_assets.taglist_squares_unsel(size, fg)
return img return img
end end
local function make_letter(cr, n, lines, size, bg, fg, alt_fg)
function theme_assets.wallpaper(bg, fg, alt_fg, s) local letter_gap = size/6
s = s or screen.primary
local height = s.workarea.height
local width = s.workarea.width
local img = cairo.RecordingSurface(cairo.Content.COLOR,
cairo.Rectangle { x = 0, y = 0, width = width, height = height })
local cr = cairo.Context(img)
local letter_size = height/10
local letter_line = letter_size/18
local letter_gap = letter_size/6
local letter_start_x = width - width / 10
local letter_start_y = height / 10
local function make_letter(n, lines, color)
local function make_line(coords) local function make_line(coords)
for i, coord in ipairs(coords) do for i, coord in ipairs(coords) do
@ -76,79 +61,124 @@ function theme_assets.wallpaper(bg, fg, alt_fg, s)
end end
lines = lines or {} lines = lines or {}
color = color or fg color = alt_fg or fg
cr:set_source(gears.color(color)) cr:set_source(gears.color(color))
cr:rectangle( cr:rectangle(
letter_start_x, letter_start_y+(letter_size+letter_gap)*n, 0, (size+letter_gap)*n,
letter_size, letter_size size, size
) )
cr:fill() cr:fill()
if bg then
cr:set_source(gears.color(bg)) cr:set_source(gears.color(bg))
for _, line in ipairs(lines) do else
cr:move_to(letter_start_x, letter_start_y+(letter_size+letter_gap)*n) cr:set_operator(cairo.Operator.CLEAR)
make_line(line)
end
end end
-- bg for _, line in ipairs(lines) do
cr:set_source(gears.color(bg)) cr:move_to(0, (size+letter_gap)*n)
cr:paint() make_line(line)
end
cr:set_operator(cairo.Operator.OVER)
end
function theme_assets.gen_awesome_name(cr, width, height, bg, fg, alt_fg, vertical)
local ls = height/10 -- letter_size
local letter_line = ls/18
cr:set_line_width(letter_line) cr:set_line_width(letter_line)
local ls = letter_size
-- a -- a
make_letter(0, { { make_letter(cr, 0, { {
{ 0, ls/3 }, { 0, ls/3 },
{ ls*2/3, 0 }, { ls*2/3, 0 },
}, { }, {
{ ls/3, ls*2/3 }, { ls/3, ls*2/3 },
{ ls/3, 0 }, { ls/3, 0 },
{ 0, ls/3 }, { 0, ls/3 },
} }, alt_fg) } }, ls, bg, fg, alt_fg)
-- w -- w
make_letter(1, { { make_letter(cr, 1, { {
{ ls/3, 0 }, { ls/3, 0 },
{ 0,ls*2/3 }, { 0,ls*2/3 },
}, { }, {
{ ls*2/3, 0 }, { ls*2/3, 0 },
{ 0,ls*2/3 }, { 0,ls*2/3 },
} }) } }, ls, bg, fg)
-- e -- e
make_letter(2, { { make_letter(cr, 2, { {
{ ls/3, ls/3 }, { ls/3, ls/3 },
{ ls*2/3, 0 }, { ls*2/3, 0 },
}, { }, {
{ ls/3, ls*2/3 }, { ls/3, ls*2/3 },
{ ls*2/3, 0 }, { ls*2/3, 0 },
} }) } }, ls, bg, fg)
-- s -- s
make_letter(3, { { make_letter(cr, 3, { {
{ ls/3, ls/3 }, { ls/3, ls/3 },
{ ls*2/3, 0 }, { ls*2/3, 0 },
}, { }, {
{ 0, ls*2/3 }, { 0, ls*2/3 },
{ ls*2/3, 0 }, { ls*2/3, 0 },
} }) } }, ls, bg, fg)
-- o -- o
make_letter(4, { { make_letter(cr, 4, { {
{ ls/2, ls/3 }, { ls/2, ls/3 },
{ 0, ls/3 }, { 0, ls/3 },
} }) } }, ls, bg, fg)
-- m -- m
make_letter(5, { { make_letter(cr, 5, { {
{ ls/3, ls/3 }, { ls/3, ls/3 },
{ 0,ls*2/3 }, { 0,ls*2/3 },
}, { }, {
{ ls*2/3, ls/3 }, { ls*2/3, ls/3 },
{ 0,ls*2/3 }, { 0,ls*2/3 },
} }) } }, ls, bg, fg)
-- e -- e
make_letter(6, { { make_letter(cr, 6, { {
{ ls/3, ls/3 }, { ls/3, ls/3 },
{ ls*2/3, 0 }, { ls*2/3, 0 },
}, { }, {
{ ls/3, ls*2/3 }, { ls/3, ls*2/3 },
{ ls*2/3, 0 }, { ls*2/3, 0 },
} }) } }, ls, bg, fg)
end
function theme_assets.gen_logo(cr, width, height, bg, fg)
local ls = math.min(width, height)
local letter_line = ls/18
cr:set_line_width(letter_line)
make_letter(cr, 0, { {
{ 0, ls/3 },
{ ls*2/3, 0 },
}, {
{ ls/3, ls*2/3 },
{ ls/3, 0 },
{ 0, ls/3 },
} }, ls, bg, fg)
end
function theme_assets.wallpaper(bg, fg, alt_fg, s)
s = s or screen.primary
local height = s.workarea.height
local width = s.workarea.width
local img = cairo.RecordingSurface(cairo.Content.COLOR,
cairo.Rectangle { x = 0, y = 0, width = width, height = height })
local cr = cairo.Context(img)
local letter_start_x = width - width / 10
local letter_start_y = height / 10
cr:translate(letter_start_x, letter_start_y)
-- background
cr:set_source(gears.color(bg))
cr:paint()
theme_assets.gen_awesome_name(cr, width, height, bg, fg, alt_fg, true)
return img return img
end end