Added support for directly blurring and image from lua (for wallpapers)
[kboard.git] / data / themes / Squares / Default / theme.lua
blob81190f16c9d4ce470a84cc39d7a154f703550d3d
1 import("../../Pieces/common.lua")
3 function theme.background(size)
4 local dark_square = Color("#6b829c")
5 local light_square = Color("#b8c0c0")
6 dark_square.a = 224
7 light_square.a = 224
8 local i = Image(size*2,size*2)
9 i:set_paint_over(false);
10 i:fill_rect(Rect(0,0,size,size), light_square)
11 i:fill_rect(Rect(size,0,size,size), dark_square)
12 i:fill_rect(Rect(0,size,size,size), dark_square)
13 i:fill_rect(Rect(size,size,size,size), light_square)
14 return i
15 end
17 function addShadow(i, size)
18 local s = i:create_shadow( size/6, "#ffffff", Point(0, 0), Point(0, 0) )
19 s:draw_image(Rect(0, 0, i.width, i.height), i)
20 return s
21 end
23 function theme.border(size)
24 local b = math.floor(size*2/3);
25 local rb = math.floor(b*2/3);
26 local s8 = size*8;
27 local tr = Image(b, b); tr:clear(); tr:draw_svg(Rect(0,b-rb,rb,rb), "corner.svg"); tr = addShadow(tr, size)
28 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)
29 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)
30 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)
31 local t = Image(s8, b); t:clear(); t:draw_svg(Rect(0,b-rb,s8,rb), "bar.svg"); t = addShadow(t, size)
32 local bt = Image(s8, b); bt:set_paint_over(false); bt:rotate(180); bt:translate(s8,b); bt:draw_image(Rect(0,0,s8,b), t)
33 local l = Image(b, s8); l:set_paint_over(false); l:rotate(270); l:translate(0,s8); l:draw_image(Rect(0,0,s8,b), t)
34 local r = Image(b, s8); r:set_paint_over(false); r:rotate(90); r:translate(b,0); r:draw_image(Rect(0,0,s8,b), t)
35 return {
36 [Rect(-b,-b,b,b)] = tl,
37 [Rect(s8,-b,b,b)] = tr,
38 [Rect(-b,s8,b,b)] = bl,
39 [Rect(s8,s8,b,b)] = br,
40 [Rect(0,-b,s8,b)] = t,
41 [Rect(0,s8,s8,b)] = bt,
42 [Rect(-b,0,b,s8)] = l,
43 [Rect(s8,0,b,s8)] = r
45 end
47 theme.wallpaper =
48 function(size)
49 local i
50 --i = Image("Wallpapers/autumn.jpg", false)
51 --i = Image("Wallpapers/winter.jpg", false)
52 --i = Image("Wallpapers/dragonballz.jpg", false)
53 i = Image("Wallpapers/Bled (nastja).jpg", false)
54 i:exp_blur(10);
55 return i
56 end
58 ratio = 2.6;
60 function create_clock(file)
61 return function(size)
62 local w = size*ratio
63 local h = math.floor(w*2/5)
64 local i = Image(w,h)
65 i:clear()
66 i:draw_svg(Rect(0,0,w,h), file)
67 local s = i:create_shadow( size/6, "#ffffff", Point(math.floor(size/2.5), math.floor(size/2.5)), Point(0, 0) )
68 s:draw_image(Rect(math.floor(size/5), math.floor(size/5), i.width, i.height), i)
69 return s
70 end
71 end
73 theme.clock_active_background = create_clock("active_clock.svg")
74 theme.clock_inactive_background = create_clock("inactive_clock.svg")
76 theme.clock_active_text = function(size)
77 return Brush("#000000")
78 end
80 theme.clock_inactive_text = function(size)
81 return Brush("#808080")
82 end
84 theme.clock_background_offset = function(size)
85 return Point(-math.floor(size/5), -math.floor(size/5))
86 end
88 theme.clock_height = function(size)
89 return math.floor((size*ratio)*2/5);
90 end
92 theme.clock_caption_rect = function(size)
93 local w = size*ratio
94 local h = math.floor(w*2/5)
95 return Rect(w*0.02, h*0.2, w*0.4, h*0.38)
96 end
98 theme.clock_time_rect = function(size)
99 local w = size*ratio
100 local h = math.floor(w*2/5)
101 return Rect(w*0.4, h*0.06, w*0.58, h*0.66)
104 theme.clock_player_rect = function(size)
105 local w = size*ratio
106 local h = math.floor(w*2/5)
107 return Rect(w*0.14, h*0.68, w*0.69, h*0.28)
110 theme.validmove = fromColor("#cd9eee")
111 theme.highlighting = fromPixmap("square_last.png")
112 theme.premove = fromPixmap("square_premove.png")
113 theme.selection = fromPixmap("square_select.png")
115 name = "Default"
116 description = "Default squares"
117 variants = { "Chess[default]", "Shogi", "XiangQi" }