test8.nim 678 B

123456789101112131415161718192021222324252627
  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. texturerect.texture_mode = TEXTURE_KEEP_ASPECT_RATIO # Can be also TEXTURE_CROP or TEXTURE_FILL_XY
  16. texturerect.texture_anchor = Anchor(0.5, 1, 0.5, 1)
  17. addScene(main)
  18. setMainScene("Main")
  19. windowLaunch()