new 4475edb243ed4627f4c5f2c470ca40b3def034d4
[tagua/yd.git] / data / themes / controls / Cool / theme.lua
blob6750b25fd49a5eea7fc1b610842b8b4e0979722a
1 import("piece_theme.lua")
4 theme.options = OptList {
5 BoolOpt("wallpaper", "Draw wallpaper", true, OptList {
6 BoolOpt("blur", "Enable blur", false),
7 UrlOpt("file", "File:", "../../wallpapers/Paris_by_Night.jpg")
8 }),
9 FontOpt("clock_font1", "Clock text font", Font("Sans", true, true)),
10 FontOpt("clock_font2", "Clock time font", Font("Sans", true, false)),
11 FontOpt("border_font", "Border font", Font("Sans", false, false))
14 local border_ratio = 0.67
15 local clock_ratio = 2.6
16 local clock_height_ratio = 0.4
17 local clock_border_ratio = 0.33
18 local pool_width = 3
19 local pool_piece_ratio = clock_ratio/pool_width
20 local border_text_near = 0.0
21 local border_text_far = 0.5
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 function addShadow(i, size)
53 local s = i:create_shadow( size, "#ffffff", Point(0, 0), Point(0, 0) )
54 s:draw_image(Rect(0, 0, i.width, i.height), i)
55 return s
56 end
58 theme.border = function(b, args)
59 local rb = math.floor(b*2/3);
60 local w = args.width;
61 local h = args.height;
62 local tr = Image(b, b); tr:clear(); tr:draw_svg(Rect(0,b-rb,rb,rb), "border_corner.svg"); tr = addShadow(tr, b/5)
63 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)
64 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)
65 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)
66 local t = Image(w, b); t:clear(); t:draw_svg(Rect(0,b-rb,w,rb), "border_top.svg"); t = addShadow(t, b/5)
67 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)
68 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)
69 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)
70 return {
71 [Rect(-b,-b,b,b)] = tl,
72 [Rect(w,-b,b,b)] = tr,
73 [Rect(-b,h,b,b)] = bl,
74 [Rect(w,h,b,b)] = br,
75 [Rect(0,-b,w,b)] = t,
76 [Rect(0,h,w,b)] = bt,
77 [Rect(-b,0,b,h)] = l,
78 [Rect(w,0,b,h)] = r
80 end
82 theme.border_color = function()
83 return "black";
84 end
86 theme.border_font = function()
87 return theme.options.border_font.value;
88 end
90 theme.wallpaper = function()
91 if(theme.options.wallpaper.value) then
92 local i = Image(theme.options.wallpaper.sub_options.file.value, false)
93 if(theme.options.wallpaper.sub_options.blur.value) then
94 i:exp_blur(5);
95 end
96 return i
97 else
98 return nil
99 end
102 function create_clock(file, col)
103 return function(w)
104 local h = math.floor(w*clock_height_ratio)
105 local i = Image(w,h)
106 i:clear()
107 i:draw_svg(Rect(0,0,w,h), file)
108 local s = i:create_shadow( w/16, col, Point(math.floor(w/7), math.floor(w/7)), Point(0, 0) )
109 s:draw_image(Rect(math.floor(w/14), math.floor(w/14), i.width, i.height), i)
110 return s
114 theme.clock_active_background = create_clock("active_clock.svg", "#ff8080")
115 theme.clock_inactive_background = create_clock("inactive_clock.svg", "#e0e0e0")
117 theme.clock_active_text = function(size)
118 return Brush("#000000")
121 theme.clock_inactive_text = function(size)
122 return Brush("#808080")
125 theme.clock_background_offset = function(w)
126 local d = math.floor(w/14)
127 return Point(-d, -d)
130 theme.clock_height = function(w)
131 return math.floor(w*clock_height_ratio)
134 theme.clock_caption_rect = function(w)
135 local h = math.floor(w*clock_height_ratio)
136 return Rect(w*0.02, h*0.22, w*0.4, h*0.38)
139 theme.clock_time_rect = function(w)
140 local h = math.floor(w*clock_height_ratio)
141 return Rect(w*0.4, h*0.1, w*0.6, h*0.62)
144 theme.clock_player_rect = function(w)
145 local h = math.floor(w*clock_height_ratio)
146 return Rect(w*0.14, h*0.68, w*0.69, h*0.28)
149 theme.clock_caption_font = function()
150 return theme.options.clock_font1.value;
153 theme.clock_time_font = function()
154 return theme.options.clock_font2.value;
157 theme.clock_player_font = function()
158 return theme.options.clock_font1.value;