test8.nim 623 B

1234567891011121314151617181920212223242526
  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. # texture mode can be TEXTURE_CROP, TEXTURE_KEEP_ASPECT_RATIO or TEXTURE_FILL_XY
  14. texturerect.texture_mode = TEXTURE_CROP
  15. texturerect.texture_anchor = Anchor(0.5, 1, 0.5, 1)
  16. addScene(main)
  17. setMainScene("Main")
  18. windowLaunch()