Esempio n. 1
0
    def DrawPolygon(self, vertices, color):
        """
        Draw a wireframe polygon given the screen vertices with the specified color.
        """
        if not vertices:
            return

        if len(vertices) == 2:
            cv2.line(self.surface, cvcoord(vertices[0]), cvcoord(vertices[1]), cvcolor(color), 1)
        else:
            pts = np.array(vertices, np.int32)
            pts = pts.reshape((-1,1,2))
            cv2.polylines(self.surface,[pts],True,cvcolor(color))
Esempio n. 2
0
    def DrawCircle(self, center, radius, color, drawwidth=1):
        """
        Draw a wireframe circle given the center, radius, axis of orientation and color.
        """
        radius *= self.zoom
        if radius < 1: radius = 1
        else: radius = int(radius)

        cv2.circle(self.surface, cvcoord(center), radius, cvcolor(color), drawwidth)
Esempio n. 3
0
    def DrawSolidPolygon(self, vertices, color):
        """
        Draw a filled polygon given the screen vertices with the specified color.
        """
        FILL = False

        if not FILL:
            self.DrawPolygon(vertices, color)
            return

        if not vertices:
            return

        if len(vertices) == 2:
            cv2.line(self.surface, cvcoord(vertices[0]), cvcoord(vertices[1]), cvcolor(color), 1)
        else:
            pts = np.array(vertices, np.int32)
            pts = pts.reshape((-1,1,2))
            cv2.fillPoly(self.surface, [pts], cvcolor(color))
Esempio n. 4
0
    def DrawAABB(self, aabb, color):
        """
        Draw a wireframe around the AABB with the given color.
        """
        points = [(aabb.lowerBound.x, aabb.lowerBound.y),
                  (aabb.upperBound.x, aabb.lowerBound.y),
                  (aabb.upperBound.x, aabb.upperBound.y),
                  (aabb.lowerBound.x, aabb.upperBound.y)]

        pts = np.array(points, np.int32)
        pts = pts.reshape((-1, 1, 2))
        cv2.polylines(self.surface, [pts], True, cvcolor(color))
Esempio n. 5
0
    def DrawSolidCircle(self, center, radius, axis, color):
        """
        Draw a solid circle given the center, radius, axis of orientation and color.
        """
        radius *= self.zoom
        if radius < 1: radius = 1
        else: radius = int(radius)

        FILL = False

        cv2.circle(self.surface, cvcoord(center), radius, cvcolor(color), -1 if FILL else 1)

        cv2.line(self.surface, cvcoord(center),
                               cvcoord((center[0] - radius*axis[0], center[1] + radius*axis[1])),
                               (0,0,255),
                               1)
Esempio n. 6
0
 def DrawSegment(self, p1, p2, color):
     """
     Draw the line segment from p1-p2 with the specified color.
     """
     cv2.line(self.surface, cvcoord(p1), cvcoord(p2), cvcolor(color), 1)