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")
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
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 for key
,value
in pairs(args
) do
25 print("args[",key
,"] = ",value
)
29 retv
.square_size
= math
.floor(math
.min(
30 args
.width
/(args
.grid_size
.x
+2*border_ratio
+clock_ratio
+2*clock_border_ratio
),
31 args
.height
/(args
.grid_size
.y
+2*border_ratio
) ) )
32 retv
.border_size
= math
.floor(retv
.square_size
*border_ratio
)
33 retv
.border_text_near
= math
.floor(retv
.border_size
*border_text_near
)
34 retv
.border_text_far
= math
.floor(retv
.border_size
*border_text_far
)
35 retv
.clock_size
= math
.floor(retv
.square_size
*clock_ratio
)
36 retv
.pool_width
= pool_width
;
37 retv
.pool_piece_size
= math
.floor(retv
.square_size
*pool_piece_ratio
)
39 local d
= Point(math
.floor((args
.width
-retv
.square_size
*(args
.grid_size
.x
+
40 2*border_ratio
+clock_ratio
+2*clock_border_ratio
))/2),
41 math
.floor((args
.height
-retv
.square_size
*(args
.grid_size
.y
+2*border_ratio
))/2));
42 local clock_border
= math
.floor(retv
.square_size
*clock_border_ratio
)
43 local clock_height
= math
.floor(retv
.clock_size
*clock_height_ratio
)
44 local panel_x
= retv
.square_size
*args
.grid_size
.x
+ 2*retv
.border_size
+ clock_border
;
45 retv
.board_position
= d
+ Point(retv
.border_size
, retv
.border_size
)
46 retv
.clock0_position
= d
+ Point(panel_x
, clock_border_ratio
*retv
.square_size
)
47 retv
.clock1_position
= d
+ Point(panel_x
, retv
.square_size
*args
.grid_size
.y
+ 2*retv
.border_size
48 - clock_height
- clock_border
)
49 retv
.pool0_position
= Point(d
.x
+ panel_x
, retv
.clock0_position
.y
+clock_height
+clock_border
);
50 retv
.pool1_position
= Point(d
.x
+ panel_x
, retv
.clock1_position
.y
-clock_border
);
56 function addShadow(i
, size
)
57 local s
= i
:create_shadow( size
, "#ffffff", Point(0, 0), Point(0, 0) )
58 s
:draw_image(Rect(0, 0, i
.width
, i
.height
), i
)
62 theme
.border
= function(b
, args
)
63 local rb
= math
.floor(b
*2/3);
65 local h
= args
.height
;
66 local tr
= Image(b
, b
); tr
:clear(); tr
:draw_svg(Rect(0,b
-rb
,rb
,rb
), "border_corner.svg"); tr
= addShadow(tr
, b
/5)
67 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
)
68 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
)
69 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
)
70 local t
= Image(w
, b
); t
:clear(); t
:draw_svg(Rect(0,b
-rb
,w
,rb
), "border_top.svg"); t
= addShadow(t
, b
/5)
71 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
)
72 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
)
73 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
)
75 [Rect(-b
,-b
,b
,b
)] = tl
,
76 [Rect(w
,-b
,b
,b
)] = tr
,
77 [Rect(-b
,h
,b
,b
)] = bl
,
86 theme
.border_color
= function()
90 theme
.border_font
= function()
91 return theme
.options
.border_font
.value
;
94 theme
.wallpaper
= function()
95 if(theme
.options
.wallpaper
.value
) then
96 local i
= Image(theme
.options
.wallpaper
.sub_options
.file
.value
, false)
97 if(theme
.options
.wallpaper
.sub_options
.blur
.value
) then
106 function create_clock(file
, col
)
108 local h
= math
.floor(w
*clock_height_ratio
)
111 i
:draw_svg(Rect(0,0,w
,h
), file
)
112 local s
= i
:create_shadow( w
/16, col
, Point(math
.floor(w
/7), math
.floor(w
/7)), Point(0, 0) )
113 s
:draw_image(Rect(math
.floor(w
/14), math
.floor(w
/14), i
.width
, i
.height
), i
)
118 theme
.clock_active_background
= create_clock("active_clock.svg", "#ff8080")
119 theme
.clock_inactive_background
= create_clock("inactive_clock.svg", "#e0e0e0")
121 theme
.clock_active_text
= function(size
)
122 return Brush("#000000")
125 theme
.clock_inactive_text
= function(size
)
126 return Brush("#808080")
129 theme
.clock_background_offset
= function(w
)
130 local d
= math
.floor(w
/14)
134 theme
.clock_height
= function(w
)
135 return math
.floor(w
*clock_height_ratio
)
138 theme
.clock_caption_rect
= function(w
)
139 local h
= math
.floor(w
*clock_height_ratio
)
140 return Rect(w
*0.02, h
*0.22, w
*0.4, h
*0.38)
143 theme
.clock_time_rect
= function(w
)
144 local h
= math
.floor(w
*clock_height_ratio
)
145 return Rect(w
*0.4, h
*0.1, w
*0.6, h
*0.62)
148 theme
.clock_player_rect
= function(w
)
149 local h
= math
.floor(w
*clock_height_ratio
)
150 return Rect(w
*0.14, h
*0.68, w
*0.69, h
*0.28)
153 theme
.clock_caption_font
= function()
154 return theme
.options
.clock_font1
.value
;
157 theme
.clock_time_font
= function()
158 return theme
.options
.clock_font2
.value
;
161 theme
.clock_player_font
= function()
162 return theme
.options
.clock_font1
.value
;