3

is there any simple way or code to make an isometric cube for 1 or more textures in python
for example, in Minecraft, the game takes two images grass_top.png and grass_side.png
enter image description hereenter image description here
and it draws it in the player's inventory like this enter image description here is there any script, API, or CLI tool that makes me do this in python and convert this into a pil image?
I want to iterate through every file and export this type of image.

B2-B
  • 69
  • 8
  • Perhaps you can do this using [PIL's capabilities](https://stackoverflow.com/questions/2563822/how-do-you-composite-an-image-onto-another-image-with-pil-in-python). – Alexey S. Larionov Jun 08 '21 at 09:45
  • ik that u can composite images but how do I make them look isometric, a guide that I read told me that I need to skew images to make it isometric but I can skew images in pil right? – B2-B Jun 08 '21 at 13:12
  • Yes, there's for example an `image.transform()` method, but it requires to put some thought into arguments, as you need to transform every pixel with coordinates `(x, y)` into another pair of coordinates. For this you pass 6 numbers - which are first two rows of a transformation matrix. You can use this [wiki article](https://en.wikipedia.org/wiki/Affine_transformation#Image_transformation) with basic examples of such matrices. Maybe [this](https://stackoverflow.com/questions/24191545/skewing-or-shearing-an-image-in-python) answer has a more easy way. – Alexey S. Larionov Jun 08 '21 at 13:19
  • The isometric transformation consists of a rotation and skewing if I recall, though I don't remember in which order (the order is important) – Alexey S. Larionov Jun 08 '21 at 13:20
  • @AlexeyLarionov is skimage fast if it is how can I skew with an angle, if skimage is not fast is there anyway I could do it in pil with angle – B2-B Jun 08 '21 at 15:21
  • I personally haven't used either, I'm just pointing you towards possibilities based on my intuition – Alexey S. Larionov Jun 08 '21 at 15:23
  • After all you can precompute your isometric images, save them as files and then draw you player's inventory from these images. It should be ok. If the images take a lot of storage you can resize them to be small, but still nicely looking from your inventory – Alexey S. Larionov Jun 08 '21 at 15:26

0 Answers0