-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.lua
68 lines (58 loc) · 1.33 KB
/
test2.lua
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
local cm = require('codim')
-- local what = require('codim.what')
-- print(what)
local AnimQueue = require('animqueue')
cm.output{
file = 'out2.mp4',
sample_rate = 44100,
width = 600,
height = 400,
fps = 24
}
function s(x)
return x:sub(1, #x-1)
end
function insert(editor, text, start, letters_per_sec)
local times = {}
for i=0,#text-1 do
times[#times+1] = i/letters_per_sec
-- print(times[#times])
end
idx = 1
return AnimQueue{
sequential = true,
times = times,
onupdate = function(t)
editor:insert(text:sub(idx, idx))
idx = idx + 1
end
}
end
local r = cm.Renderer()
local text = cm.Text(40, "mono.ttf")
local editor = cm.Editor(text, 0, 300)
-- local model = editor:get_rd():get_model()
-- model:rotz(0.5)
r:add(editor)
local queue = editor:type(s[[
#include <hello.h>
int main() {
printf("codim is real.\n");
return 0;
}
]], 1.0, 10)
return {
video = function(t)
if end_t then
if t >= end_t then cm.stop() end
elseif queue:over() then
end_t = 1.0 + t
end
queue:update(t)
cm.clear(0.3, 0.4, 0.5, 0.0)
r:render()
end,
audio = function(t)
return 0, 0
end
}