N
N
NeoLight32020-07-03 23:21:35
Python
NeoLight3, 2020-07-03 23:21:35

How to draw a dot on top of an Image by coordinates in Python?

Using the TCP / IP protocol, the Unity game server passed 2 variables, x and z, to the Python bot. (player coordinates)
Floats.
How can you draw the corresponding point on a png image using these 2 coordinates?

PS the maximum value for the X coordinate = 1015.635
and the maximum value for the Z coordinate = 1015.442

The picture is 1015 by 1015 pixels.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-07-03
@hottabxp

How to draw a dot on top of an Image by coordinates in Python?

pip install Pillow
from PIL import Image, ImageDraw

img = Image.open("1.png")  
draw = ImageDraw.Draw(img)
draw.point((10, 10),fill='red') # Рисуем красную точку по координатам 10x10
img.show()
img.save('2.png')

Are the x and z coordinates correct?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question