diff tests/test_font.nim @ 1139:114f395b9144

did: finish refactoring and updated all tests accordingly
author sam <sam@basx.dev>
date Sat, 08 Jun 2024 14:58:25 +0700
parents 02e1d2658ff5
children
line wrap: on
line diff
--- a/tests/test_font.nim	Tue Jun 04 22:08:48 2024 +0700
+++ b/tests/test_font.nim	Sat Jun 08 14:58:25 2024 +0700
@@ -11,10 +11,10 @@
 
   # build scene
   var scene = Scene(name: "main")
-  var font = loadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32)
-  var origin = initPanel(transform = Scale(0.01, 0.01))
-  var main_text = font.initText("".toRunes, maxLen = 255, color = NewVec4f(1, 0.15, 0.15, 1), maxWidth = 1.0, transform = Scale(0.0005, 0.0005))
-  var help_text = font.initText("""Controls
+  var font = LoadFont("DejaVuSans.ttf", lineHeightPixels = 210'f32)
+  var origin = InitPanel(transform = Scale(0.01, 0.01))
+  var main_text = font.InitText("".toRunes, maxLen = 255, color = NewVec4f(1, 0.15, 0.15, 1), maxWidth = 1.0, transform = Scale(0.0005, 0.0005))
+  var help_text = font.InitText("""Controls
 
 Horizontal alignment:
   F1: Left
@@ -24,16 +24,16 @@
   F4: Top
   F5: Center
   F6: Bottom""".toRunes, horizontalAlignment = Left, verticalAlignment = Top, transform = Translate(-0.9, -0.9) * Scale(0.0002, 0.0002))
-  scene.add origin
-  scene.add main_text
-  scene.add help_text
+  scene.Add origin
+  scene.Add main_text
+  scene.Add help_text
   engine.LoadScene(scene)
   mixer[].LoadSound("key", "key.ogg")
   mixer[].SetLevel(0.5)
 
   while engine.UpdateInputs() and not KeyIsDown(Escape):
     var t = cpuTime()
-    main_text.color = NewVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1)
+    main_text.Color = NewVec4f(sin(t) * 0.5 + 0.5, 0.15, 0.15, 1)
 
     # add character
     if main_text.text.len < main_text.maxLen - 1:
@@ -66,11 +66,11 @@
     elif KeyWasPressed(F5): main_text.verticalAlignment = Center
     elif KeyWasPressed(F6): main_text.verticalAlignment = Bottom
 
-    origin.refresh()
+    origin.Refresh()
     main_text.text = main_text.text & Rune('_')
-    main_text.refresh()
+    main_text.Refresh()
     main_text.text = main_text.text[0 ..< ^1]
-    help_text.refresh()
+    help_text.Refresh()
     engine.RenderScene(scene)
   engine.Destroy()