test8.nim 602 B

12345678910111213141516171819202122232425
  1. # --- Test 8. Use TextureRect node. --- #
  2. import nodesnim
  3. Window("hello world")
  4. var
  5. main = Scene("Main")
  6. texturerect = TextureRect()
  7. main.addChild(texturerect)
  8. var texture = load("assets/sharp.jpg") # Load image from file.
  9. texturerect.setTexture(texture)
  10. texturerect.resize(256, 256)
  11. texturerect.setBackgroundColor(Color(1, 0.6, 1, 0.6))
  12. texturerect.setTextureFilter(Color(1f, 1f, 1f))
  13. texturerect.texture_mode = TEXTURE_KEEP_ASPECT_RATIO # Can be also TEXTURE_CROP or TEXTURE_FILL_XY
  14. texturerect.texture_anchor = Anchor(0.5, 1, 0.5, 1)
  15. addScene(main)
  16. setMainScene("Main")
  17. windowLaunch()