test12.nim 779 B

1234567891011121314151617181920212223242526272829
  1. # --- Test 12. Label node. --- #
  2. import nodesnim
  3. var
  4. window = newWindow("hello world", 640, 360)
  5. main: SceneObj
  6. main_scene = Scene("Main", main)
  7. labelobj: LabelObj
  8. label = Label(labelobj)
  9. main_scene.addChild(label)
  10. label.resize(256, 256)
  11. # You can change label text
  12. label.text = "Hello, world"
  13. # `color` is the font color.
  14. label.color = Color(1, 0.6, 1)
  15. # `background_color` is the background color ... :)
  16. label.background_color = Color(1, 0.6, 1, 0.4)
  17. # You can set text align inside the Label.
  18. label.text_align = Anchor(0.5, 0.5, 0.5, 0.5)
  19. # You can also do not set your font, as nodesnim has a default font.
  20. label.fontdata = openFont("assets/GNUUnifont9FullHintInstrUCSUR.ttf", 16)
  21. window.setMainScene(main_scene)
  22. window.launch()