Ejemplo n.º 1
0
    async def debug_text(self,
                         texts: Union[str, list],
                         positions: Union[list, set],
                         color=(0, 255, 0),
                         size_px=16):
        """ Deprecated, may be removed soon """
        if isinstance(positions, (set, list)):
            if not positions:
                return

            if isinstance(texts, str):
                texts = [texts] * len(positions)
            assert len(texts) == len(positions)

            await self._execute(debug=sc_pb.RequestDebug(debug=[
                debug_pb.DebugCommand(draw=debug_pb.DebugDraw(text=[
                    debug_pb.DebugText(
                        text=t,
                        color=debug_pb.Color(
                            r=color[0], g=color[1], b=color[2]),
                        world_pos=common_pb.Point(
                            x=p.x, y=p.y, z=getattr(p, "z", 10)),
                        size=size_px) for t, p in zip(texts, positions)
                ]))
            ]))
        else:
            await self.debug_text([texts], [positions], color)
Ejemplo n.º 2
0
 def to_proto(self):
     return debug_pb.DebugText(
         color=self.to_debug_color(self._color),
         text=self._text,
         virtual_pos=None,
         world_pos=self.to_debug_point(self._start_point),
         size=self._font_size,
     )
Ejemplo n.º 3
0
    def to_debug_message(
        self, text: str, color=None, pos: Optional[Union[Point2, Point3]] = None, size: int = 8
    ) -> debug_pb.DebugText:
        """ Helper function to create debug texts """
        color = self.to_debug_color(color)
        pt3d = self.to_debug_point(pos) if isinstance(pos, Point3) else None
        virtual_pos = self.to_debug_point(pos) if not isinstance(pos, Point3) else None

        return debug_pb.DebugText(color=color, text=text, virtual_pos=virtual_pos, world_pos=pt3d, size=size)
Ejemplo n.º 4
0
    async def debug_text(self, texts, positions, color=(0, 255, 0)):
        if isinstance(positions, list):
            if not positions:
                return

            if isinstance(texts, str):
                texts = [texts] * len(positions)
            assert len(texts) == len(positions)

            await self._execute(debug=sc_pb.RequestDebug(
                debug=[debug_pb.DebugCommand(draw=debug_pb.DebugDraw(
                    text=[debug_pb.DebugText(
                        text=t,
                        color=debug_pb.Color(r=color[0], g=color[1], b=color[2]),
                        world_pos=common_pb.Point(x=p.x, y=p.y, z=p.z)
                    ) for t, p in zip(texts, positions)]
                ))]
            ))
        else:
            await self.debug_text([texts], [positions], color)