forecast.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. width5=50 -- width of 5th column: time and date
  2. width4=45 -- width of 4th column: Precipitation
  3. width3=42 -- width of 3rd column: wind_img, also right-alignment for wind text
  4. f_s=12 -- font small
  5. f_l=20 -- font large
  6. o_r2=25 -- offset 2nd row
  7. --
  8. -- first column (image only)
  9. --
  10. tab=%padding_h%
  11. draw_line(tab,%offset%,%width%-%padding_h%*2,2,'%linecol%',0.4,CAIRO_LINE_CAP_BUTT)
  12. draw_svg_file('%smart_img%',tab,%offset%-(%img_size_fc%-%forecast_height%),%img_size_fc%,%img_size_fc%)
  13. --
  14. -- second column
  15. --
  16. tab=tab+%img_size_fc%
  17. draw_text('%ss_text%',tab,%offset%+%forecast_height%-f_s-5,'%font%',f_s,'%textcol%',nil,nil,nil,%width%-tab-%padding_h%)
  18. draw_text('fl %FeelsLike%',tab,%offset%+o_r2,'%font%',f_s,'%textcol%')
  19. draw_text('%Temperature%',tab,%offset%+1,'%font%',f_l,'%tempcol%',nil,CAIRO_FONT_WEIGHT_BOLD)
  20. --
  21. -- third column - wind
  22. --
  23. tab=%width%-%padding_h%-width5-width4-width3
  24. draw_svg_file('%wind_img%',tab+3,%offset%+3,36,36)
  25. draw_text('%WindSpeedUnit% %WindCompass8%',tab,%offset%+o_r2,'%font%',f_s,'%textcol%',nil,nil,"right")
  26. draw_text('%WindSpeedMS%',tab,%offset%+1,'%font%',f_l,'%textcol%',nil,CAIRO_FONT_WEIGHT_BOLD,"right")
  27. --
  28. -- fourth column - Precipitation
  29. --
  30. tab=%width%-%padding_h%-width5-width4
  31. if string.len("%popbg%") > 2 then
  32. draw_box(tab,%offset%+4,width4,22,'%popbg%')
  33. end
  34. draw_text('%PoP%',tab,%offset%+1,'%font%',f_l,'%popcol%',nil,CAIRO_FONT_WEIGHT_BOLD)
  35. -- drawing text + backgroundbox + bar, alpha depends on PoP
  36. precipmm=tonumber("%Precipitation1h%")
  37. w = draw_text('%Precipitation1h%mm',tab,%offset%+o_r2,'%font%',f_s,'%textcol%',precipmm*2+0.25)
  38. draw_box(tab,%offset%+o_r2+f_s+1,w+1,7,'%textcol%',0.2)
  39. draw_box(tab,%offset%+o_r2+f_s+2,precipmm*20,6,'%popcol%')
  40. --
  41. -- last column: time and weekday
  42. --
  43. tab=%width%-%padding_h%-width5
  44. draw_text('%localtime%',%width%-%padding_h%,%offset%,'%font%',f_l,'%linecol%',0.5,CAIRO_FONT_WEIGHT_BOLD,"right")
  45. if string.len("%day%") > 0 then
  46. draw_text('%day%',%width%-%padding_h%-1,%offset%+20,'%font%',f_l,'%linecol%',0.5,CAIRO_FONT_WEIGHT_BOLD,"right")
  47. end