Fix deserialization of shogi promotions.
[tagua/yd.git] / data / scripts / piece_theme.lua
blob530e80a1e02f2041418c15f3574f52c3b53f130c
2 function addShadow(func)
3 return function(size)
4 local isz = math.floor( size*100/(100+shadow_grow) + 0.5)
5 local offx = shadow_offset_x*isz/200
6 local offy = shadow_offset_y*isz/200
7 local i = func(isz)
8 local s = i:create_shadow( shadow*isz/100, shadow_color,
9 Point(size-isz, size-isz),
10 Point(offx, offy) )
11 s:draw_image(Rect((size-isz)/2-offx, (size-isz)/2-offy,isz,isz), i, Rect(0,0,isz,isz))
12 return s
13 end
14 end
16 function fromSVG_Direct(file)
17 return function(size)
18 local i = Image(size,size)
19 i:clear()
20 i:draw_svg(Rect(0,0,size,size), file)
21 return i
22 end
23 end
25 function fromSVG(file)
26 if shadow then
27 return addShadow(fromSVG_Direct(file))
28 else
29 return fromSVG_Direct(file)
30 end
31 end
33 function fromFontGlyph_Direct(...)
34 local t = (function(...) return ... end):partial(...)
35 return function(size)
36 local i = Image(size,size)
37 i:clear()
38 i:draw_glyph(Rect(0,0,size,size), t())
39 return i
40 end
41 end
43 -- function fromFontGlyph_Direct(file, glyph, fg, bg, border, draw_inner_bg)
44 -- return function(size)
45 -- local i = Image(size,size)
46 -- i:clear()
47 -- i:draw_glyph(Rect(0,0,size,size), file, glyph, fg, bg, border, draw_inner_bg)
48 -- return i
49 -- end
50 -- end
52 function fromFontGlyph(...)
53 if shadow then
54 return addShadow(fromFontGlyph_Direct(...))
55 else
56 return fromFontGlyph_Direct(...)
57 end
58 end
60 function fromPixmap(file)
61 return function(size)
62 local i = Image(size,size)
63 i:set_paint_over(false)
64 i:draw_image(Rect(0,0,size,size), file)
65 return i
66 end
67 end
69 function fromColor(color)
70 return function(size)
71 local i = Image(size,size)
72 i:clear(color)
73 return i
74 end
75 end
77 function overlay(func1,func2,...)
78 if func2 then
79 return overlay(function(size)
80 return func2(func1(size), size)
81 end, ...)
82 else
83 return func1
84 end
85 end