new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / data / themes / controls / Google / theme_google.lua
blob9701e8f0173fb14173d6b9810e3a99127dd56cdd
1 import("piece_theme.lua")
4 theme.options = OptList {
5 BoolOpt("wallpaper", "Draw wallpaper", false, OptList {
6 BoolOpt("blur", "Enable blur", false),
7 UrlOpt("file", "File:", "../../wallpapers")
8 }),
9 FontOpt("clock_font1", "Clock text font", Font("Sans", false, true)),
10 FontOpt("clock_font2", "Clock time font", Font("Sans", false, false)),
11 FontOpt("border_font", "Border font", Font("Sans", false, false))
14 local border_ratio = 0.67
15 local clock_ratio = 2.8
16 local clock_height_ratio = 0.6
17 local clock_border_ratio = 0.16
18 local pool_width = 3
19 local pool_piece_ratio = clock_ratio/pool_width
20 local border_text_near = 0.05
21 local border_text_far = 0.6
23 theme.layout = function(args)
24 retv = {}
25 retv.square_size = math.floor(math.min(
26 args.width/(args.grid_size.x+2*border_ratio+clock_ratio+2*clock_border_ratio),
27 args.height/(args.grid_size.y+2*border_ratio) ) )
28 retv.border_size = math.floor(retv.square_size*border_ratio)
29 retv.border_text_near = math.floor(retv.border_size*border_text_near)
30 retv.border_text_far = math.floor(retv.border_size*border_text_far)
31 retv.clock_size = math.floor(retv.square_size*clock_ratio)
32 retv.pool_width = pool_width;
33 retv.pool_piece_size = math.floor(retv.square_size*pool_piece_ratio)
35 local d = Point(math.floor((args.width-retv.square_size*(args.grid_size.x+
36 2*border_ratio+clock_ratio+2*clock_border_ratio))/2),
37 math.floor((args.height-retv.square_size*(args.grid_size.y+2*border_ratio))/2));
38 local clock_border = math.floor(retv.square_size*clock_border_ratio)
39 local clock_height = math.floor(retv.clock_size*clock_height_ratio)
40 local panel_x = retv.square_size*args.grid_size.x + 2*retv.border_size + clock_border;
41 retv.board_position = d + Point(retv.border_size, retv.border_size)
42 retv.clock0_position = d + Point(panel_x, clock_border_ratio*retv.square_size)
43 retv.clock1_position = d + Point(panel_x, retv.square_size*args.grid_size.y + 2*retv.border_size
44 - clock_height - clock_border)
45 retv.pool0_position = Point(d.x + panel_x, retv.clock0_position.y+clock_height+clock_border);
46 retv.pool1_position = Point(d.x + panel_x, retv.clock1_position.y-clock_border);
48 return retv
49 end
52 theme.border = function(b, args)
53 b = math.floor(b*0.7)
54 local w = args.width;
55 local h = args.height;
56 local tr = Image(b, b); tr:clear(); tr:draw_svg(Rect(0,0,b,b), "border_corner.svg");
57 local tl = Image(b, b); tl:set_paint_over(false); tl:rotate(270); tl:translate(0,b); tl:draw_image(Rect(0,0,b,b), tr)
58 local bl = Image(b, b); bl:set_paint_over(false); bl:rotate(180); bl:translate(b,b); bl:draw_image(Rect(0,0,b,b), tr)
59 local br = Image(b, b); br:set_paint_over(false); br:rotate(90); br:translate(b,0); br:draw_image(Rect(0,0,b,b), tr)
60 local t = Image(w, b); t:clear(); t:draw_svg(Rect(0,0,w,b), "border_top.svg");
61 local bt = Image(w, b); bt:set_paint_over(false); bt:rotate(180); bt:translate(w,b); bt:draw_image(Rect(0,0,w,b), t)
62 local l = Image(b, h); l:set_paint_over(false); l:rotate(270); l:translate(0,h); l:draw_image(Rect(0,0,h,b), t)
63 local r = Image(b, h); r:set_paint_over(false); r:rotate(90); r:translate(b,0); r:draw_image(Rect(0,0,h,b), t)
64 return {
65 [Rect(-b,-b,b,b)] = tl,
66 [Rect(w,-b,b,b)] = tr,
67 [Rect(-b,h,b,b)] = bl,
68 [Rect(w,h,b,b)] = br,
69 [Rect(0,-b,w,b)] = t,
70 [Rect(0,h,w,b)] = bt,
71 [Rect(-b,0,b,h)] = l,
72 [Rect(w,0,b,h)] = r
74 end
76 theme.border_color = function()
77 return "#108060";
78 end
80 theme.border_font = function()
81 return theme.options.border_font.value;
82 end
84 theme.wallpaper = function()
85 if(theme.options.wallpaper.value) then
86 local i = Image(theme.options.wallpaper.sub_options.file.value, false)
87 if(theme.options.wallpaper.sub_options.blur.value) then
88 i:exp_blur(5);
89 end
90 return i
91 else
92 return {}
93 end
94 end
96 function create_clock(file, col)
97 return function(w)
98 local h = math.floor(w*clock_height_ratio)
99 local i = Image(w,h)
100 i:clear()
101 i:draw_svg(Rect(0,0,w,h), file)
102 return i
106 theme.clock_active_background = create_clock("active_clock.svg", "#ff8080")
107 theme.clock_inactive_background = create_clock("inactive_clock.svg", "#e0e0e0")
109 theme.clock_active_text = function(size)
110 return Brush("#000000")
113 theme.clock_inactive_text = function(size)
114 return Brush("#a0a0a0")
117 theme.clock_background_offset = function(w)
118 return Point()
121 theme.clock_height = function(w)
122 return math.floor(w*clock_height_ratio)
125 theme.clock_caption_rect = function(w)
126 local h = math.floor(w*clock_height_ratio)
127 return Rect(0, h*0.04, w, h*0.2)
130 theme.clock_time_rect = function(w)
131 local h = math.floor(w*clock_height_ratio)
132 return Rect(0, h*0.23, w, h*0.6)
135 theme.clock_player_rect = function(w)
136 local h = math.floor(w*clock_height_ratio)
137 return Rect(0, h*0.78, w, h*0.21)
140 theme.clock_caption_font = function()
141 return theme.options.clock_font1.value;
144 theme.clock_time_font = function()
145 return theme.options.clock_font2.value;
148 theme.clock_player_font = function()
149 return theme.options.clock_font1.value;