test6.nim 723 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # --- Test 6. Anchor setting. --- #
  2. import nodesnim
  3. Window("hello world")
  4. var
  5. main = Scene("Main")
  6. lightblue = ColorRect()
  7. violet = ColorRect()
  8. main.addChild(lightblue)
  9. lightblue.addChild(violet)
  10. lightblue.resize(256, 128)
  11. lightblue.move(128, 64)
  12. violet.setAnchor( # Try to change it! ^^
  13. 0.5, # parent anchor at X-axis.
  14. 0.5, # parent anchor at Y-axis.
  15. 0.5, # anchor at X-axis.
  16. 0.5 # anchor at Y-axis.
  17. )
  18. lightblue.setAnchor(1, 1, 1, 1)
  19. lightblue.setSizeAnchor(
  20. 0, # size anchor at X-axis. If 0 then not used.
  21. 1 # size anchor at Y-axis. If 0 then not used.
  22. )
  23. lightblue.color = Color(0xaaccffff'u32)
  24. violet.color = Color(0xccaaffff'u32)
  25. addScene(main)
  26. setMainScene("Main")
  27. windowLaunch()