Seconde version de l'horloge Flip Flap, je me suis contenté de modifier la position des paramètres, de manière à rendre plus simple les modifications effectuées par l'utilisateur.
Flip_Flap_Clock.lua
--[[
by mrpeachy
Modifié par Dider-T pour utilisation de l'horloge seul - le 28/01/2014
Utilisation dans le conky
############################################################################
# #
# Avant TEXT #
# #
############################################################################
# #
# lua_load /chemin/vers/le/script/Flip_Flap_Clock.lua #
# lua_draw_hook_pre main #
# #
############################################################################
]]--
--[[
#############################################################################
# #
# EDITABLE #
# #
# Zonne de paramètres #
# #
#############################################################################
]]--
default_font="LED_mono"--font must be in quotes
default_font_size=12
default_face="normal"
default_color=0xffffff
default_alpha=1--fully opaque text
ajust=1--ajustement des chiffres en hauteur
alignement="r"-- l (Left), r (right) or c (center)
function tab()
local Digit={
{
TopLeftX=50,
TopLeftY=50,
cra=10,
sw=30,
Digit=tostring(os.date("%H")):sub(1,1)
},
{
TopLeftX=105,
TopLeftY=50,
cra=10,
sw=30,
Digit=tostring(os.date("%H")):sub(2,2)
},
{
TopLeftX=170,
TopLeftY=50,
cra=10,
sw=30,
Digit=tostring(os.date("%M")):sub(1,1)
},
{
TopLeftX=225,
TopLeftY=50,
cra=10,
sw=30,
Digit=tostring(os.date("%M")):sub(2,2)
},
{
TopLeftX=290,
TopLeftY=65,
cra=10,
sw=20,
Digit=tostring(os.date("%S")):sub(1,1)
},
{
TopLeftX=335,
TopLeftY=65,
cra=10,
sw=20,
Digit=tostring(os.date("%S")):sub(2,2)
},
}
return Digit
end
--[[
#############################################################################
# #
# END EDITABLE #
# #
# Fin de la zonne de paramètres #
# Ne rien modifier après cette ligne #
# #
#############################################################################
]]--
require 'cairo'
require 'os'
_G.weather_script = function()
local settings_table=tab()
for i in pairs(settings_table) do
flip_digit(settings_table[i].TopLeftX,settings_table[i].TopLeftY,settings_table[i].cra,settings_table[i].sw,settings_table[i].Digit)
end
end
function conky_main()--run with lua_draw_hook_pre 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)
cr = cairo_create(cs)
_G.weather_script()
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
collectgarbage()
end
function grec(gtab)--#################################################################################
local function color(col,alp)
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
local 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
local function sub_draw(sdtab)
local cdsx={}
local cdsy={}
local dr={}
local limit=#sdtab
local x, y, d, ang1, ang2, rad, alx, aly, ax, ay, q
for i=1,limit do
d=sdtab[i].d
if d=="start" then
table.insert(dr,"cairo_move_to(cr,"..tostring(sdtab[i].x)..","..tostring(sdtab[i].y)..");")
table.insert(cdsx,sdtab[i].x)
table.insert(cdsy,sdtab[i].y)
end
if d=="line" then
table.insert(dr,"cairo_line_to(cr,"..tostring(sdtab[i].x)..","..tostring(sdtab[i].y)..");")
table.insert(cdsx,sdtab[i].x)
table.insert(cdsy,sdtab[i].y)
end
if d=="rline" then
table.insert(dr,"cairo_rel_line_to(cr,"..tostring(sdtab[i].x)..","..tostring(sdtab[i].y)..");")
table.insert(cdsx,cdsx[i-1]+sdtab[i].x)
table.insert(cdsy,cdsy[i-1]+sdtab[i].y)
end
if d=="aline" then
--pt(px,py,prad,pdeg)
alx,aly=pt(cdsx[i-1],cdsy[i-1],sdtab[i].l,sdtab[i].a)
table.insert(dr,"cairo_line_to(cr,"..tostring(alx)..","..tostring(aly)..");")
table.insert(cdsx,alx)
table.insert(cdsy,aly)
end
if d=="arc" then
ang1=(math.pi/180)*((sdtab[i].a1)-90)
ang2=(math.pi/180)*((sdtab[i].a2)-90)
rad=sdtab[i].r
x=sdtab[i].x
y=sdtab[i].y
table.insert(dr,"cairo_arc(cr,"..tostring(x)..","..tostring(y)..","..tostring(rad)..","..tostring(ang1)..","..tostring(ang2)..");")
ang2=(math.pi/180)*(sdtab[i].a2)
ax=0+rad*(math.sin(ang2))
ay=0-rad*(math.cos(ang2))
table.insert(cdsx,x+ax)
table.insert(cdsy,y+ay)
end
if d=="arc_c" then
q=sdtab[i].q
rad=sdtab[i].r
if q==4 then
ang1=(math.pi/180)*(270-90)
x=cdsx[i-1]+rad
y=cdsy[i-1]
elseif q==1 then
ang1=(math.pi/180)*(360-90)
x=cdsx[i-1]
y=cdsy[i-1]+rad
elseif q==2 then
ang1=(math.pi/180)*(90-90)
x=cdsx[i-1]-rad
y=cdsy[i-1]
elseif q==3 then
ang1=(math.pi/180)*(180-90)
x=cdsx[i-1]
y=cdsy[i-1]-rad
end
ang2=ang1+((math.pi/180)*(sdtab[i].degs))
table.insert(dr,"cairo_arc(cr,"..tostring(x)..","..tostring(y)..","..tostring(rad)..","..tostring(ang1)..","..tostring(ang2)..");")
ang2=ang2+((math.pi/180)*90)
ax=0+rad*(math.sin(ang2))
ay=0-rad*(math.cos(ang2))
table.insert(cdsx,x+ax)
table.insert(cdsy,y+ay)
end
if d=="arc_a" then
q=sdtab[i].q
rad=sdtab[i].r
if q==4 then
ang1=(math.pi/180)*(360-90)
x=cdsx[i-1]
y=cdsy[i-1]+rad
elseif q==1 then
ang1=(math.pi/180)*(90-90)
x=cdsx[i-1]-rad
y=cdsy[i-1]
elseif q==2 then
ang1=(math.pi/180)*(180-90)
x=cdsx[i-1]
y=cdsy[i-1]-rad
elseif q==3 then
ang1=(math.pi/180)*(270-90)
x=cdsx[i-1]+rad
y=cdsy[i-1]
end
ang2=ang1-(math.pi/180)*(sdtab[i].degs)
table.insert(dr,"cairo_arc_negative(cr,"..tostring(x)..","..tostring(y)..","..tostring(rad)..","..tostring(ang1)..","..tostring(ang2)..");")
ang2=ang2+((math.pi/180)*90)
ax=0+rad*(math.sin(ang2))
ay=0-rad*(math.cos(ang2))
table.insert(cdsx,x+ax)
table.insert(cdsy,y+ay)
end
end
return table.concat(dr)
end--of local function sub_draw
local g=gtab.g or 1
local x=gtab.x or 0
local y=gtab.y or 0
local w=gtab.w or 50
local h=gtab.h or 50
local r=gtab.r or 50
local rgx=gtab.rgx or x
local rgy=gtab.rgy or y
local grad=gtab.grad or {{c=0xffffff}}
local gan=gtab.gan or 45
local lw=gtab.lw or 1
local sub=gtab.sub or 0
local db=gtab.db or 0
local subtab=gtab.subtab
if db==1 and g~=6 then
cairo_set_source_rgba (cr,1,1,1,1)
cairo_set_line_width (cr,1)
cairo_rectangle (cr,x,y,w,h)
cairo_stroke (cr)
elseif db==1 and g==6 then
cairo_set_source_rgba (cr,1,1,1,1)
cairo_set_line_width (cr,1)
cairo_arc (cr,x,y,r,0,2*math.pi)
cairo_stroke (cr)
end
--##########################################
if g==1 or g==2 or g==5 or g==6 then --rectangular gradients
if g==1 then
pat = cairo_pattern_create_linear (0,y,0,y+h);
elseif g==2 then
pat = cairo_pattern_create_linear (x,0,x+w,0);
elseif g==5 then
--calculate hypotenuse across middle of rectange
local hyp=math.sqrt((w^2)+(h^2))
local rad=hyp/2
--center point of rectangle
local crx=x+(w/2)
local cry=y+(h/2)
--calculate point 1
local point=(math.pi/180)*gan
local x1=crx+rad*(math.sin(point))
local y1=cry-rad*(math.cos(point))
--calculate point 2
local point=(math.pi/180)*(gan+180)
local x2=crx+rad*(math.sin(point))
local y2=cry-rad*(math.cos(point))
--gradient
pat = cairo_pattern_create_linear (x1,y1,x2,y2);
elseif g==6 then
pat = cairo_pattern_create_radial (rgx, rgy, 0, x, y, r);
end
local gnum=#grad
for i=1,gnum do
cairo_pattern_add_color_stop_rgba (pat,grad[i].p,color(grad[i].c,grad[i].a));
end--for loop
if sub==1 then
cairo_save (cr)
cairo_clip(cr)
cairo_new_sub_path(cr)
local drawstring=sub_draw(subtab)
loadstring(drawstring)()
cairo_restore (cr)
end
cairo_set_source (cr, pat);
cairo_fill(cr);
cairo_pattern_destroy (pat);
--###########################################
elseif g==0 and sub==1 then --non gradient
local drawstring=sub_draw(subtab)
loadstring(drawstring)()
cairo_set_source_rgba (cr,color(grad[1].c,grad[1].a));
cairo_fill(cr)
elseif g==3 and sub==1 then
local drawstring=sub_draw(subtab)
loadstring(drawstring)()
cairo_set_line_width(cr,lw)
cairo_set_source_rgba (cr,color(grad[1].c,grad[1].a));
cairo_close_path (cr)
cairo_stroke(cr);
elseif g==4 and sub==1 then
local drawstring=sub_draw(subtab)
loadstring(drawstring)()
cairo_set_source_rgba (cr,color(grad[1].c,grad[1].a));
cairo_fill_preserve(cr);
cairo_set_line_width(cr,lw)
cairo_set_source_rgba (cr,color(grad[2].c,grad[2].a));
cairo_close_path (cr)
cairo_stroke(cr);
elseif g==0 and sub~=1 then
cairo_rectangle (cr,x,y,w,h)
cairo_set_source_rgba (cr,color(grad[1].c,grad[1].a));
cairo_fill(cr);
elseif g==3 and sub~=1 then
cairo_rectangle (cr,x,y,w,h)
cairo_set_line_width(cr,lw)
cairo_set_source_rgba (cr,color(grad[1].c,grad[1].a));
cairo_close_path (cr)
cairo_stroke(cr);
elseif g==4 and sub~=1 then
cairo_rectangle (cr,x,y,w,h)
cairo_set_source_rgba (cr,color(grad[1].c,grad[1].a));
cairo_fill_preserve(cr);
cairo_set_line_width(cr,lw)
cairo_set_source_rgba (cr,color(grad[2].c,grad[2].a));
cairo_close_path (cr)
cairo_stroke(cr);
--radial gradients
elseif g==6 then
pat = cairo_pattern_create_radial (cx, cy, crad-(clw/2)-2,--
cx, cy, crad+(clw/2)+4);
cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 0, 1);
cairo_pattern_add_color_stop_rgba (pat, 0.5, 0, 0, 0, 0);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 0, 1);
cairo_set_source (cr, pat);
cairo_arc (cr, cx, cy, crad+(clw/2), 0, 2*math.pi);
cairo_fill (cr);
cairo_pattern_destroy (pat);
end--of g type
end--of function grec
--END MAIN GTAB FUNCTION################################################--]]
function glassyboxtop(tlx,tly,cra,sw,sh,bg)
sho=sh
sw=sw-cra-cra
sh=sh-cra-cra
--BIG FILLED IN RECTANGLE
if bg~=1 then
subtab={
{d="start",x=tlx+cra,y=tly},
{d="rline",x=sw,y=0},
{d="arc_c",q=1,r=cra,degs=90},
{d="rline",x=0,y=sh+cra},
{d="rline",x=-sw-cra-cra,y=0},
{d="rline",x=0,y=-sh-cra},
{d="arc_c",q=4,r=cra,degs=90},
}
grec({
g=1,
x=tlx,
y=tly,
w=sw+cra+cra,
h=sh+cra+cra,
grad={{c=0x606060,a=0.3,p=0},{c=0x101010,a=0.3,p=1}},
lw=1,
sub=1,
db=0,
subtab=subtab})
end
--[HIGHLIGHT TOP RECTANGLE
if bg~=1 and bg~=2 then
shh=((80/150)*sho)-cra-cra
subtab={
{d="start",x=tlx+cra,y=tly},
{d="rline",x=sw,y=0},
{d="arc_c",q=1,r=cra,degs=90},
{d="rline",x=0,y=shh},
{d="arc_c",q=2,r=cra,degs=90},
{d="rline",x=-sw,y=0},
{d="arc_c",q=3,r=cra,degs=90},
{d="rline",x=0,y=-shh},
{d="arc_c",q=4,r=cra,degs=90},
}
grec({
g=1,
x=tlx,
y=tly,
w=sw+cra+cra,
h=shh+cra+cra,
grad={{c=0xffffff,a=0.5,p=0},{c=0xffffff,a=0,p=1}},
lw=1,
sub=1,
db=0,
subtab=subtab})
end
--OUTLINE
lt=1 --BOARDER WIDTH
tlx,tly=tlx-lt,tly-lt
cra1=cra+lt
subtab={
{d="start",x=tlx+cra1,y=tly},
{d="rline",x=sw,y=0},
{d="arc_c",q=1,r=cra1,degs=90},
{d="rline",x=0,y=sh+cra1},
--{d="arc_c",q=2,r=cra1,degs=90},
{d="rline",x=-sw-cra1-cra1,y=0},
--{d="arc_c",q=3,r=cra1,degs=90},
{d="rline",x=0,y=-sh-cra1},
{d="arc_c",q=4,r=cra1,degs=90},
{d="rline",x=sw,y=0},
{d="rline",x=0,y=lt},
{d="rline",x=-sw,y=0},
{d="arc_a",q=4,r=cra,degs=90},
{d="rline",x=0,y=sh+cra},
--{d="arc_a",q=3,r=cra,degs=90},
{d="rline",x=sw+cra+cra,y=0},
--{d="arc_a",q=2,r=cra,degs=90},
{d="rline",x=0,y=-sh-cra},
{d="arc_a",q=1,r=cra,degs=90},
{d="rline",x=-sw,y=0},
}
grec({
g=1,
x=tlx,
y=tly,
w=sw+cra+cra,
h=sh+cra+cra,
grad={{c=0x808080,a=1,p=0},{c=0x202020,a=1,p=1}},
lw=1,
sub=1,
db=0,
subtab=subtab})--]]
end
function glassyboxbot(tlx,tly,cra,sw,sh,bg)
sho=sh
sw=sw-cra-cra
sh=sh-cra-cra
--BIG FILLED IN RECTANGLE
if bg~=1 then
subtab={
{d="start",x=tlx+cra,y=tly},
{d="rline",x=sw+cra,y=0},
--{d="arc_c",q=1,r=cra,degs=90},
{d="rline",x=0,y=sh+cra},
{d="arc_c",q=2,r=cra,degs=90},
{d="rline",x=-sw,y=0},
{d="arc_c",q=3,r=cra,degs=90},
{d="rline",x=0,y=-sh-cra},
--{d="arc_c",q=4,r=cra,degs=90},
}
grec({
g=1,
x=tlx,
y=tly,
w=sw+cra+cra,
h=sh+cra+cra,
grad={{c=0x606060,a=0.3,p=0},{c=0x101010,a=0.3,p=1}},
lw=1,
sub=1,
db=0,
subtab=subtab})
end
--[HIGHLIGHT TOP RECTANGLE
if bg~=1 and bg~=2 then
shh=((80/150)*sho)-cra-cra
subtab={
{d="start",x=tlx+cra,y=tly},
{d="rline",x=sw+cra,y=0},
--{d="arc_c",q=1,r=cra,degs=90},
{d="rline",x=0,y=shh+cra},
{d="arc_c",q=2,r=cra,degs=90},
{d="rline",x=-sw,y=0},
{d="arc_c",q=3,r=cra,degs=90},
{d="rline",x=0,y=-shh-cra},
--{d="arc_c",q=4,r=cra,degs=90},
}
grec({
g=1,
x=tlx,
y=tly,
w=sw+cra+cra,
h=shh+cra+cra,
grad={{c=0xffffff,a=0.5,p=0},{c=0xffffff,a=0,p=1}},
lw=1,
sub=1,
db=0,
subtab=subtab})
end
--OUTLINE
lt=1 --BOARDER WIDTH
tlx,tly=tlx-lt,tly-lt
cra1=cra+lt
subtab={
{d="start",x=tlx+cra+lt,y=tly},
{d="rline",x=sw+cra1,y=0},
--{d="arc_c",q=1,r=cra1,degs=90},
{d="rline",x=0,y=sh+cra1},
{d="arc_c",q=2,r=cra1,degs=90},
{d="rline",x=-sw,y=0},
{d="arc_c",q=3,r=cra1,degs=90},
{d="rline",x=0,y=-sh-cra1},
--{d="arc_c",q=4,r=cra1,degs=90},
{d="rline",x=sw+cra1,y=0},
{d="rline",x=0,y=lt},
{d="rline",x=-sw-cra,y=0},
--{d="arc_a",q=4,r=cra,degs=90},
{d="rline",x=0,y=sh+cra},
{d="arc_a",q=3,r=cra,degs=90},
{d="rline",x=sw,y=0},
{d="arc_a",q=2,r=cra,degs=90},
{d="rline",x=0,y=-sh-cra},
--{d="arc_a",q=1,r=cra,degs=90},
{d="rline",x=-sw,y=0},
}
grec({
g=1,
x=tlx,
y=tly,
w=sw+cra+cra,
h=sh+cra+cra,
grad={{c=0x808080,a=1,p=0},{c=0x202020,a=1,p=1}},
lw=1,
sub=1,
db=0,
subtab=subtab})--]]
end
function out(txj)--c,a,f,fs,face,x,y,txt,hj,vj,ro,sxo,syo,sfs,sface,sc,sa #########################################################
local extents=cairo_text_extents_t:create()
tolua.takeownership(extents)
local function color(col,alp)
return ((col / 0x10000) % 0x100) / 255, ((col / 0x100) % 0x100) / 255, (col % 0x100) / 255, alp
end
local function justify(jtxt,x,hj,y,vj,f,face,fs)
if face=="normal" then
face={f,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL}
elseif face=="bold" then
face={f,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD}
elseif face=="italic" then
face={f,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_NORMAL}
elseif face=="bolditalic" then
face={f,CAIRO_FONT_SLANT_ITALIC,CAIRO_FONT_WEIGHT_BOLD}
else
print ('face not set correctly - "normal","bold","italic","bolditalic"')
end
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_text_extents(cr,jtxt,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
local tx=x
local ty=y
--set horizontal alignment - l, c, r
if hj=="l" then
x=x-bx
rad=0
nx=tx+wx
elseif hj=="c" then
x=(x*2-wx+wd)/2
rad=(wx-bx)/2
nx=tx+(wx/2)
elseif hj=="r" then
x=x-wx+wd+bx
rad=wx-bx
nx=tx
else
print ("hj not set correctly - l, c, r")
end
--vj. n=normal, nb=normal-ybearing, m=middle, mb=middle-ybearing, t=top
if vj=="n" then
y=y
rad2=0
ry=by
elseif vj=="nb" then
y=y-by
rad2=-by
ry=by
elseif vj=="m" then
y=y+((hy-by)/2)
rad2=((hy-by)/2)
ry=((hy-by)/2)-by
elseif vj=="mb" then
y=y+(hy/2)-by
rad2=(hy/2)-by
ry=((hy-by)/2)-by
elseif vj=="t" then
y=y+hy-by
rad2=hy-by
ry=0+by
else
print ("vj not set correctly - n, nb, m, mb, t")
end
return face,fs,x,y,rad,rad2,tx,ty
end--justify local function #########################################################
--set variables
local c=txj.c or default_color or 0xffffff
local a=txj.a or default_alpha or 1
local f=txj.f or default_font or "mono"
local fs=txj.fs or default_font_size or 12
local x=txj.x or 100
local y=txj.y or 100
local txt=txj.txt or "set txt"
local hj=txj.hj or default_hj or "l"
local vj=txj.vj or default_vj or "n"
local ro=txj.ro or defaukt_ro or 0
local face=txj.face or default_face or "normal"
local wl=txj.wrap_len or 0
local wrap_gap=txj.wrap_gap or 15
--shadow
local shadow=txj.shadow or 0
local sxo=txj.sxo or default_sxo or 2
local syo=txj.syo or default_syo or 2
local sc=txj.sc or defualt_sc or 0x000000
local sa=txj.sa or default_sa or 0.8
local sface=txj.sface or default_sface or face
local sfs=txj.sfs or default_sfs or fs
--print text ##################################################################
if wl>0 then--do wrap
local tt={}
local s=txt:gsub(" $","|"):gsub(" ","| "):gsub(" ","| ")
for i in string.gmatch(s, "%S+") do --Where "%S+" is the string pattern.
table.insert(tt,i)
end
local tl=#tt
local sl=string.len(s)
lines={}
if sl<=wl or tl==1 then
table.insert(lines,s)
else
--get longest entry in table
longest=0
for i=1,tl do
local l=string.len(tt[i])
if l>longest then
longest=l
end
end
if wl<longest then wl=longest+1 end
while sl>wl and tl>1 do
local ll=0
local lt={}
while ll+string.len(tt[1])<wl or string.len(tt[1])>wl do
table.insert(lt,tt[1])
table.remove(tt,1)
line=table.concat(lt," ")
ll=string.len(line)
tl=#tt
end--while
table.insert(lines,line)
lastline=table.concat(tt," ")
sl=string.len(lastline)
end--while
table.insert(lines,lastline)
end
end--if wrap
--rotation
if ro~=0 and wl==0 then
if shadow==1 then
local face,fs,x,y,rad,rad2,tx,ty=justify(txt,x+sxo,hj,y+syo,vj,f,sface,sfs)
local point2=(math.pi/180)*(ro-180)
local x2=tx+rad2*(math.sin(point2))
local y2=ty-rad2*(math.cos(point2))
local point=(math.pi/180)*(ro-90)
local x1=x2+rad*(math.sin(point))
local y1=y2-rad*(math.cos(point))
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*ro)
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_set_source_rgba (cr,color(sc,sa))
cairo_show_text (cr,txt)
cairo_stroke (cr)
cairo_restore (cr)
end--if shadow
local face,fs,x,y,rad,rad2,tx,ty=justify(txt,x,hj,y,vj,f,face,sfs)
local point2=(math.pi/180)*(ro-180)
local x2=tx+rad2*(math.sin(point2))
local y2=ty-rad2*(math.cos(point2))
local point=(math.pi/180)*(ro-90)
local x1=x2+rad*(math.sin(point))
local y1=y2-rad*(math.cos(point))
cairo_save (cr)
cairo_translate (cr,x1,y1)
cairo_rotate(cr,(math.pi/180)*ro)
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_set_source_rgba (cr,color(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
cairo_restore (cr)
return nx,ny
elseif wl>0 then
for i=1,#lines do
local txt=string.gsub(lines[i],"|"," ")
if shadow==1 then
local face,fs,x,y=justify(txt,x+sxo,hj,y+syo,vj,f,sface,sfs)
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_move_to (cr,x,y+(wrap_gap*(i-1)))
cairo_set_source_rgba (cr,color(sc,sa))
cairo_show_text (cr,txt)
cairo_stroke (cr)
end--if shadow
local face,fs,x,y=justify(txt,x,hj,y,vj,f,face,fs)
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_move_to (cr,x,y+(wrap_gap*(i-1)))
cairo_set_source_rgba (cr,color(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
end--for i=1,#lines
return #lines*wrap_gap
elseif ro==0 and wl==0 then
--draw shadow first
if shadow==1 then
local face,fs,x,y=justify(txt,x+sxo,hj,y+syo,vj,f,sface,sfs)
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_move_to (cr,x,y)
cairo_set_source_rgba (cr,color(sc,sa))
cairo_show_text (cr,txt)
cairo_stroke (cr)
end--if shadow
local face,fs,x,y=justify(txt,x,hj,y,vj,f,face,fs)
cairo_select_font_face (cr,face[1],face[2],face[3])
cairo_set_font_size(cr,fs)
cairo_move_to (cr,x,y)
cairo_set_source_rgba (cr,color(c,a))
cairo_show_text (cr,txt)
cairo_stroke (cr)
return nx
end--if ro
end--function out #########################################################################################
function flip_digit(tlx,tly,cra,sw,dig)
sh=(sw+cra+cra)*(120/80)
fs=(180/160)*sh
subtab={
{d="start",x=tlx+cra,y=tly},
{d="rline",x=sw,y=0},
{d="arc_c",q=1,r=cra,degs=90},
{d="rline",x=0,y=sh-cra-cra},
{d="arc_c",q=2,r=cra,degs=90},
{d="rline",x=-sw,y=0},
{d="arc_c",q=3,r=cra,degs=90},
{d="rline",x=0,y=-sh+cra+cra},
{d="arc_c",q=4,r=cra,degs=90},
}
grec({g=1,x=tlx,y=tly,w=sw+cra+cra,h=sh+cra+cra,grad={{c=0x202020,a=1,p=0}},lw=1,sub=1,db=0,subtab=subtab})
tin=(sw+cra+cra)/8
tup=(sh)/12
out({x=tlx+tin,y=tly+sh-tup+ajust,fs=fs,txt=dig, hj=alignement})
glassyboxtop(tlx,tly,cra,sw+cra+cra,sh/2,0)
glassyboxbot(tlx,tly+(sh/2),cra,sw+cra+cra,sh/2,0)
cairo_move_to(cr,tlx-1,tly+(sh/2))
cairo_rel_line_to(cr,sw+cra+cra+2,0)
cairo_set_source_rgba(cr,0,0,0,1)
cairo_set_line_width(cr,2)
cairo_stroke(cr)
end
Voici quelques captures, pour ceux qui se demanderaient à quoi ça peut ressembler.
Edit :
Attention, il y a des fuites de mémoires, je regarderais plus tard, mais tu peux demander à mrpeachy, d'y jeter un oeil en attendant problème réglé.
Edit 2 : j'ai ajouté une variable pour ajuster la hauteur du chiffre (pour une position propre dans le Flip Flap)
Edit 3 : correction de la fonction d'alignement et ajout d'une variable pour aligner à gauche, droite ou centrer (perso avec LED_mono, je préfère aligner à droite)