Skip to content

Commit

Permalink
fixed wrong orientation of pixels when returning the cached version.
Browse files Browse the repository at this point in the history
  • Loading branch information
petteramland committed Nov 27, 2024
1 parent 6e9efcc commit e43f914
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ursina/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def pixels(self):
from ursina.array_tools import rotate_2d_list

if self._cached_image:
return Array2D(data=asarray(self._cached_image))
return Array2D(data=rotate_2d_list(asarray(self._cached_image)))

pixels = asarray(Image.open(self.path))
pixels = rotate_2d_list(pixels)
Expand Down Expand Up @@ -197,7 +197,7 @@ def __repr__(self):
A texture file can be a .png, .jpg or .psd.
If it's a .psd it and no compressed version exists, it will compress it automatically.
'''
e = Entity(model='quad', texture='brick')
e = Entity(model='quad', texture='test_tileset')
e.texture.set_pixel(0, 2, color.blue)
e.texture.apply()
#
Expand Down Expand Up @@ -241,16 +241,17 @@ def input(key):
for key, value in texture_importer.imported_textures.items():
print(key, value)

e.texture = 'brick'
e.texture = 'test_tileset'
# e.texture.set_pixels([e for e in e.texture.get_pixels()])
e.texture.apply()

tex = Texture.new((512,512), (255,0,0))
# tex = Texture.new((512,512), (255,0,0))

pixels = e.texture.pixels
new_grid = Array2D(width=pixels.width, height=pixels.height)
print('w:', pixels.width, 'h:', pixels.height)
for (x,y), value in enumerate_2d(pixels):
new_grid[x][y] = int(color.rgba32(*value).v > .5)

print(new_grid)
# print(new_grid)
app.run()

0 comments on commit e43f914

Please sign in to comment.