Une pendule système :
ConkySystemClock:
# pkill -xf "conky -c /media/5/Conky/S11_Rem_Cal.conky" &
# conky -c /media/5/Conky/S11_Rem_Cal.conky &
# To use #! in a conky use: ${exec echo '#!'}
# Reminder fix compliments: Reid Thompson
### Begin Window Settings ##################################################
# Create own window instead of using desktop (required in nautilus)
own_window yes
#own_window_type normal
#own_window_transparent yes
#own_window_hints undecorated,below,skip_taskbar,skip_pager,sticky
own_window_title systemclock
own_window_class Conky
own_window_colour grey50
### ARGB can be used for real transparency
#own_window_argb_visual yes
#own_window_argb_value 0
# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
double_buffer yes
############
minimum_size 350 400
maximum_width 350 ##largeur
############
gap_x 15 # left-right
gap_y 35 # up-down
alignment mr
################################################### End Window Settings ###
### Font Settings #########################################################
# Use Xft (anti-aliased font and stuff)
use_xft yes
#xftfont Monofur:bold:size=11
xftfont mono:bold:size=8
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
###################################################### End Font Settings ###
### Color Settings #########################################################
draw_shades yes #no # amplifies text if yes
default_shade_color 000000
draw_outline no # amplifies text if yes
default_outline_color 000000
#default_color DCDCDC #220 220 220 Gainsboro
#default_color C0C0C0 #192 192 192 Silver
default_color B0E0E6 #176 224 230 PowderBlue
color0 8FBC8F #143 188 143 DarkSeaGreen
color1 778899 #119 136 153 LightSlateGray
color2 D8BFD8 #216 191 216 Thistle
color3 9ACD32 #154 205 50 YellowGreen
color4 FFA07A #255 160 122 LightSalmon
color5 FFDEAD #255 222 173 NavajoWhite
color6 00BFFF # 0 191 255 DeepSkyBlue
color7 5F9EA0 # 95 158 160 CadetBlue
color8 BDB76B #189 183 107 DarkKhaki
color9 CD5C5C #205 92 92 IndianRed #FF0000 #255 0 0 Red
##################################################### End Color Settings ###
### Borders Section ########################################################
draw_borders no
# Stippled borders?
stippled_borders 0
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 0
# graph borders
draw_graph_borders no #yes
#default_graph_size 15 40
##################################################### End Borders Secton ###
### Miscellaneous Section ##################################################
# Boolean value, if true, Conky will be forked to background when started.
background yes
# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none
# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 1024
# Subtract (file system) buffers from used memory?
no_buffers yes
# change GiB to G and MiB to M
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
# Maximum size of user text buffer, i.e. layout below TEXT line in config file
# (default is 16384 bytes)
# max_user_text 16384
# Desired output unit of all objects displaying a temperature. Parameters are
# either "fahrenheit" or "celsius". The default unit is degree Celsius.
# temperature_unit Fahrenheit
update_interval 1
############################################## End Miscellaneous Section ###
### LUA Settings ###########################################################
## Above and After TEXT - After - requires a composite manager or blinks.
##############################################################################
#lua scripts
lua_load ~/.conky/system_clock.lua
lua_draw_hook_pre main
TEXT
system_clock.lua:
--this lua script for use in conky
require 'cairo'
function conky_main(center_x,center_y)
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
--#################################################################
--#################################################################
--#################################################################
-- hours on the clock 12 or 24
hours=12
--the second interval displayed 5, 10, or 15
seconds=5
second_hand_size=1
minute_hand_size=5
hour_hand_size=5
-- Colors
d_font_red=.8
d_font_green=.8
d_font_blue=.8
d_font_alpha=1
--#################################################################
--#################################################################
--#################################################################
d_math=math.pi/180
max_width=175
if center_x == nil then center_x=max_width+5 end
if center_y == nil then center_y=max_width+5 end
hour_radius=141
second_radius=120
--#################################################################
--########## time calculation #####################################
--#################################################################
date_mm_dd_yy=conky_parse("${time %D}")
second=tonumber(conky_parse("${time %S}"))
minute=tonumber(conky_parse("${time %M}"))
if hours ~= 12 then hours=24 end
if hours == 12 then
hour=tonumber(conky_parse("${time %I}"))
time_hms=conky_parse("${time %r}")
i_start=1
i_end=12
else
hour=tonumber(conky_parse("${time %H}"))
time_hms=conky_parse("${time %T}")
i_start=0
i_end=hours-1
end
second_position=(-90+(360/60)*second)*d_math
minute_position=(-90+(360/60)*minute)*d_math
hour_position=(-90+(360/hours)*hour)*d_math+(((360/hours/60)*minute)*d_math)
--#################################################################
--########## string values ########################################
--#################################################################
cpu_avg=tonumber(conky_parse("${cpu cpu0}"))
if cpu_avg == nil then cpu_avg=0 end
cpu_core1=tonumber(conky_parse("${cpu cpu1}"))
if cpu_core1 == nil then cpu_core1=0 end
cpu_core2=tonumber(conky_parse("${cpu cpu2}"))
if cpu_core2 == nil then cpu_core2=0 end
ram=tonumber(conky_parse("${memperc}"))
if ram == nil then ram=0 end
mem=conky_parse("${mem}")
mem_size=conky_parse("${memmax}")
swap_perc=tonumber(conky_parse("${swapperc}"))
if swap_perc == nil then swap_perc=0 end
swap=conky_parse("${swap}")
swap_size=conky_parse("${swapmax}")
--#################################################################
--########## Info Panel ###########################################
--#################################################################
cairo_set_line_width(cr,2)
cairo_arc(cr,55,360,30,(90*d_math),(270*d_math))
cairo_arc(cr,295,360,30,(270*d_math),(90*d_math))
cairo_close_path(cr)
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_fill(cr)
cairo_set_line_width(cr,2)
cairo_arc(cr,55,360,28,(90*d_math),(270*d_math))
cairo_arc(cr,295,360,28,(270*d_math),(90*d_math))
cairo_close_path(cr)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_fill(cr)
x={52,52,52,
161,153,153,
225,225,225,225
}
y={348,363,378,
355,370,383,
343,355,370,382
}
t={"Cpu Avg: "..cpu_avg.."%","Cpu Core 1: "..cpu_core1.."%","Cpu Core 2: "..cpu_core2.."%",
"Time: ",time_hms,date_mm_dd_yy,
"Ram:",""..mem.." / "..mem_size.."","Swap:",""..swap.." / "..swap_size..""
}
for i = 1,#t do
cairo_set_source_rgba(cr,.8,.8,.8,1)
cairo_move_to(cr,x[i],y[i])
cairo_show_text(cr,t[i])
end
cairo_stroke(cr)
--#################################################################
--#################################################################
--#################################################################
--minute hand bottom
cairo_set_line_width(cr,6)
cairo_arc(cr,center_x,center_y,170,(minute_position-((minute_hand_size/2)*d_math)),(minute_position+((minute_hand_size/2)*d_math)))
cairo_arc(cr,center_x,center_y,10,(minute_position+(40*d_math)),(minute_position-(40*d_math)))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_close_path(cr)
cairo_fill(cr)
--hour hand bottom
cairo_arc(cr,center_x,center_y,160,(hour_position-((hour_hand_size/2)*d_math)),(hour_position+((hour_hand_size/2)*d_math)))
cairo_arc(cr,center_x,center_y,10,(hour_position+(40*d_math)),(hour_position-(40*d_math)))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_close_path(cr)
cairo_fill(cr)
--hands center
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,center_y,10,0,(360*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_fill(cr)
--main background
cairo_arc(cr,center_x,center_y,150,0,(360*d_math))
cairo_set_source_rgba(cr,.5,.5,.5,.25)
cairo_fill(cr)
--clock background
cairo_arc(cr,center_x,center_y,150,0,(360*d_math))
cairo_arc_negative(cr,center_x,center_y,110,(360*d_math),0)
cairo_close_path(cr)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_fill(cr)
cairo_arc(cr,center_x,center_y,150,0,(360*d_math))
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_stroke(cr)
cairo_arc(cr,center_x,center_y,130,0,(360*d_math))
cairo_set_source_rgba(cr,.25,.25,.25,1)
cairo_stroke(cr)
cairo_arc(cr,center_x,center_y,110,0,(360*d_math))
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_stroke(cr)
--#################################################################
--########## System Info ##########################################
--#################################################################
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
--cpu avg
cairo_set_line_width(cr,10)
cairo_arc(cr,center_x,center_y,102,(135*d_math),(45*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,8)
cairo_arc(cr,center_x,center_y,102,(135*d_math),((135*d_math)+(((270/100)*cpu_avg)*d_math)))
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_stroke(cr)
--cpu core 1
cairo_set_line_width(cr,10)
cairo_arc(cr,center_x,center_y,89,(135*d_math),(45*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,8)
cairo_arc(cr,center_x,center_y,89,(135*d_math),((135*d_math)+(((270/100)*cpu_core1)*d_math)))
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_stroke(cr)
--cpu core 2
cairo_set_line_width(cr,10)
cairo_arc(cr,center_x,center_y,76,(135*d_math),(45*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,8)
cairo_arc(cr,center_x,center_y,76,(135*d_math),((135*d_math)+(((270/100)*cpu_core2)*d_math)))
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_stroke(cr)
--ram
cairo_set_line_width(cr,10)
cairo_arc(cr,center_x,center_y,62,(100*d_math),(260*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,8)
cairo_arc(cr,center_x,center_y,62,(100*d_math),((100*d_math)+(((160/100)*ram)*d_math)))
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_stroke(cr)
--swap
cairo_set_line_width(cr,10)
cairo_arc(cr,center_x,center_y,62,(-80*d_math),(80*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,8)
cairo_arc_negative(cr,center_x,center_y,62,(80*d_math),((80*d_math)-(((160/100)*swap_perc)*d_math)))
cairo_set_source_rgba(cr,.2,.2,1,.75)
cairo_stroke(cr)
--#################################################################
--########## Text Backgrounds #####################################
--#################################################################
--cpu_avg
cairo_set_line_width(cr,14)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,102,(50*d_math),(130*d_math))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_set_line_width(cr,12)
cairo_arc(cr,center_x,center_y,102,(50*d_math),(130*d_math))
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_stroke(cr)
--cpu_core1
cairo_set_line_width(cr,14)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,89,(50*d_math),(130*d_math))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_set_line_width(cr,12)
cairo_arc(cr,center_x,center_y,89,(50*d_math),(130*d_math))
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_stroke(cr)
--cpu_core2
cairo_set_line_width(cr,14)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,76,(50*d_math),(130*d_math))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_set_line_width(cr,12)
cairo_arc(cr,center_x,center_y,76,(50*d_math),(130*d_math))
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_stroke(cr)
--ram
cairo_set_line_width(cr,14)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,47,(157*d_math),(202*d_math))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_set_line_width(cr,12)
cairo_arc(cr,center_x,center_y,47,(157*d_math),(202*d_math))
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_stroke(cr)
--swap
cairo_set_line_width(cr,14)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_arc(cr,center_x,center_y,47,(-30*d_math),(30*d_math))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_set_line_width(cr,12)
cairo_arc(cr,center_x,center_y,47,(-30*d_math),(30*d_math))
cairo_set_source_rgba(cr,.1,.1,.1,1)
cairo_stroke(cr)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_BUTT)
--#################################################################
--######### Text ##################################################
--#################################################################
cairo_set_source_rgba(cr,.8,.8,.8,1)
t={"C","P","U"," ","A","V","E","R","A","G","E"}
for i=1,#t do
x,y=pt((center_x-3),(center_y+4),102,((223-(79/#t)*i)))
cairo_move_to (cr,x,y)
cairo_show_text (cr,t[i])
end--for
cairo_stroke(cr)
t={"C","P","U"," ","C","O","R","E"," ","1"}
for i=1,#t do
x,y=pt((center_x-3),(center_y+4),89,((223-(79/#t)*i)))
cairo_move_to (cr,x,y)
cairo_show_text (cr,t[i])
end--for
cairo_stroke(cr)
t={"C","P","U"," ","C","O","R","E"," ","2"}
for i=1,#t do
x,y=pt((center_x-3),(center_y+4),76,((223-(79/#t)*i)))
cairo_move_to (cr,x,y)
cairo_show_text (cr,t[i])
end--for
cairo_stroke(cr)
t={"R","A","M"}
for i=1,#t do
x,y=pt((center_x-3),(center_y+4),48,(((90+220)-(60/#t)*i)))
cairo_move_to (cr,x,y)
cairo_show_text (cr,t[i])
end--for
cairo_stroke(cr)
t={"P","A","W","S"}
for i=1,#t do
x,y=pt((center_x-3),(center_y+4),46,((134-(70/#t)*i)))
cairo_move_to (cr,x,y)
cairo_show_text (cr,t[i])
end--for
cairo_stroke(cr)
--######################################################################
-- time markers ########################################################
--######################################################################
for i=1,60 do
second_markers_position=(-90*d_math)+((i*(360/60))*d_math)
cairo_set_line_width(cr,2)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_BUTT)
cairo_arc(cr,center_x,center_y,115,second_markers_position,second_markers_position)
cairo_arc(cr,center_x,center_y,110,second_markers_position,second_markers_position)
cairo_set_source_rgba(cr,.75,.75,.75,1)
cairo_stroke(cr)
cairo_arc(cr,center_x,center_y,130,second_markers_position,second_markers_position)
cairo_arc(cr,center_x,center_y,125,second_markers_position,second_markers_position)
cairo_stroke(cr)
end
for i=i_start,i_end do
hour_markers_position=(-90*d_math)+(i*(360/hours))*d_math
cairo_set_line_width(cr,3)
cairo_arc(cr,center_x,center_y,150,hour_markers_position,hour_markers_position)
cairo_arc(cr,center_x,center_y,145,hour_markers_position,hour_markers_position)
cairo_set_source_rgba(cr,.5,.5,.5,1)
cairo_stroke(cr)
cairo_arc(cr,center_x,center_y,135,hour_markers_position,hour_markers_position)
cairo_arc(cr,center_x,center_y,130,hour_markers_position,hour_markers_position)
cairo_stroke(cr)
end
--######################################################################
-- time text ###########################################################
--######################################################################
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
cairo_set_source_rgba(cr,.8,.8,.8,1)
if hours==24 then
for i=0,23 do
if i==0 or i==2 or i==4 or i==6 or i==8 or i==10 or i==12 or i==14 or i==16 or i==18 or i==20 or i==22 then
x,y=pt((center_x-4),(center_y+4),(hour_radius),((360/24)*i))
cairo_move_to (cr,x,y)
cairo_show_text (cr,i)
end
end--for
elseif hours==12 then
for i=1,12 do
x,y=pt((center_x-4),(center_y+4),(hour_radius),((360/12)*i))
cairo_move_to (cr,x,y)
cairo_show_text (cr,i)
end--for
end--hours
if seconds==5 then
for i=0,59 do
if i==0 or i==5 or i==10 or i==15 or i==20 or i==25 or i==30 or i==35 or i==40 or i==45 or i==50 or i==55 then
x,y=pt((center_x-5),(center_y+4),(second_radius),((360/60)*i))
cairo_move_to (cr,x,y)
cairo_show_text (cr,i)
end
end--for
elseif seconds==10 then
for i=0,59 do
if i==0 or i==10 or i==20 or i==30 or i==40 or i==50 then
x,y=pt((center_x-5),(center_y+4),(second_radius),((360/60)*i))
cairo_move_to (cr,x,y)
cairo_show_text (cr,i)
end
end--for
elseif seconds==15 then
for i=0,59 do
if i==0 or i==15 or i==30 or i==45 then
x,y=pt((center_x-5),(center_y+4),(second_radius),((360/60)*i))
cairo_move_to (cr,x,y)
cairo_show_text (cr,i)
end
end--for
end--second
cairo_stroke(cr)
--######################################################################
-- mrpeacy code end ####################################################
--######################################################################
--hour hand top
cairo_set_line_width(cr,6)
cairo_arc(cr,center_x,center_y,160,(hour_position-((hour_hand_size/2)*d_math)),(hour_position+((hour_hand_size/2)*d_math)))
cairo_arc_negative(cr,center_x,center_y,140,hour_position,hour_position)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_close_path(cr)
cairo_fill(cr)
--minute hand top
cairo_arc(cr,center_x,center_y,170,(minute_position-((minute_hand_size/2)*d_math)),(minute_position+((minute_hand_size/2)*d_math)))
cairo_arc_negative(cr,center_x,center_y,120,minute_position,minute_position)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_fill_preserve(cr)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_close_path(cr)
cairo_fill(cr)
--second hand
cairo_set_line_width(cr,2)
cairo_arc(cr,center_x,center_y,10,0,(360*d_math))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_fill(cr)
cairo_arc(cr,center_x,center_y,9,0,(360*d_math))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_fill(cr)
cairo_set_line_width(cr,4)
cairo_arc(cr,center_x,center_y,10,second_position,second_position)
cairo_arc(cr,center_x,center_y,120,second_position,second_position)
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_set_line_width(cr,3)
cairo_arc(cr,center_x,center_y,9,second_position,second_position)
cairo_arc(cr,center_x,center_y,119,second_position,second_position)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_stroke(cr)
cairo_set_line_width(cr,4)
cairo_arc(cr,center_x,center_y,10,(second_position-(180*d_math)),(second_position-(180*d_math)))
cairo_arc(cr,center_x,center_y,30,(second_position-(180*d_math)),(second_position-(180*d_math)))
cairo_set_source_rgba(cr,1,1,1,1)
cairo_stroke(cr)
cairo_set_line_width(cr,3)
cairo_arc(cr,center_x,center_y,9,(second_position-(180*d_math)),(second_position-(180*d_math)))
cairo_arc(cr,center_x,center_y,29,(second_position-(180*d_math)),(second_position-(180*d_math)))
cairo_set_source_rgba(cr,0,0,0,1)
cairo_stroke(cr)
--#################################################################
--#################################################################
--#################################################################
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return""
end-- end main function
--#################################################################
--#################################################################
--#################################################################
--######################################################################
-- mrpeacy code ########################################################
--######################################################################
function pt(px,py,prad,pdeg)
local ppo=(math.pi/180)*pdeg
local px1=px+prad*(math.sin(ppo))
local py1=py-prad*(math.cos(ppo))
return px1,py1
end
function font(fontt)
local name=fontt.f or default_font_name or "mono"
local size=fontt.fs or default_font_size or 12
local face=fontt.ff or default_font_face or "n"
if face=="n" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="b" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
elseif face=="i" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL)
elseif face=="bi" then
cairo_select_font_face(cr,name,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD)
end
cairo_set_font_size(cr,size)
end
function hexcolor(hexcolort)
local col=hexcolort.c or default_hex_color or 0xffffff
local a=hexcolort.a or default_alpha or 1
local r,g,b=((col/0x10000) % 0x100)/255,((col/0x100) % 0x100)/255,(col % 0x100)/255
cairo_set_source_rgba(cr,r,g,b,a)
end
function text(textt)
local x=textt.x or 100
local y=textt.y or 100
local t=textt.t or "set txt"
local hj=textt.hj or default_horizontal_justify or "l"
local vj=textt.vj or default_vertical_justify or "n"
local r=textt.r or default_rotation or 0
cairo_text_extents(cr,t,extents)
local wx=extents.x_advance
local wd=extents.width
local hy=extents.height
local bx=extents.x_bearing
local by=extents.y_bearing+hy
--hl-- l=left, c=center, r=right
if hj=="l" then
xa=x-bx
rad=0
elseif hj=="c" then
xa=x-((wx-bx)/2)-bx
rad=(wx-bx)/2
elseif hj=="r" then
xa=x-wx
rad=wx-bx
else
print ('hj not set correctly for text: '..t..' - "l", "c" or "r"')
xa=0
rad=0
end
--vj-- n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
ya=y
rad2=0
ry=by
elseif vj=="nb" then
ya=y-by
rad2=-by
ry=by
elseif vj=="m" then
ya=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
ya=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
ya=y+hy-by
rad2=hy-by
ry=0+by
else
print ('vj not set correctly for text: '..t..' - "n", "nb", "m", "mb" or "t"')
ya=0
rad2=0
ry=0
end
--rotation
if r~=0 then
local x2,y2=pt(x,y,rad2,r-180)
local x1,y1=pt(x2,y2,rad,r-90)
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*r)
cairo_show_text (cr,t)
cairo_stroke (cr)
cairo_restore (cr)
else
cairo_move_to (cr,xa,ya)
cairo_show_text (cr,t)
cairo_stroke (cr)
end--if ro
--set non local variables to nil
xa=nil;ya=nil;rad=nil;rad2=nil;ry=nil
end--function text #####################################################

😉