Cannot get transparency on clock background. [SOLVED]
Posted: Thu May 30, 2024 6:10 pm
Hello everyone
Here is what I am dealing with:
Image on the left is a clock displayed with .lua. Image on the right is biohazzard sign displayed with .lua
As you can see, the clock has an obvious visible outline of the boarder and I cannot get rid of it without breaking the clock.
When I set transparency with the Edit Widget I get this:
Here is the conky code for the biohazzard image:
Here is biohazzard .lua:
By comparison, here is the clock conkyrc:
and the clock .lua:
I have tried overwriting the window settings of the clock conkyrc with the biohazzard.conkyrc but while this makes the background go away, it also destroys and washes out the image.
Can anyone please help me get rid of this background outline?
Thank you for reading,
Logan
Here is what I am dealing with:
Image on the left is a clock displayed with .lua. Image on the right is biohazzard sign displayed with .lua
As you can see, the clock has an obvious visible outline of the boarder and I cannot get rid of it without breaking the clock.
When I set transparency with the Edit Widget I get this:
Here is the conky code for the biohazzard image:
Code: Select all
--[[
Bleys 2024
]]
conky.config = {
-- — Conky settings
background = false,
total_run_times = 0,
no_buffers = true,
-- — Window specifications with Background
own_window = true,
own_window_type = dock,
own_window_hints = 'skip_taskbar,skip_pager,undecorated,above',
own_window_transparent = false,
own_window_argb_visual = true,
own_window_argb_value = 0,
own_window_colour = '000000',
double_buffer = true,
minimum_width = 300, minimum_height = 263,
alignment = 'middle_middle',
gap_x = 20,
gap_y = 20,
-- Lua Load
lua_load = '/home/logansfury/.conky/Biohazzard/pic.lua',
lua_draw_hook_post = 'main',
};
conky.text = [[
]];
Code: Select all
--[[
2024 Bleys
]]
require 'cairo'
require "imlib2"
home_path = os.getenv ('HOME')
function fDrawImage(cr,path,xx,yy,ww,hh,arc)
cairo_save (cr)
local img = cairo_image_surface_create_from_png(path)
local w_img, h_img = cairo_image_surface_get_width(img), cairo_image_surface_get_height(img)
cairo_translate (cr, xx, yy)
if arc then
cairo_rotate (cr, arc)
end
cairo_scale (cr, ww/w_img, hh/h_img)
cairo_set_source_surface (cr, img, -w_img/2, -h_img/2)
cairo_paint (cr)
cairo_surface_destroy (img)
collectgarbage ()
cairo_restore (cr)
end
function conky_main()
if conky_window==nil then return end
local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)
local cr=cairo_create(cs)
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num>4 then
fDrawImage(cr,'/home/logansfury/Pictures/bio_sm.png',150,132,300,263)
end
cairo_surface_destroy(cs)
cairo_destroy(cr)
end
Code: Select all
conky.config = {
background = false,
alignment = 'middle_middle',
gap_x = 290,
gap_y = 20,
minimum_width = 200,
minimum_height = 200,
maximum_width = 200,
-- update_run_times = '0',
draw_borders = false,
border_width = 0,
draw_shades = false,
draw_graph_borders = false,
draw_outline = false,
draw_shades = false,
double_buffer = true,
no_buffers = true,
uppercase = false,
use_spacer = 'none',
own_window = true,
own_window_type = 'desktop',
own_window_class = 'Conky',
own_window_hints = 'skip_taskbar,skip_pager,undecorated,above',
own_window_transparent = true,
own_window_argb_visual = false,
own_window_argb_value = 0,
own_window_colour = '000000',
override_utf8_locale = true,
use_xft = true,
--xftfont Ani Regular:size=12
xftalpha = 0,
default_color = '#FFFFFF',
color1 = '#FFFFFF',
imlib_cache_flush_interval = 100,
imlib_cache_size = 2048,
text_buffer_size = 1024,
lua_load = 'grey.lua',
lua_draw_hook_post = 'imlib_clock eigen 200 100 100',
update_interval = 1,
};
conky.text = [[
#
# Set day of the month in clock (old day color was #BBBBBB)
${voffset 104}${goto 136}${color ea8e5a}${Font lcdmono2:bold:size=10}${exec date '+%a' | sed 's/^0//g'}
${voffset 96}${goto 128}${image ~/.conky/myclock/images/eigen/back.png -s 46x24 -p 120,98}
]];
Code: Select all
--[[
Simple clock, written using imlib. Edited by Etles_Team (2016)
Make sure you've installed "imlib2" application in your system if this script doesn't work :)
To use this script in Conky, Add this command in conkyrc file before (TEXT), Example :
lua_load ~/.conky/Conky-Name/imlib_clock.lua
lua_draw_hook_pre imlib_clock theme
OR you can add this other command to load script in conkyrc after (TEXT), Example :
${lua imlib_clock theme-name 120 100 100}
]]
---------------------------------------------------------------------------------------------------------
require ('imlib2')
image_path = os.getenv ('HOME')..'/.conky/myclock/images/'
function fFreeImage (image)
imlib_context_set_image(image)
imlib_free_image ()
end
function fRotateImage (image, arc)
imlib_context_set_image(image)
return imlib_create_rotated_image(arc)
end
function fGetImageSize(image)
imlib_context_set_image(image)
return imlib_image_get_width(), imlib_image_get_height()
end
function create_clock(theme, arc_s, arc_m, arc_h)
local imgFace = imlib_load_image(image_path..theme..'/grey_face.png')
local w_img, h_img = fGetImageSize(imgFace)
local imgH = imlib_load_image(image_path..theme..'/oh.png')
local imgHR = fRotateImage (imgH, arc_h)
local w_imgH, h_imgH = fGetImageSize(imgHR)
local imgM = imlib_load_image(image_path..theme..'/om.png')
local imgMR = fRotateImage (imgM, arc_m)
local w_imgM, h_imgM = fGetImageSize(imgMR)
local imgS = imlib_load_image(image_path..theme..'/os.png')
local imgSR = fRotateImage (imgS, arc_s)
local w_imgS, h_imgS = fGetImageSize(imgSR)
--local imgGlass = imlib_load_image(image_path..theme..'/glass.png')
local buffer = imlib_create_image(w_img, h_img)
imlib_context_set_image(buffer)
imlib_image_set_has_alpha(1)
imlib_image_clear()
imlib_blend_image_onto_image(imgFace, 1, 0, 0, w_img, h_img, 0, 0, w_img, h_img )
imlib_blend_image_onto_image(imgHR, 1, 0, 0, w_imgH, h_imgH, w_img/2-w_imgH/2, h_img/2-h_imgH/2, w_imgH, h_imgH )
imlib_blend_image_onto_image(imgMR, 1, 0, 0, w_imgM, h_imgM, w_img/2-w_imgM/2, h_img/2-h_imgM/2, w_imgM, h_imgM )
imlib_blend_image_onto_image(imgSR, 1, 0, 0, w_imgS, h_imgS, w_img/2-w_imgS/2-1, h_img/2-h_imgS/2-1, w_imgS, h_imgS )
--imlib_blend_image_onto_image(imgGlass, 1, 0, 0, w_img, h_img, 0, 0, w_img, h_img )
fFreeImage (imgFace)
fFreeImage (imgH)
fFreeImage (imgHR)
fFreeImage (imgM)
fFreeImage (imgMR)
fFreeImage (imgS)
fFreeImage (imgSR)
-- fFreeImage (imgGlass)
return buffer
end
function conky_imlib_clock(theme,w,x,y)
if conky_window==nil then return ' ' end
local w = w or 265
local x = x or conky_window.width / 2
local y = y or conky_window.height / 2
local arc_s = (2 * math.pi / 60) * os.date("%S")
local arc_m = (2 * math.pi / 60) * os.date("%M") + arc_s / 60
local arc_h = (2 * math.pi / 12) * os.date("%I") + arc_m / 12
local buffer = create_clock(theme, arc_s, arc_m, arc_h)
imlib_context_set_image(buffer)
imlib_render_image_on_drawable_at_size(
x-w/2, y-w/2, w, w)
fFreeImage (buffer)
return ' '
end
--=================================== Regards, Etles_Team =====================================--
Can anyone please help me get rid of this background outline?
Thank you for reading,
Logan