Londonali1010 clock hands.module (en)
From Conky PitStop
londonali1010_clock_hands.module
Language | English Français |
londonali1010 clock_hands for One4All project
Londonali1010 clock hands.module-1.0.tar.gz
--[[ CLOCK HANDS one4all module --[[ Options (xc, yc, colour, alpha, show_secs, size): "xc" and "yc" are the x and y coordinates of the centre of the clock hands, in pixels, relative to the top left corner of the Conky window "colour" is the colour of the clock hands, in OxFFFFFF formate "alpha" is the alpha of the hands, between 0 and 1 "show_secs" is a boolean; set to TRUE to show the seconds hand, otherwise set to FALSE "size" is the total size of the widget (e.g. twice the length of the minutes hand), in pixels ]] --[[ chnagelog: v1.0 - (..) converted to One4All module --]] local modname = ... local M = {} _G[modname] = M package.loaded[modname] = M --[[ ############################################################################### ### SETTINGS ### ############################################################################### --]] local settings_table = { { xc = 100, yc = 100, colour = 0xffffff, alpha = 0.5, size = 180, }, } --[[ ############################################################################### ### END OF SETTINGS ### ############################################################################### --]] function M.clock_hands(t) local secs,mins,hours,secs_arc,mins_arc,hours_arc local xh,yh,xm,ym,xs,ys secs=os.date("%S") mins=os.date("%M") hours=os.date("%I") secs_arc=(2*math.pi/60)*secs mins_arc=(2*math.pi/60)*mins+secs_arc/60 hours_arc=(2*math.pi/12)*hours+mins_arc/12 xh=t.xc+0.4*t.size*math.sin(hours_arc) yh=t.yc-0.4*t.size*math.cos(hours_arc) cairo_move_to(cr,t.xc,t.yc) cairo_line_to(cr,xh,yh) cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND) cairo_set_line_width(cr,5) cairo_set_source_rgba(cr,one4all_cairo.rgb2rgba(t.colour,t.alpha)) cairo_stroke(cr) xm=t.xc+0.5*t.size*math.sin(mins_arc) ym=t.yc-0.5*t.size*math.cos(mins_arc) cairo_move_to(cr,t.xc,t.yc) cairo_line_to(cr,xm,ym) cairo_set_line_width(cr,3) cairo_stroke(cr) if t.show_secs then xs=t.xc+0.5*t.size*math.sin(secs_arc) ys=t.yc-0.5*t.size*math.cos(secs_arc) cairo_move_to(cr,t.xc,t.yc) cairo_line_to(cr,xs,ys) cairo_set_line_width(cr,1) cairo_stroke(cr) end end --[[ ############################################################################### ### MODULE MAIN LOOP ### ############################################################################### --]] function M.main() for i in pairs(settings_table) do M.clock_hands(settings_table[i]) end end