PiotrMachowski / Python-package-vacuum-map-parser-roborock

Apache License 2.0
1 stars 2 forks source link

Writing the room name on the map #3

Open Lash-L opened 9 months ago

Lash-L commented 9 months ago

https://github.com/PiotrMachowski/Python-package-vacuum-map-parser-roborock/blob/e64108c71db888b1208786181084b63478acc914/src/vacuum_map_parser_roborock/map_data_parser.py#L222

Hey @PiotrMachowski - today I've been spending some time trying to get the names on the map.

I do this:

    for room_id, room in parsed_map.rooms.items():
        room.name = self.coordinator.room_mapping.get(room_id, "Unknown")
    self.parser._image_generator._draw_room_names(parsed_map)

But the issue is that draw_room_names expects room to have a pos_x and pos_y - instead it just has a x0,x1,y0,y1. How can I get that/ calculate that?

PiotrMachowski commented 9 months ago

pos_x, pos_y are coordinates of desired center of a label. You can use pos_x = (x0 + x1)/2 and pos_y = (y0 + y1)/2

PiotrMachowski commented 9 months ago

Are you sure you want to draw room names on the map? Have you figured out if there are any available fonts?

Lash-L commented 9 months ago

Why would i not want to out of curiosity? This is what I currently have

Screenshot 2023-11-19 at 1 20 45 PM
PiotrMachowski commented 9 months ago

Which font do you use?

Lash-L commented 9 months ago

Which font do you use?

I did not set a font - so I guess the default?

PiotrMachowski commented 9 months ago

The last time I have checked default font didn't support any special characters and it wasn't scalable. Your font seems to look much better though, maybe I'd need to check it again if there have been any upgrades in this field.

Lash-L commented 9 months ago

Interesting - I'll look into the scaling issue later. I was just trying to see proof of concept how it worked. Will be a few days before I actually fully implement it as it will need a PR in your repo as well to not access the private attributes.

PiotrMachowski commented 9 months ago

Can you check if special characters are supported? ĄąÈÉóÔŁź etc

Lash-L commented 9 months ago

Ah - nope they are not

PiotrMachowski commented 9 months ago

Yeah, because of that I wouldn't add this feature to the official integration

Lash-L commented 9 months ago

Is the limitation in a underlying package or home assistant? I could perhaps try to find if I could access home assistants fonts if that would help

PiotrMachowski commented 9 months ago

This is a limitation of a default font built into Pillow library. It is possible to use system fonts, but last time I checked HA image didn't contain any built-in fonts.

Retrieving fonts:

fc-list | grep ttf | sed "s/.*\///"| sed "s/ttf.*/ttf/"