main.wren 522 B

12345678910111213141516171819202122232425262728293031
  1. var width = 12
  2. var height = 12
  3. var image = []
  4. for (y in 0...height) {
  5. var row = []
  6. for (x in 0...width) {
  7. row.add(0)
  8. }
  9. image.add(row)
  10. }
  11. // «checkers»
  12. for (x in 0...width) {
  13. for (y in 0...height) {
  14. image[y][x] = (x + y) % 4
  15. }
  16. }
  17. // «end»
  18. // «print»
  19. System.print("P2") // the PGM header
  20. System.print("%(width) %(height)")
  21. System.print(3) // the maximum value which will appear
  22. for (y in 0...height) {
  23. for (x in 0...width) {
  24. System.write("%(image[y][x]) ")
  25. }
  26. System.print()
  27. }
  28. // «end»