Mercurial > games > semicongine
diff tests/test_text.nim @ 1238:03634915bbdb
add: tests for updating texts, does not pass validation atm
author | sam <sam@basx.dev> |
---|---|
date | Sun, 21 Jul 2024 11:31:11 +0700 |
parents | 97813ac43cfb |
children | 69489a678141 |
line wrap: on
line diff
--- a/tests/test_text.nim Sun Jul 21 00:03:48 2024 +0700 +++ b/tests/test_text.nim Sun Jul 21 11:31:11 2024 +0700 @@ -1,4 +1,5 @@ import std/os +import std/strutils import std/sequtils import std/monotimes import std/times @@ -48,7 +49,7 @@ renderdata, pipeline.descriptorSetLayouts[0], font1, - "0", + " 0", color = NewVec4f(0, 1, 1, 1), scale = 0.004, position = NewVec3f(-0.3, 0.5) @@ -57,7 +58,7 @@ renderdata, pipeline.descriptorSetLayouts[0], font2, - "1", + " 1", color = NewVec4f(1, 0, 1, 1), scale = 0.001, position = NewVec3f(0, 0) @@ -66,7 +67,7 @@ renderdata, pipeline.descriptorSetLayouts[0], font3, - "2", + " 2", color = NewVec4f(1, 1, 0, 1), scale = 0.001, position = NewVec3f(0.3, -0.5) @@ -74,15 +75,18 @@ ] var start = getMonoTime() + var p = 0 while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: let progress = ((getMonoTime() - start).inMilliseconds().int / 1000) / time for i in 0 ..< labels.len: var c = labels[i].Color c[i] = progress labels[i].Color = c - labels[i].Scale = labels[i].Scale * 1.002 + labels[i].Scale = labels[i].Scale * (1.0 + (i + 1).float * 0.001) labels[i].Position = labels[i].Position + NewVec3f(0.001 * (i.float - 1'f)) + labels[i].text = $(p + i) labels[i].Refresh(swapchain.GetAspectRatio()) + inc p WithNextFrame(swapchain, framebuffer, commandbuffer): WithRenderPass(swapchain.renderPass, framebuffer, commandbuffer, swapchain.width, swapchain.height, NewVec4f(0, 0, 0, 0)): WithPipeline(commandbuffer, pipeline):