예제 #1
0
 def draw_pattern(self):
     path = './patterns/' + self.pattern
     lines, ellipses, rectangles, polygons = get_picture.read_file(path)
     x, y = self.get_start_pattern(lines, ellipses, rectangles, polygons)
     if len(lines) != 0:
         for line in lines:
             points, pencil = get_picture.get_inf_line(line)
             new_points = self.get_new_points(points, [], x, y)
             self.draw_line(new_points, pencil)
     if len(ellipses) != 0:
         for ellipse in ellipses:
             points, width, height,\
              pencil, fill = get_picture.get_inf_ellipse(ellipse)
             new_points = self.get_new_points(points, [], x, y)
             width = width * self.figure_size / 180
             height = height * self.figure_size / 180
             self.draw_ellipse(new_points, width, height, pencil, fill)
     if len(rectangles) != 0:
         for rectangle in rectangles:
             points, width, height,\
              pencil, fill = get_picture.get_inf_rectangle(rectangle)
             new_points = self.get_new_points(points, [], x, y)
             width = width * self.figure_size / 180
             height = height * self.figure_size / 180
             self.draw_rectangle(new_points, width, height, pencil, fill)
     if len(polygons) != 0:
         for polygon in polygons:
             polygon, pencil, fill = get_picture.get_inf_polygon(polygon)
             newpolygon = self.get_new_points(polygon, QPolygonF(), x, y)
             self.draw_polygon(newpolygon, pencil, fill)
예제 #2
0
 def test_get_inf_triangle(self):
     polygon, pencil, fill = g.get_inf_polygon(self.polygons[1])
     self.assertEqual(polygon[0].x(), 110)
     self.assertEqual(polygon[0].y(), 140)
     self.assertEqual(polygon[1].x(), 125)
     self.assertEqual(polygon[1].y(), 167)
     self.assertEqual(polygon[2].x(), 94)
     self.assertEqual(polygon[2].y(), 167)
     self.assertEqual(pencil, '#000000')
     self.assertEqual(fill, '#FFFFFF')
예제 #3
0
 def test_get_inf_pentagon(self):
     polygon, pencil, fill = g.get_inf_polygon(self.polygons[0])
     self.assertEqual(polygon[0].x(), 851)
     self.assertEqual(polygon[0].y(), 280)
     self.assertEqual(polygon[1].x(), 965)
     self.assertEqual(polygon[1].y(), 362)
     self.assertEqual(polygon[2].x(), 921)
     self.assertEqual(polygon[2].y(), 497)
     self.assertEqual(polygon[3].x(), 780)
     self.assertEqual(polygon[3].y(), 497)
     self.assertEqual(polygon[4].x(), 736)
     self.assertEqual(polygon[4].y(), 362)
     self.assertEqual(pencil, '#000000')
     self.assertEqual(fill, '#FFFFFF')
예제 #4
0
 def upload_picture(self, filename):
     lines, ellipses,\
      rectangles, polygons = get_picture.read_file(filename)
     if len(lines) != 0:
         for line in lines:
             points, pencil = get_picture.get_inf_line(line)
             self.draw_line(points, pencil)
     if len(ellipses) != 0:
         for ellipse in ellipses:
             points, width, height,\
              pencil, fill = get_picture.get_inf_ellipse(ellipse)
             self.draw_ellipse(points, width, height, pencil, fill)
     if len(rectangles) != 0:
         for rectangle in rectangles:
             points, width, height,\
              pencil, fill = get_picture.get_inf_rectangle(rectangle)
             self.draw_rectangle(points, width, height, pencil, fill)
     if len(polygons) != 0:
         for polygon in polygons:
             polygon, pencil, fill = get_picture.get_inf_polygon(polygon)
             self.draw_polygon(polygon, pencil, fill)
예제 #5
0
 def get_start_pattern(self, lines, ellipses, rectangles, polygons):
     minx = 1000
     miny = 700
     if len(lines) != 0:
         for line in lines:
             points, pencil = get_picture.get_inf_line(line)
             minx, miny = self.get_minx_miny(minx, miny, points)
     if len(ellipses) != 0:
         for ellipse in ellipses:
             points, width, height, \
              pencil, fill = get_picture.get_inf_ellipse(ellipse)
             minx, miny = self.get_minx_miny(minx, miny, points)
     if len(rectangles) != 0:
         for rectangle in rectangles:
             points, width, height, \
              pencil, fill = get_picture.get_inf_rectangle(rectangle)
             minx, miny = self.get_minx_miny(minx, miny, points)
     if len(polygons) != 0:
         for polygon in polygons:
             polygon, pencil, fill = get_picture.get_inf_polygon(polygon)
             minx, miny = self.get_minx_miny(minx, miny, polygon)
     x = self.clicked[0].x() - minx
     y = self.clicked[0].y() - miny
     return (x, y)