test8.nim 699 B

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