diff options
Diffstat (limited to 'demo/vector/main.lua')
-rw-r--r-- | demo/vector/main.lua | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/demo/vector/main.lua b/demo/vector/main.lua new file mode 100644 index 0000000..595131b --- /dev/null +++ b/demo/vector/main.lua @@ -0,0 +1,50 @@ +require 'common' + +local window = honey.window +local nvg = honey.nvg + + +local vg + +function honey.init() + vg = nvg.Context() +end + + +local time = 0 +local frames = 0 +function honey.update(dt) + if window.getKey(window.win, window.KEY_ESCAPE) == window.PRESS then + window.setShouldClose(honey.window.win, true) + end + + time = time + dt + frames = frames + 1 + if time > 5 then + print('fps:', frames/5) + frames = 0 + time = time - 5 + end +end + + +function honey.draw() + nvg.BeginFrame(vg, 640, 480, 1.0) + nvg.StrokeWidth(vg, 20) + nvg.StrokeColor(vg, 1, 0, 0, 1) + + local w = 640 + local h = 480 + + nvg.BeginPath(vg) + nvg.MoveTo(vg, w*0.2, h*.5) + nvg.LineTo(vg, w*0.4, h * (0.5 + 0.5*math.sin(math.pi * time))); + nvg.LineTo(vg, w*0.6, h * (0.5 - 0.5*math.sin(math.pi * time))); + nvg.LineTo(vg, w*0.8, h*.5) + nvg.Stroke(vg) + + nvg.EndFrame(vg) +end + + +honey.run() |