MrPeachy's conky-lua thermometer

The place to post your Salix wallpapers, screenshots etc.
User avatar
Tim CowChip
Posts: 304
Joined: 27. May 2011, 03:35
Location: Cascade Locks, OR

MrPeachy's conky-lua thermometer

Post by Tim CowChip »

Image
ImageImage
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: MrPeachy's conky-lua thermometer

Post by zAchAry »

Where is the code of this?

Why do not you use the real physical substance for such complicated things? since it would be more accurate, let alone that the information from the WWW may be bogus and all you might have would be merely a sophistical appearance, eventually. :mrgreen:
Image
Help to make Slackware easier Donate to Salix
User avatar
Tim CowChip
Posts: 304
Joined: 27. May 2011, 03:35
Location: Cascade Locks, OR

Re: MrPeachy's conky-lua thermometer

Post by Tim CowChip »

zAchAry wrote:Where is the code of this?
thermometer_v4.conky

Code: Select all

# To use #! in a conky use: ${exec echo '#!'}
# killall conky && conky -c ~/Conky/thermometer_v4.conky &

 ###  Begin Window Settings  ##################################################
 # Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_type normal #override
own_window_transparent yes
own_window_hints sticky,skip_pager
own_window_argb_visual yes
# own_window_argb_value 255
# own_window_colour brown
own_window_class Conky
own_window_title Cascade Locks Weather

 # 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

 ### ARGB can be used for real transparency
 ### NOTE that a composite manager is required for real transparency.
 ### This option will not work as desired (in most cases) in conjunction with
 ### 'own_window_type override'
# own_window_argb_visual yes

 ### When ARGB visuals are enabled, this use this to modify the alpha value
 ### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
#own_window_argb_value 0

minimum_size 640 500     ## width, height
maximum_width 640       ## width, usually a good idea to equal minimum width

gap_x 20       ### left &right
gap_y 0        ### up & down

### top_left, top_right, top_middle, bottom_left, bottom_right, bottom_middle
### middle_left, middle_middle, middle_right, or none
alignment middle_middle
 ####################################################  End Window Settings  ###
 ###  Font Settings  ##########################################################
 # Use Xft (anti-aliased font and stuff)
use_xft yes
xftfont dejavu sans mono:size=8
 # Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 0
 # Force UTF8? requires XFT ###
override_utf8_locale yes

draw_shades no
default_shade_color black

draw_outline no # amplifies text if yes
default_outline_color black

uppercase no
 ######################################################  End Font Settings  ###
 ###  Color Settings  #########################################################
default_shade_color grey
default_outline_color black

default_color DCDCDC #Gainsboro
color0 DAA520 #Goldenrod  FFFFF0 #Ivory
color1 778899 #LightSlateGrey
color2 FF8C00 #Darkorange
color3 7FFF00 #Chartreuse
color4 FFA07A #LightSalmon
color5 FFDEAD #NavajoWhite
color6 00BFFF #DeepSkyBlue
color7 00FFFF #Cyan 48D1CC #MediumTurquoise
color8 FFFF00 #Yellow
color9 FF0000 #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
 #####################################################  End Borders Secton  ###
 ###  Miscellaneous Section  ##################################################

 # Boolean value, if true, Conky will be forked to background when started.
background no

 # 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 1028

 # 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

 ##############################################  End Miscellaneous Section  ###
 ###  LUA Settings  ###########################################################
lua_load ~/Conky/LUA/thermometer_v4.lua
 #######################################################  End LUA Settings  ###

 # The all important - How often conky refreshes.
 # If you have a "Crey" try: 0.2 - smokin' - but watch the CPU usage go UP!
update_interval 1



TEXT
${lua conky_draw_bg 10 0 0 650 510 0x000000 0.5}
${lua conky_weather}${voffset 240}${goto 10}${font digitalk:size=18}${time %T}${font}
thermometer_v4.lua

Code: Select all

--#########################################################################################################
--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP--SETUP
secs=300--set update interval
web="http://www.intellicast.com/Local/Forecast.aspx?unit=F&location=USOR0057"--insert unit=C& after? for C
--get web address by going to the intellicast site and entering your location in the box
--for version 3 you must get click on "Extended Forecast" to get the necessary address
units="F"--set units for C or F
mid=24--this is the temp at which temp scale is yellow, ie mid point in color change scale
--#########################################################################################################

require 'cairo'
require 'imlib2'
------------------------------------------------------------------------------
function string:split(delimiter)
local result = { }
local from  = 1
local delim_from, delim_to = string.find( self, delimiter, from  )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from  = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from  )
end
table.insert( result, string.sub( self, from  ) )
return result
end
--------------------------------------------------------------------------------

function conky_weather()
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
local timer=(updates %secs)+1
if timer==1 or updates==6 then
local f=io.popen("curl '"..web.."' | grep -A62 'As of ' | gawk -F'>' -v RS='</' 'RT{print $NF}' | sed -e 's/^[ \t]*//' -e '/^$/d' -e 's/&deg;//g' -e 's/%//g' -e 's/  / /g' -e 's/Thunderstorms/T.Storms/g'")
local data1=f:read("*a")
f:close()
local data2=string.split(data1,"\n")
local data={}
for i,v in pairs(data2) do
if string.find(v,"[%a%d]")~=nil then
table.insert(data,data2[i])
end
end
--##############################################
--current
local wdr=string.split(data[25]," ")
now={con=string.gsub(data[2],"[\r\n]",""),tmp=string.gsub(data[4],units,""),flk=string.gsub(data[5],"Feels Like: ",""),wch=data[7],cel=data[10],hid=data[12],vis=string.gsub(data[15],"[ %a]",""),dpt=data[17],wsp=string.gsub(data[20],"[ %a]",""),wdg=(wdr[1]),wdi=string.gsub(wdr[2],"[%(%)\n\r]",""),wgs=string.gsub(data[30],"[ %a]",""),hum=data[22],prs=string.gsub(data[27],"\"","")}
--############################################
--forecast
local f=io.popen("curl '"..web.."' | grep -A554 'View the Calendar Forecast' | gawk -F'>' -v RS='<' 'RT{print $NF}' | sed -e 's/^[ \t]*//' -e 's/&deg;//g' -e 's/  / /g' -e 's/%//g' -e 's/&deg//g' -e 's/Thunderstorms/T.Storms/g'")
local fdata1=f:read("*a")
f:close()
local fdata=string.split(fdata1,"\n")
local fdata2={}
for i,v in pairs(fdata) do
if string.find(v,"[%a%d]")~=nil then
table.insert(fdata2,fdata[i])
end
end
local uvi=string.split(fdata2[20]," ")
local wsp=string.split(fdata2[32]," ")
local wdr=string.split(fdata2[34]," ")
day1={day=fdata2[2],con=fdata2[3],hih=fdata2[4],low=fdata2[5],sri=fdata2[8],sst=fdata2[10],mri=fdata2[12],mst=fdata2[14],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[22],ppt=fdata2[24],snw=fdata2[26],cld=fdata2[28],mph=fdata2[30],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day2
local uvi=string.split(fdata2[53]," ")
local wsp=string.split(fdata2[65]," ")
local wdr=string.split(fdata2[67]," ")
day2={day=fdata2[35],con=fdata2[36],hih=fdata2[37],low=fdata2[38],sri=fdata2[41],sst=fdata2[43],mri=fdata2[45],mst=fdata2[47],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[55],ppt=fdata2[57],snw=fdata2[59],cld=fdata2[61],mph=fdata2[63],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day3
local start=68
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day3={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day4
local start=start+29
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day4={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day5
local start=start+29
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day5={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day6
local start=start+29
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day6={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day7
local start=start+29
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day7={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=wmh,wkm=wkm,wkt=wkt,wdg=wdg,wdi=wdi}
--day8
local start=start+29
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day8={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day9
local start=start+29
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day9={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
--day10
local start=start+29
local uvi=string.split(fdata2[start+14]," ")
local wsp=string.split(fdata2[start+26]," ")
local wdr=string.split(fdata2[start+28]," ")
day10={day=fdata2[start],con=fdata2[start+1],hih=fdata2[start+2],low=fdata2[start+3],sri=fdata2[start+5],sst=fdata2[start+7],mri=fdata2[start+9],mst=fdata2[start+11],uvn=uvi[1],uvt=string.gsub(uvi[2],"[%(%)]",""),hum=fdata2[start+16],ppt=fdata2[start+18],snw=fdata2[start+20],cld=fdata2[start+22],mph=fdata2[start+24],wmh=string.gsub(wsp[1],"[%a]",""),wkm=string.gsub(wsp[2],"[%a%(,]",""),wkt=string.gsub(wsp[3],"[%a%)]",""),wdg=wdr[1],wdi=string.gsub(wdr[2],"[%(%)\n\r]","")}
end--timer section
display(now,day1,day2,day3,day4,day5,day6,day7,day8,day9,day10)
--################################################################3
end-- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
return ""
end-- end main function

function display(now,day1,day2,day3,day4,day5,day6,day7,day8,day9,day10)
--print (now.con,now.tmp,now.flk,now.wch,now.cel,now.hid,now.vis,now.dpt,now.wsp,now.wdg,now.wgi,now.wgs,now.hum,now.prs)
--[[
--forecast information, 10 day, options
--use like this  dayX.option (where X=day number (1=today,2=tomorrow))
--eg day1.day
day=forecast day and date
con=conditions summary
hih=high temp
low=low temp
sri=sunrise
sst=sunset
mri=moon rise
mst=moon set
uvi=ultraviolet index
hum=humidity
ppt=chance of precipitation
snw=chance of snow
cld=cloud cover
mph=moon phase
wmh=wind speed in mph
wkm=wind speed in km/h
wkt=wind speed in knots
wdg=wind direction in degrees
wdi=wind direction in nesw
]]
--#####################################
--setup text type and color
local font="Mono"
local fsize=10
local red,green,blue,alpha=1,1,1,1
local xpos=430
local ypos=30--first line
local gap1=fsize+2
---------------------------
text=day1.day;txt(text,xpos,ypos,font,14,red,green,blue,alpha)
text="    Conditions: "..day1.con;gap=gap1+4;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="     High Temp: "..day1.hih.."°"..units;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Low Temp: "..day1.low.."°"..units;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Sun Rise: "..day1.sri;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="       Sun Set: "..day1.sst;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="     Moon Rise: "..day1.mri;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Moon Set: "..day1.mst;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="    Moon Phase: "..day1.mph;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      UV Index: "..day1.uvn.." ("..day1.uvt..")";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Humidity: "..day1.hum.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="Chance of Rain: "..day1.ppt.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="Chance of Snow: "..day1.snw.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="   Cloud Cover: "..day1.cld.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="    Wind Speed: "..day1.wmh.."mph";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="Wind Direction: "..day1.wdg.."° ("..day1.wdi..")";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
ypos=240--first line
gap1=fsize+2
gap=0
text=day2.day;txt(text,xpos,ypos,font,14,red,green,blue,alpha)
text="    Conditions: "..day2.con;gap=gap1+4;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="     High Temp: "..day2.hih.."°"..units;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Low Temp: "..day2.low.."°"..units;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Sun Rise: "..day2.sri;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="       Sun Set: "..day2.sst;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="     Moon Rise: "..day2.mri;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Moon Set: "..day2.mst;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="    Moon Phase: "..day2.mph;gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      UV Index: "..day2.uvn.." ("..day1.uvt..")";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="      Humidity: "..day2.hum.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="Chance of Rain: "..day2.ppt.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="Chance of Snow: "..day2.snw.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="   Cloud Cover: "..day2.cld.."%";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="    Wind Speed: "..day2.wmh.."mph";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
text="Wind Direction: "..day2.wdg.."° ("..day2.wdi..")";gap=gap+gap1;txt(text,xpos,ypos+gap,font,fsize,red,green,blue,alpha)
--#####################################
--thermometers for current temps
--thermometer
local scale=1--1=full size, 0.5=half size, 2=double size
local x=35.5
local y=200.5
local temp=tonumber(now.tmp)
local label="Current Temperature"
thermometer (x,y,temp,label,scale,mid,units)
--thermometer
local scale=0.75
local x=x+70
local y=155.5
local temp=tonumber(now.flk)
local label="Feels Like Temp"
thermometer (x,y,temp,label,scale,mid,units)
--thermometer
local scale=0.75
local x=x+60
local y=y
local temp=tonumber(now.wch)
local label="Wind Chill Temp"
thermometer (x,y,temp,label,scale,mid,units)
--thermometer
local scale=0.75
local x=x+60
local y=y
local temp=tonumber(now.hid)
local label="Heat Index Temp"
thermometer (x,y,temp,label,scale,mid,units)
--thermometer
local scale=0.75
local x=x+60
local y=y
local temp=tonumber(now.dpt)
local label="Dew Point Temp"
thermometer (x,y,temp,label,scale,mid,units)
--#############################################
--hi/lo thermometers for forecast days
--thermometer day1 high
local scale=0.4
local x=628
local y=30+95
local temp=tonumber(day1.hih)
local label="none"
thermometer (x,y,temp,label,scale,mid,units)
text="HI";txt(text,x-22,y-20,"Mono",12,1,1,1,1)
--thermometer day1 low
local scale=0.4
local x=x
local y=y+90
local temp=tonumber(day1.low)
local label="none"
thermometer (x,y,temp,label,scale,mid,units)
text="LO";txt(text,x-22,y-20,"Mono",12,1,1,1,1)
--thermometer day2 high
local scale=0.4
local x=x
local y=240+95
local temp=tonumber(day2.hih)
local label="none"
thermometer (x,y,temp,label,scale,mid,units)
text="HI";txt(text,x-22,y-20,"Mono",12,1,1,1,1)
--thermometer day2 low
local scale=0.4
local x=x
local y=y+90
local temp=tonumber(day2.low)
local label="none"
thermometer (x,y,temp,label,scale,mid,units)
text="LO";txt(text,x-22,y-20,"Mono",12,1,1,1,1)
--#############################################
--wind direction compass
compass(170,245,50,tonumber(now.wdg),now.wsp,now.wgs)
--windspeed dial
wspeed_dial(now.wsp,325,300)
--################################################################3
--pressure barometer
barometer(tonumber(now.prs),130,395)
--#########################################
--humidity bar
humidity(340.5,20.5,tonumber(now.hum))
--#########################################
--current conditions display
text="Currently:";txt(text,250,450,"Mono",12,1,1,1,1)
text=now.con;txt(text,250,470,"Mono",22,1,1,1,1)
text="Visibility: "..now.vis.." miles, Ceiling: "..now.cel;txt(text,250,490,"Mono",10,1,1,1,1)
end--display
--#############################################################################################################################################################
function wspeed_dial(ws,px,py)
--0 to 60 mph
--draw circle
cairo_set_line_width (cr,1)
local router=110
cairo_set_source_rgba (cr,0.1,0.1,0.1,1)
cairo_arc (cr,px,py,router,(math.pi/180),0)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_arc (cr,px,py,router,(math.pi/180),0)
cairo_stroke (cr)
-------------------------------------------
--mph scale
local rout1=80
local rin1=rout1-10
for i=0,60 do
if i==5 or i==15 or i==25 or i==35 or i==45 then
rin=rin1--set line length for 5s
cairo_set_line_width (cr,1)
elseif i==0 or i==10 or i==20 or i==30 or i==40 or i==50 or i==60 then
rin=rin1+7--set line length for 10's
cairo_set_line_width (cr,3)
else
rin=rin1+5--set other lines
cairo_set_line_width (cr,1)
end--if i==
arc=(math.pi/180)*(210+(i*(300/60)))
ppx=0+rout1*(math.sin(arc))
ppy=0-rout1*(math.cos(arc))
arc=(math.pi/180)*(210+(i*300/60))
pix=0+rin*(math.sin(arc))
piy=0-rin*(math.cos(arc))
cairo_move_to (cr,px+ppx,py+ppy)
cairo_line_to (cr,px+pix,py+piy)
cairo_stroke (cr)
end--for i=
--mph reading
mph={0,10,20,30,40,50,60}
local rin=rin1-2
for i=1,#mph do
arc=(math.pi/180)*(210+((i-1)*(300/6)))
ppx=0+rin*(math.sin(arc))
ppy=0-rin*(math.cos(arc))
text=mph[i]
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.width
height=extents.height
cairo_move_to (cr,px+ppx-(width/2),py+ppy+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end--for i= print inches
--kmh lines and numbers
--60kmh=96.5606
cairo_set_line_width (cr,1)
local m1=300/96.5606
local rout2=60
local rin2=rout2-5
local num=95
--print lines---------------
for i=0,num do
if i==0 or i==10 or i==20 or i==30 or i==40 or i==50 or i==60 or i==70 or i==80 or i==90 then
rin=rin2-5--set length for 10s
elseif i==5 or i==15 or i==25 or i==35 or i==45 or i==55 or i==65 or 1==75 or i==85 or i==95 then
rin=rin2-2--set length for 5's
else
rin=rin2
end--if i=
---------------------------------------------------
arc=(math.pi/180)*(210+(i*m1))
ppx=0+rout2*(math.sin(arc))
ppy=0-rout2*(math.cos(arc))
arc=(math.pi/180)*(210+(i*m1))
pix=0+rin*(math.sin(arc))
piy=0-rin*(math.cos(arc))
cairo_move_to (cr,px+ppx,py+ppy)
cairo_line_to (cr,px+pix,py+piy)
cairo_stroke (cr)
end--for i --line drawing
--kmh reading
kmh={0,10,20,30,40,50,60,70,80,90}
local rout=rin2-18
for i=1,#kmh do
arc=(math.pi/180)*(210+((i-1)*(m1*10)))
ppx=0+rout*(math.sin(arc))
ppy=0-rout*(math.cos(arc))
text=kmh[i]
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.width
height=extents.height
cairo_move_to (cr,px+ppx-(width/2),py+ppy+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end--kmh lines and numbers
--knots
--60kmh=52.1386
cairo_set_line_width (cr,1)
local m1=300/52.1386
local rout3=90
local rin3=rout3-5
local num=50
--print lines---------------
for i=0,num do
if i==0 or i==10 or i==20 or i==30 or i==40 or i==50 then
rout=rout3-1--set length for 10s
cairo_set_line_width (cr,3)
elseif i==5 or i==15 or i==25 or i==35 or i==45 then
rout=rout3+4--set length for 5's
cairo_set_line_width (cr,1)
else
rout=rout3
cairo_set_line_width (cr,1)
end--if i=
---------------------------------------------------
arc=(math.pi/180)*(210+(i*m1))
ppx=0+rout*(math.sin(arc))
ppy=0-rout*(math.cos(arc))
arc=(math.pi/180)*(210+(i*m1))
pix=0+rin3*(math.sin(arc))
piy=0-rin3*(math.cos(arc))
cairo_move_to (cr,px+pix,py+piy)
cairo_line_to (cr,px+ppx,py+ppy)
cairo_stroke (cr)
end--for i --line drawing
--kmh reading
knot={0,10,20,30,40,50}
local rout=rin3+15
for i=1,#kmh do
arc=(math.pi/180)*(210+((i-1)*(m1*10)))
ppx=0+rout*(math.sin(arc))
ppy=0-rout*(math.cos(arc))
text=knot[i]
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.width
height=extents.height
cairo_move_to (cr,px+ppx-(width/2),py+ppy+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
--scale labels
local text="mph"
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,px-(width/2),py+rin1)
cairo_show_text (cr,text)
cairo_stroke (cr)
local text="kmh"
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,px-(width/2),py+rin2)
cairo_show_text (cr,text)
cairo_stroke (cr)
local text="knots"
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,px-(width/2),py+rin3)
cairo_show_text (cr,text)
cairo_stroke (cr)
local text="Wind Speed"
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,px-(width/2),py+rin3+16)
cairo_show_text (cr,text)
cairo_stroke (cr)
--pointer
if ws==nil then ws=0 end
local wspd=ws
local m1=300/60
local m2=wspd*m1
local rout1=rout3
local arc=(math.pi/180)*(210+m2)
local ppx=0+rout1*(math.sin(arc))
local ppy=0-rout1*(math.cos(arc))
------------------------------
local arc=(math.pi/180)*(210+m2+180)
local ppox=0+rout1*(math.sin(arc))
local ppoy=0-rout1*(math.cos(arc))
-------------------------------
local rin3=7
local arc=(math.pi/180)*(210+m2-90)
local pilx=0+rin3*(math.sin(arc))
local pily=0-rin3*(math.cos(arc))
local arc=(math.pi/180)*(210+m2+90)
local pirx=0+rin3*(math.sin(arc))
local piry=0-rin3*(math.cos(arc))
--------------------------------
cairo_move_to (cr,px+pilx,py+pily)
cairo_line_to (cr,px+ppx,py+ppy)
cairo_line_to (cr,px+pirx,py+piry)
cairo_line_to (cr,px+pilx,py+pily)
cairo_set_source_rgba (cr,1,0,0,1)
cairo_fill (cr)
cairo_arc (cr,px,py,rin3,(math.pi/180),0)
cairo_fill (cr)
---------------------------------
cairo_move_to (cr,px+pilx,py+pily)
cairo_line_to (cr,px+ppox,py+ppoy)
cairo_line_to (cr,px+pirx,py+piry)
cairo_line_to (cr,px+pilx,py+pily)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,0,0,1)
cairo_arc (cr,px,py,rin3,(math.pi/180),0)
cairo_fill (cr)
-----------------------------------
cairo_set_source_rgba (cr,0,0,0,1)
cairo_arc (cr,px,py,rin3-1,(math.pi/180),0)
cairo_fill (cr)
end--wspeed dial function
--#############################################################################################################################################################
function circlewriting(text, font, fsize, radi, horiz, verti, start, finish)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,1,1,1,1);
local inum=string.len(text)
local deg=(finish-start)/(inum-1)
local degrads=(math.pi/180)
local textcut=string.gsub(text, ".", "%1|")
texttable=string.split(textcut, "|")
for i=1,inum do
interval=(degrads*(start+(deg*(i-1))))
txs=0+radi*(math.sin(interval))
tys=0-radi*(math.cos(interval))
cairo_move_to (cr, txs+horiz, tys+verti);
cairo_rotate (cr, interval)
cairo_show_text (cr, (texttable[i]))
cairo_stroke (cr)
cairo_rotate (cr, -interval)
end
end--circlewriting
--#############################################################################################################################################################
--#############################################################################################################################################################
function humidity(x,y,hval1)
hval=hval1*1.5
yt=y-1
rh=151
rw=30
local pat = cairo_pattern_create_linear (0,yt,0,yt+rh);
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 1, 0);
cairo_pattern_add_color_stop_rgba (pat, 0, 0, 0, 1, 1);
cairo_rectangle (cr,x,yt,rw, rh);
cairo_set_source (cr, pat);
cairo_fill (cr);
cairo_pattern_destroy (pat);
----------
for i=1,11 do
lwid=-1
cairo_set_source_rgba (cr,1,1,1,1)
cairo_move_to (cr,x+rw,(y+150)-((i-1)*15))
cairo_rel_line_to (cr,lwid,0)
cairo_stroke(cr)
end
----------
cairo_set_source_rgba (cr,1,1,1,1)
hh=5
hw1=19
hw2=hw1+10
if hval==nil then hval=0 end
tx,ty=x+hw1,(y+150)-(hval+hh)
ix,iy=x+hw2,(y+150)-hval
bx,by=x+hw1,(y+150)-(hval-hh)
cairo_move_to (cr,tx,ty)
cairo_line_to (cr,ix,iy)
cairo_line_to (cr,bx,by)
cairo_line_to (cr,tx,ty)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,1,1,1)
font="Mono"
fsize=12
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_move_to (cr,x+hw2+3,(y+150)-(hval-hh))
cairo_show_text (cr,hval1.."%")
cairo_stroke (cr)
label="Relative Humidity"
cairo_move_to (cr,x+12,y+150)
cairo_rotate (cr,(math.pi/180)*(-90))
cairo_show_text (cr,label)
cairo_stroke (cr)
cairo_rotate (cr,(math.pi/180)*(90))
end--humidity
--#############################################################################################################################################################
--#############################################################################################################################################################
function txt(text,xpos,ypos,font,fsize,red,green,blue,alpha)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
cairo_set_source_rgba (cr,red,green,blue,alpha)
cairo_move_to (cr,xpos,ypos)
cairo_show_text (cr,text)
cairo_stroke (cr)
end--function txt
--#############################################################################################################################################################
--#############################################################################################################################################################
function barometer(pr,px,py)
--baromeer 27 inches to 32 inches = 5 inches
cairo_set_line_width (cr,1)
local router=100
cairo_set_source_rgba (cr,0.1,0.1,0.1,1)
cairo_arc (cr,px,py,router,(math.pi/180),0)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_arc (cr,px,py,router,(math.pi/180),0)
cairo_stroke (cr)
local rout1=75
local rin1=rout1-10
for i=0,40 do
if i==5 or i==15 or i==25 or i==35 then
rout=rout1-7
cairo_set_line_width (cr,3)
elseif i==0 or i==10 or i==20 or i==30 or i==40 then
rout=rout1
cairo_set_line_width (cr,1)
else
rout=rout1-5
cairo_set_line_width (cr,1)
end
arc=(math.pi/180)*(210+(i*(300/40)))
ppx=0+rout*(math.sin(arc))
ppy=0-rout*(math.cos(arc))
arc=(math.pi/180)*(210+(i*300/40))
pix=0+rin1*(math.sin(arc))
piy=0-rin1*(math.cos(arc))
cairo_move_to (cr,px+ppx,py+ppy)
cairo_line_to (cr,px+pix,py+piy)
cairo_stroke (cr)
end
--inches reading
inch={28,29,30,31}
local rout=rout1+2
for i=1,4 do
arc=(math.pi/180)*(210+(300/8)+((i-1)*(300/4)))
ppx=0+rout*(math.sin(arc))
ppy=0-rout*(math.cos(arc))
text=inch[i]
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.width
height=extents.height
cairo_move_to (cr,px+ppx-(width/2),py+ppy+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
--942 to 1056
--27.5=931.25
--31.5=1066.70
cairo_set_line_width (cr,1)
local m1=300/135.45
local m2=m1*8.75--931.25+8.75=940
local rout2=60
local rin2=rout2-5
local num=60
for i=0,num 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 or i==60 or i==65 then
rin=rin2-5
else
rin=rin2
end
arc=(math.pi/180)*(210+m2+(i*((m1*(num*2))/num)))
ppx=0+rout2*(math.sin(arc))
ppy=0-rout2*(math.cos(arc))
arc=(math.pi/180)*(210+m2+(i*((m1*(num*2))/num)))
pix=0+rin*(math.sin(arc))
piy=0-rin*(math.cos(arc))
cairo_move_to (cr,px+ppx,py+ppy)
cairo_line_to (cr,px+pix,py+piy)
cairo_stroke (cr)
end
--millibars reading
inch={940,960,980,1000,1020,1040,1060}
local rout=rin2-18
for i=1,7 do
arc=(math.pi/180)*(210+m2+((i-1)*(m1*20)))
ppx=0+rout*(math.sin(arc))
ppy=0-rout*(math.cos(arc))
text=inch[i]
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.width
height=extents.height
cairo_move_to (cr,px+ppx-(width/2),py+ppy+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
--scale labels
local text="inches hg"
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,px-(width/2),py+rin1)
cairo_show_text (cr,text)
cairo_stroke (cr)
local text="millibars"
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,px-(width/2),py+rin2-height)
cairo_show_text (cr,text)
cairo_stroke (cr)
local text="Pressure"
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,px-(width/2),py+rin2+35)
cairo_show_text (cr,text)
cairo_stroke (cr)
--pointer
if pr==nil then pr=27.5 end
local pres=pr-27.5
local m1=300/4
local m2=pres*m1
local rout1=rout1
local arc=(math.pi/180)*(210+m2)
local ppx=0+rout1*(math.sin(arc))
local ppy=0-rout1*(math.cos(arc))
------------------------------
local arc=(math.pi/180)*(210+m2+180)
local ppox=0+rout1*(math.sin(arc))
local ppoy=0-rout1*(math.cos(arc))
-------------------------------
local rin3=7
local arc=(math.pi/180)*(210+m2-90)
local pilx=0+rin3*(math.sin(arc))
local pily=0-rin3*(math.cos(arc))
local arc=(math.pi/180)*(210+m2+90)
local pirx=0+rin3*(math.sin(arc))
local piry=0-rin3*(math.cos(arc))
--------------------------------
cairo_move_to (cr,px+pilx,py+pily)
cairo_line_to (cr,px+ppx,py+ppy)
cairo_line_to (cr,px+pirx,py+piry)
cairo_line_to (cr,px+pilx,py+pily)
cairo_set_source_rgba (cr,1,0,0,1)
cairo_fill (cr)
cairo_arc (cr,px,py,rin3,(math.pi/180),0)
cairo_fill (cr)
---------------------------------
cairo_move_to (cr,px+pilx,py+pily)
cairo_line_to (cr,px+ppox,py+ppoy)
cairo_line_to (cr,px+pirx,py+piry)
cairo_line_to (cr,px+pilx,py+pily)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,0,0,1)
cairo_arc (cr,px,py,rin3,(math.pi/180),0)
cairo_fill (cr)
-----------------------------------
cairo_set_source_rgba (cr,0,0,0,1)
cairo_arc (cr,px,py,rin3-1,(math.pi/180),0)
cairo_fill (cr)
----text
local horiz=px
local verti=py
local radi=87
local text="STORMY"
local font="Mono"
local fsize=12
local start=250
local finish=start+((string.len(text))*5)
circlewriting(text, font, fsize, radi, horiz, verti, start, finish)
local text="RAIN"
local start=300
local finish=start+((string.len(text))*5)
circlewriting(text, font, fsize, radi, horiz, verti, start, finish)
local text="CHANGE"
local start=340
local finish=start+((string.len(text))*5)
circlewriting(text, font, fsize, radi, horiz, verti, start, finish)
local text="FAIR"
local start=395
local finish=start+((string.len(text))*5)
circlewriting(text, font, fsize, radi, horiz, verti, start, finish)
local text="VERY DRY"
local start=435
local finish=start+((string.len(text))*5)
circlewriting(text, font, fsize, radi, horiz, verti, start, finish)
end--barometer
--#############################################################################################################################################################
--#############################################################################################################################################################
function compass(wx,wy,rout,wdeg,w,wg)
local rin=rout-((rout/100)*10)
cairo_set_source_rgba (cr,0.1,0.1,0.1,1)
cairo_arc (cr,wx,wy,rout,(math.pi/180),0)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,1,1,1)
cairo_arc (cr,wx,wy,rout,(math.pi/180),0)
cairo_stroke (cr)
for i=1,36 do
arc=(math.pi/180)*(i*10)
wpx=0+rout*(math.sin(arc))
wpy=0-rout*(math.cos(arc))
arc=(math.pi/180)*(i*10)
wix=0+rin*(math.sin(arc))
wiy=0-rin*(math.cos(arc))
cairo_move_to (cr,wx+wpx,wy+wpy)
cairo_line_to (cr,wx+wix,wy+wiy)
cairo_stroke (cr)
end
--print directions
local font="Mono"
local fsize=10
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
dirs={"N","NE","E","SE","S","SW","W","NW"}
local rdir=rout-((rout/100)*25)
for i=1,8 do
arc=(math.pi/180)*((i-1)*(360/8))
wdx=0+rdir*(math.sin(arc))
wdy=0-rdir*(math.cos(arc))
text=dirs[i]
extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
width=extents.width
height=extents.height
cairo_move_to (cr,wx+wdx-(width/2),wy+wdy+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end
--indicator
local npr=rout-((rout/100)*15)
if wdeg==nil then wdeg=0 end
local arc=(math.pi/180)*(wdeg)
local npx=0+npr*(math.sin(arc))
local npy=0-npr*(math.cos(arc))
cairo_move_to (cr,wx+npx,wy+npy)
local nprm=rout-((rout/100)*88)
local arc=(math.pi/180)*(wdeg+90)
local npmrx=0+nprm*(math.sin(arc))
local npmry=0-nprm*(math.cos(arc))
local arc=(math.pi/180)*(wdeg-90)
local npmlx=0+nprm*(math.sin(arc))
local npmly=0-nprm*(math.cos(arc))
cairo_line_to (cr,wx+npmrx,wy+npmry)
cairo_line_to (cr,wx+npmlx,wy+npmly)
cairo_line_to (cr,wx+npx,wy+npy)
cairo_set_source_rgba (cr,1,0,0,1)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,1,1,1)
---------------------------------
local arc=(math.pi/180)*(wdeg-180)
local spx=0+npr*(math.sin(arc))
local spy=0-npr*(math.cos(arc))
cairo_move_to (cr,wx+spx,wy+spy)
local sprm=nprm
local arc=(math.pi/180)*(wdeg+90-180)
local spmrx=0+sprm*(math.sin(arc))
local spmry=0-sprm*(math.cos(arc))
local arc=(math.pi/180)*(wdeg-90-180)
local spmlx=0+sprm*(math.sin(arc))
local spmly=0-sprm*(math.cos(arc))
cairo_line_to (cr,wx+spmrx,wy+spmry)
cairo_line_to (cr,wx+spmlx,wy+spmly)
cairo_line_to (cr,wx+spx,wy+spy)
cairo_fill (cr)
--------------------------------------
cairo_set_source_rgba (cr,0,0,0,1)
cairo_arc (cr,wx,wy,nprm,(math.pi/180),0)
cairo_fill (cr)
cairo_set_source_rgba (cr,1,0,0,1)
cairo_arc (cr,wx,wy,nprm,(math.pi/180),0)
cairo_stroke (cr)
------------------------
cairo_set_source_rgba (cr,1,1,1,1)
local text="Wind Direction"
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,wx-(width/2),wy-rout-5)
cairo_show_text (cr,text)
cairo_stroke (cr)
end--compass
--#############################################################################################################################################################
--#############################################################################################################################################################
function thermometer(mx,my,temp,label,scale,mid,units)
--by mrpeachy 2011
if scale==nil then scale=1 end
if units=="F" then height=150 elseif units=="C" then height=160 end
local mx=mx*(1/scale)
local my=my*(1/scale)
local font="Mono"
local fsize=10
cairo_scale (cr,scale,scale)
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,1,1)
--graphics outer
--bottom circle
r_outer=25
local lang_outer=335
local rang_outer=0+(360-lang_outer)
local h_outer=height-4--maybe make this a percentage?###########
cairo_arc (cr,mx,my,r_outer,(math.pi/180)*(rang_outer-90),(math.pi/180)*(lang_outer-90))
--coordinates,left line
local arc=(math.pi/180)*lang_outer
local lxo=0+r_outer*(math.sin(arc))
local lyo=0-r_outer*(math.cos(arc))
cairo_line_to (cr,mx+lxo,my+lyo-h_outer)
--coordinates,left line
local arc=(math.pi/180)*rang_outer
local rxo=0+r_outer*(math.sin(arc))
local ryo=0-r_outer*(math.cos(arc))
--top circle
cairo_arc (cr,mx+lxo+((rxo-lxo)/2),my+lyo-h_outer,(rxo-lxo)/2,(math.pi/180)*(270-90),(math.pi/180)*(90-90))
--right line
cairo_line_to (cr,mx+lxo+((rxo-lxo)),my+lyo)
cairo_stroke (cr)
----------------------------------------------
--graphics inner
--####################################################
if units=="F" then
local str,stg,stb,sta=0,1,1,1
local mr,mg,mb,ma=1,1,0,1
local fr,fg,fb,fa=1,0,0,1
local nd=150
if temp==nil then temp=0 end
local tadj=temp+30
local middle=mid+30
if tadj<(middle) then
colr=((mr-str)*(tadj/(middle)))+str
colg=((mg-stg)*(tadj/(middle)))+stg
colb=((mb-stb)*(tadj/(middle)))+stb
cola=((ma-sta)*(tadj/(middle)))+sta
elseif tadj>=(middle) then
colr=((fr-mr)*((tadj-(middle))/(nd-middle)))+mr
colg=((fg-mg)*((tadj-(middle))/(nd-middle)))+mg
colb=((fb-mb)*((tadj-(middle))/(nd-middle)))+mb
cola=((fa-ma)*((tadj-(middle))/(nd-middle)))+ma
end
cairo_set_source_rgba (cr,colr,colg,colb,cola)
--bottom circle
r_inner=r_outer-6
local lang_inner=lang_outer+9
local rang_inner=0+(360-lang_inner)
local h_inner=temp+30
cairo_arc (cr,mx,my,r_inner,(math.pi/180)*(rang_inner-90),(math.pi/180)*(lang_inner-90))
--coordinates,left line
local arc=(math.pi/180)*lang_inner
lxi=0+r_inner*(math.sin(arc))
local lyi=0-r_inner*(math.cos(arc))
cairo_line_to (cr,mx+lxi,my+lyi-h_inner)
--coordinates,left line
local arc=(math.pi/180)*rang_inner
rxi=0+r_inner*(math.sin(arc))
local ryi=0-r_inner*(math.cos(arc))
--top circle
cairo_arc (cr,mx+lxi+((rxi-lxi)/2),my+lyi-h_inner,(rxi-lxi)/2,(math.pi/180)*(270-90),(math.pi/180)*(90-90))
--right line
cairo_line_to (cr,mx+lxi+((rxi-lxi)),my+lyi)
cairo_fill (cr)
----------------------------
if label~="none" then
--scale lines
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,1,0.5)
local grad=10
local lnn=15
local lnx=mx+lxo
local lnw=(rxo-lxo)
for i=1,lnn do
lny=my-r_inner-(10+((i-1)*grad))-((rxi-lxi)/2)
if i==lnn then
lnx=lnx+2
lnw=lnw-4
end
cairo_move_to (cr,lnx,lny)
cairo_rel_line_to (cr,lnw,0)
cairo_stroke (cr)
end
--numbers
cairo_set_source_rgba (cr,1,1,1,1)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
local grad=20
local lnn=8
local lnx=mx+lxo+(rxo-lxo)+4
num={-20,"0°"..units,20,40,60,80,100,120}
for i=1,lnn do
lny=my-r_inner-(10+((i-1)*grad))-((rxi-lxi)/2)+(fsize/3)
cairo_move_to (cr,lnx,lny)
cairo_show_text (cr,num[i])
cairo_stroke (cr)
end
end--if label=none
end--if units=F
--#################################################
if units=="C" then
--from -30 to 50 C
local str,stg,stb,sta=0,1,1,1
local mr,mg,mb,ma=1,1,0,1
local fr,fg,fb,fa=1,0,0,1
local nd=160
if temp==nil then temp=0 end
local tadj=(temp*2)+60
local middle=(mid*2)+60
if tadj<(middle) then
colr=((mr-str)*(tadj/(middle)))+str
colg=((mg-stg)*(tadj/(middle)))+stg
colb=((mb-stb)*(tadj/(middle)))+stb
cola=((ma-sta)*(tadj/(middle)))+sta
elseif tadj>=(120) then
colr=((fr-mr)*((tadj-(middle))/(nd-middle)))+mr
colg=((fg-mg)*((tadj-(middle))/(nd-middle)))+mg
colb=((fb-mb)*((tadj-(middle))/(nd-middle)))+mb
cola=((fa-ma)*((tadj-(middle))/(nd-middle)))+ma
end
cairo_set_source_rgba (cr,colr,colg,colb,cola)
--cairo_set_source_rgba (cr,0,1,1,1)
--bottom circle
r_inner=r_outer-6
local lang_inner=lang_outer+9
local rang_inner=0+(360-lang_inner)
local h_inner=(temp*2)+60
cairo_arc (cr,mx,my,r_inner,(math.pi/180)*(rang_inner-90),(math.pi/180)*(lang_inner-90))
--coordinates,left line
local arc=(math.pi/180)*lang_inner
lxi=0+r_inner*(math.sin(arc))
local lyi=0-r_inner*(math.cos(arc))
cairo_line_to (cr,mx+lxi,my+lyi-h_inner)
--coordinates,left line
local arc=(math.pi/180)*rang_inner
rxi=0+r_inner*(math.sin(arc))
local ryi=0-r_inner*(math.cos(arc))
--top circle
cairo_arc (cr,mx+lxi+((rxi-lxi)/2),my+lyi-h_inner,(rxi-lxi)/2,(math.pi/180)*(270-90),(math.pi/180)*(90-90))
--right line
cairo_line_to (cr,mx+lxi+((rxi-lxi)),my+lyi)
cairo_fill (cr)
----------------------------
if label~="none" then
--scale lines
cairo_set_line_width (cr,1)
cairo_set_source_rgba (cr,1,1,1,0.5)
local grad=10
local lnn=17
local lnx=mx+lxo
local lnw=(rxo-lxo)
for i=1,lnn do
lny=my-r_inner-(((i-1)*grad))-((rxi-lxi)/2)
if i==lnn then
lnx=lnx+2
lnw=lnw-4
end
cairo_move_to (cr,lnx,lny)
cairo_rel_line_to (cr,lnw,0)
cairo_stroke (cr)
end
--numbers
cairo_set_source_rgba (cr,1,1,1,1)
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
local grad=20
local lnn=9
local lnx=mx+lxo+(rxo-lxo)+4
num={-30,-20,-10,"0°"..units,10,20,30,40,50}
for i=1,lnn do
lny=my-r_inner-(((i-1)*grad))-((rxi-lxi)/2)+(fsize/3)
cairo_move_to (cr,lnx,lny)
cairo_show_text (cr,num[i])
cairo_stroke (cr)
end
end--if label=none
end--if units=C
--#################################################
--label
if label~="none" then
local font="Mono"
local fsize=12
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize)
local lbx=mx+lxo-5
local lby=my-r_inner-10-((rxi-lxi)/2)
cairo_move_to (cr,lbx,lby)
cairo_rotate (cr,(math.pi/180)*(-90))
cairo_show_text (cr,label)
cairo_stroke (cr)
cairo_rotate (cr,(math.pi/180)*(90))
--temperature readout
cairo_set_source_rgba (cr,0,0,0,1)
local text=temp.."°"..units
local extents=cairo_text_extents_t:create()
cairo_text_extents(cr,text,extents)
local width=extents.width
local height=extents.height
cairo_move_to (cr,mx-(width/2),my+(height/2))
cairo_show_text (cr,text)
cairo_stroke (cr)
end--if label
------------------------------------
cairo_scale (cr,1/scale,1/scale)
end--thermometer function
--#############################################################################################################################################################
--#############################################################################################################################################################
function conky_draw_bg(r,x,y,w,h,color,alpha)
local function rgb_to_r_g_b(colour,alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
if conky_window == nil then return end
if cs == nil then cairo_surface_destroy(cs) end
if cr == nil then cairo_destroy(cr) 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)
cairo_set_source_rgba (cr,rgb_to_r_g_b(color,alpha))
--top left mid circle
local xtl=x+r
local ytl=y+r
--top right mid circle
local xtr=(x+r)+((w)-(2*r))
local ytr=y+r
--bottom right mid circle
local xbr=(x+r)+((w)-(2*r))
local ybr=(y+r)+((h)-(2*r))
--bottom right mid circle
local xbl=(x+r)
local ybl=(y+r)+((h)-(2*r))
-----------------------------
cairo_move_to (cr,xtl,ytl-r)
cairo_line_to (cr,xtr,ytr-r)
cairo_arc(cr,xtr,ytr,r,((2*math.pi/4)*3),((2*math.pi/4)*4))
cairo_line_to (cr,xbr+r,ybr)
cairo_arc(cr,xbr,ybr,r,((2*math.pi/4)*4),((2*math.pi/4)*1))
cairo_line_to (cr,xbl,ybl+r)
cairo_arc(cr,xbl,ybl,r,((2*math.pi/4)*1),((2*math.pi/4)*2))
cairo_line_to (cr,xtl-r,ytl)
cairo_arc(cr,xtl,ytl,r,((2*math.pi/4)*2),((2*math.pi/4)*3))
cairo_close_path(cr)
cairo_fill (cr)
------------------------------------------------------------
cairo_surface_destroy(cs)
cairo_destroy(cr)
return ""
end
zAchAry wrote:Why do not you use the real physical substance for such complicated things? since it would be more accurate, let alone that the information from the WWW may be bogus and all you might have would be merely a sophistical appearance, eventually. :mrgreen:
Image
ImageImage
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: MrPeachy's conky-lua thermometer

Post by zAchAry »

lol. How much RAM does it consume?
Image
Help to make Slackware easier Donate to Salix
User avatar
Tim CowChip
Posts: 304
Joined: 27. May 2011, 03:35
Location: Cascade Locks, OR

Re: MrPeachy's conky-lua thermometer

Post by Tim CowChip »

2384k, but only if you inhale. ;)
ImageImage
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: MrPeachy's conky-lua thermometer

Post by mimosa »

Why do not you use the real physical substance for such complicated things?
As in, look out the window?

@TimCowChip All I can say is, just wait till the clocks go back ;)
User avatar
Tim CowChip
Posts: 304
Joined: 27. May 2011, 03:35
Location: Cascade Locks, OR

Re: MrPeachy's conky-lua thermometer

Post by Tim CowChip »

Image

You can never have enough weather information in the micro-climate rich Pacific Northwest.

Image
ImageImage
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: MrPeachy's conky-lua thermometer

Post by mimosa »

Why is the weather in Brazil so boring? Sun, sun, all the time ... and occasionally it rains, and the city grinds to a halt.
User avatar
zAchAry
Posts: 804
Joined: 11. May 2010, 09:02
Location: Israel

Re: MrPeachy's conky-lua thermometer

Post by zAchAry »

mimosa wrote:
Why do not you use the real physical substance for such complicated things?
As in, look out the window?
No, as in use the real analog equipment.
Image
Help to make Slackware easier Donate to Salix
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: MrPeachy's conky-lua thermometer

Post by mimosa »

A window *is* "analogue equipment".
Post Reply