forked from info-beamer/package-conference-room
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfancy.lua
More file actions
108 lines (86 loc) · 2.64 KB
/
fancy.lua
File metadata and controls
108 lines (86 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
local max = math.max
local min = math.min
local cos = math.cos
local sin = math.sin
local exp = math.exp
local PUSH = gl.pushMatrix
local POP = gl.popMatrix
local PI = math.pi
local RADTODEG = 180.0 / 3.14159265359
local DEGTORAD = 3.14159265359 / 180.0
local ROT1 = RADTODEG * PI
local SHOW_QUERULANT = true
local QSIZE = 0.12
local QPOSX, QPOSY = 0.4, 0.3 -- querulant base position [(0,0) = center, (1,1) = bottom right corner]
local QMOVESCALE = 0.20
local QROTSPEED = 1.0
local fancy = {}
----------------------------------------------
-- utils
local function chaos(t)
return (exp(sin(t*0.22))*exp(cos(t*0.39))*sin(t*0.3));
end
local function rotaterad(a, ...)
gl.rotate(RADTODEG * a, ...)
end
local function rotate1(a, ...) -- 0.5 = half rotation, 1 = full rotation
gl.rotate(ROT1 * a, ...)
end
----------------------------------------------
-- querulant
local function queruPos(t)
local dx = chaos(t * PI)
local dy = chaos(t * -1.3)
return QPOSX + QMOVESCALE * dx, QPOSY + QMOVESCALE * dy
end
local function drawQueru(now)
local ox, oy, x, y = 0.012, 0.01, queruPos(now)
local s = 1.05
-- shadow
-- PUSH()
-- gl.translate(x+ox, y+oy)
-- rotate1(QROTSPEED *now, 0, 0, 1)
-- gl.scale(s, s, s)
-- gl.translate(QSIZE/-2, QSIZE/-2) -- center rotation point
-- Resources.shadow:draw(0,0,QSIZE,QSIZE)
-- POP()
-- querulant
PUSH()
gl.translate(x,y)
rotate1(QROTSPEED * now, 0, 0, 1)
gl.translate(QSIZE/-2, QSIZE/-2) -- center rotation point
Resources.fancy_bgcolor:draw(0,0,QSIZE,QSIZE)
POP()
end
----------------------------------------------
-- modes: "minimal", "full".
function fancy.render(mode)
local now = sys.now()
if mode == "minimal" then
Resources.fancy_minimalbg:draw(0, 0, WIDTH, HEIGHT)
-- TODO: draw minimal animation
elseif mode == "full" then
Resources.fancy_bgcolor:draw(0, 0, WIDTH, HEIGHT)
local fov = math.atan2(HEIGHT, WIDTH*2) * 360 / math.pi
gl.perspective(fov, WIDTH/2, HEIGHT/2, -WIDTH,
WIDTH/2, HEIGHT/2, 0)
gl.translate(WIDTH/2, HEIGHT/2)
gl.scale(WIDTH * (1/NATIVE_ASPECT), HEIGHT)
if fancy.fixaspect then
fancy.fixaspect()
end
-- TODO: draw fancy animation
end
-- TODO: draw common animation
if SHOW_QUERULANT then
gl.ortho()
gl.translate(WIDTH/2, HEIGHT/2)
gl.scale(WIDTH * (1/NATIVE_ASPECT), HEIGHT)
if fancy.fixaspect then
fancy.fixaspect()
end
drawQueru(now)
end
end
----------------------------------------------
return fancy