def DrawTransform(self, xf): """ Draw the transform xf on the screen """ p1 = xf.position p2 = self.to_screen(p1 + self.axisScale * xf.R.x_axis) p3 = self.to_screen(p1 + self.axisScale * xf.R.y_axis) p1 = self.to_screen(p1) cv2.line(self.surface, cvcoord(p1), cvcoord(p2), (0, 0, 255), 1) cv2.line(self.surface, cvcoord(p1), cvcoord(p3), (0, 255, 0), 1)
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))
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)
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)
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))
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)