add(wallpaper) pizza 🍕

This commit is contained in:
Aire-One 2021-09-29 01:48:44 +02:00
parent 3d7c85c3aa
commit a0a8250d14
3 changed files with 41 additions and 40 deletions

View File

@ -44,7 +44,7 @@ local load_wallpaper = slot {
action = slot.actions.CREATE | slot.actions.CONNECT,
target = capi.screen,
signal = 'request::wallpaper',
slot = slot.slots.screen.wallpaper
slot = my_slots.wallpaper
}
-- luacheck: ignore unused variable default_layout

View File

@ -8,6 +8,45 @@ local naughty = require 'naughty'
local slots = {}
function slots.wallpaper(screen)
local awallpaper = require 'awful.wallpaper'
local beautiful = require 'beautiful'
local gcolor = require 'gears.color'
local gsurface = require 'gears.surface'
local imagebox = require 'wibox.widget.imagebox'
local cairo = require('lgi').cairo
local screen_geo = screen.geometry
local source = cairo.ImageSurface(cairo.Format.RGB32, screen_geo.width, screen_geo.height)
local cr = cairo.Context(source)
-- Load base image
local image_surface = gsurface.load_uncached(beautiful.wallpaper)
local w, h = gsurface.get_size(image_surface)
cr:scale(screen_geo.width / w, screen_geo.height / h)
cr:set_source_surface(image_surface, 0, 0)
cr:paint()
-- Add color layer
local color_pattern = gcolor.create_linear_pattern {
from = { 0, 0 },
to = { screen.width, screen.height },
stops = {
{ 0, '#26323840' }
}
}
cr:set_source(color_pattern)
cr:paint()
awallpaper {
screen = screen,
widget = {
image = source,
widget = imagebox,
}
}
end
function slots.create_tags (screen)
local atag = require 'awful.tag'
local home_layout = require 'MyTagLayout.home_layout'

View File

@ -55,44 +55,6 @@ theme.bg_systray = '#455A64'
theme.systray_icon_spacing = 3
--- Wallpaper
theme.wallpaper = function (screen)
local cairo = require('lgi').cairo
local surface = require 'gears.surface'
local wallpaper = require 'gears.wallpaper'
local wallpaper_image_path = assets_dir .. 'wallpapers/pizza.jpg'
local geom, cr = wallpaper.prepare_context(screen)
-- local surf = cairo.ImageSurface.create(cairo.Format.RGB24, 200, 200)
local surf = surface.load_uncached(wallpaper_image_path)
local w, h = surface.get_size(surf)
local aspect_w = geom.width / w
local aspect_h = geom.height / h
-- scall the surface to the screen dimenssion ignoring aspect ratio
cr:scale(aspect_w, aspect_h)
cr:set_source_surface(surf, 0, 0)
cr:paint()
-- Add colored layer
local cm = cairo.LinearPattern(0, 0, w, h)
cm:add_color_stop_rgba(0, 38/256, 50/256, 56/256, 0.2)
cr:set_source(cm)
cr:paint()
-- Add vignette effect
local linpat = cairo.LinearPattern(0, 0, w, h)
linpat:add_color_stop_rgba(0, 0, 0, 0, 1)
local radpat = cairo.RadialPattern(
w / 2, h / 2, h * 0.5,
w / 2, h / 2, w * 0.5)
for i=0,1,0.1 do
radpat:add_color_stop_rgba(i, 0, 0, 0, i/2)
end
cr:set_source(linpat)
cr:mask(radpat)
surf:finish()
end
theme.wallpaper = assets_dir .. 'wallpapers/pizza.jpg'
return theme