Beispiel #1
0
 def test_change_center(self):
     """C-9. Verify center attribute change works."""
     expected = ((3, 4), 3)
     circle = Circle(Point(1, 2), 3)
     point1 = Point(3, 4)
     circle.center = point1
     self.assertEqual(circle_data(circle), expected)
Beispiel #2
0
 def mousePressEvent(self, event):   # отслеживание кликов по мыши и добавление фигуры в список
     if self.instrument == 'brush':
         self.objects.append([])
         self.objects[-1].append(BrushPoint(event.x(), event.y(), self.thickness, self.color))
         self.update()
     elif self.instrument == 'line':
         self.objects.append(Line(event.x(), event.y(), event.x(), event.y(), self.thickness, self.color))
         self.update()
     elif self.instrument == 'circle':
         self.objects.append(Circle(event.x(), event.y(), event.x(), event.y(), self.thickness, self.color))
         self.update()
     elif self.instrument == 'rubber':
         self.objects.append([])
         self.objects[-1].append(BrushPoint(event.x(), event.y(), self.thickness, QColor(240, 240, 240)))
         self.update()
     elif self.instrument == 'rect':
         self.objects.append(Rect(event.x(), event.y(), 0, 0, self.thickness, self.color))
         self.update()
     elif self.instrument == 'square':
         self.objects.append(Rect(event.x(), event.y(), 0, 0, self.thickness, self.color))
         self.update()
     elif self.instrument == 'triangle':
         self.objects.append(Triangle(event.x(), event.y(), event.x(), event.y(), self.thickness, self.color))
         self.update()
     elif self.instrument == 'sqtriangle':
         self.objects.append(SqTriangle(event.x(), event.y(), event.x(), event.y(), self.thickness, self.color))
         self.update()
Beispiel #3
0
 def test_move_center(self):
     """C-5A. Verify moving center Point of Circle works."""
     expected = ((6, 2), 1.5)
     point = Point(2, 3)
     circle = Circle(point, 1.5)
     point.x = 6
     point.y = 2
     self.assertEqual(circle_data(circle), expected)
Beispiel #4
0
 def setUp(self):
     self.init_kwargs = {}
     self.init_kwargs["xCoord"] = 50
     self.init_kwargs["yCoord"] = 50
     measurements = {"radius": 50}
     self.init_kwargs["measurements"] = measurements
     self.area = 3.14 * measurements["radius"]**2
     self.shape = Circle(**self.init_kwargs)
Beispiel #5
0
class TestUnitCircle(TestCircle):
    circle = Circle(1)

    def test_area(self):
        assert self.circle.get_area() == math.pi

    def test_perimeter(self):
        assert self.circle.perimeter == 2 * math.pi
Beispiel #6
0
 def test_properties(self):
     """Test circle properties"""
     c = Circle(d=12.0)
     self.assertAlmostEqual(c.A(), 113.097, places=2)
     self.assertAlmostEqual(c.I(), 1017.875, places=2)
     self.assertAlmostEqual(c.S(), 169.646, places=2)
     self.assertAlmostEqual(c.Z(), 288.000, places=2)
     self.assertAlmostEqual(c.r(), 3.0, places=2)
Beispiel #7
0
    def add_wafer_outline(self):        
        """
        Create Wafer Outline
        """
        outline=Cell('WAF_OLINE')
        for l in self.cell_layers:
            circ=Circle((0, 0), self.wafer_r, 100, layer=l)
            outline.add(circ)
#            outline.add(Disk(l, (0,0), self.wafer_r, self.wafer_r-10))
        self.add(outline)
Beispiel #8
0
class TestCircle(object):
    radius = 10
    circle = Circle(radius)

    def test_area(self):
        expected = math.pi * self.__class__.radius**2
        assert self.circle.get_area() == expected

    def test_perimeter(self):
        expected = 2 * math.pi * self.__class__.radius
        assert self.circle.perimeter == expected
def main():
    shapes: list = [
        Circle(5),
        Rectangle(3, 3),
        Rectangle(4, 4),
        Triangle(3, 4),
    ]

    for shape in shapes:
        logging.debug(
            "type: {0}, circumference = {1:.2f}, area = {2:.2f}".format(
                type(shape), shape.circumference(), shape.area()))
def main() -> None:
    shape1 = Rectangle(100, 200)
    shape2 = Square(100)
    shape3 = Circle(100)

    print('Shape1 surface: {}'.format(shape1.surface))
    print('Shape1 perimiter: {}'.format(shape1.perimeter))

    print('Shape2 surface: {}'.format(shape2.surface))
    print('Shape2 perimiter: {}'.format(shape2.perimeter))

    print('Shape3 surface: {}'.format(shape3.surface))
    print('Shape3 perimiter: {}'.format(shape3.perimeter))
Beispiel #11
0
def main():
    apoint = Point(x=100, y=80)
    bpoint = Point(x=160, y=200)
    cpoint = Point(x=220, y=80)
    circle = Circle(radius=10, point=apoint)
    triangle = Triangle(lines=[StraightLine(a=apoint, b=bpoint), StraightLine(a=apoint, b=cpoint),
                               StraightLine(a=bpoint, b=cpoint)])
    canvas1 = Canvas(250, 250, Point(x=200, y=200), "canvas1", [triangle, circle], show_cp=True)
    canvas2 = Canvas(260, 260, Point(x=450, y=450), "canvas2", [circle], show_cp=True)
    canvas3 = Canvas(270, 270, Point(x=710, y=710), "canvas3", [circle], show_cp=True)
    canvas_list = [canvas1, canvas2, canvas3]
    screen = TkinterScreen()
    screen.configure(canvas_list)
    board = Board(screen)
    board.draw_at()
Beispiel #12
0
 def __init__(self,
              x,
              y,
              radius,
              degree=150,
              scanning_max=360,
              scanning_min=0,
              scanning_mode="CIRCLE",
              origin="PERIMETER"):
     #TODO origin = CENTER is broken for rebroadcasting
     self.uuid = str(uuid.uuid4())
     self.x = x
     self.y = y
     self.radius = radius
     # for drawing
     self.colorDict = dict()
     self.lastColor = colour.Color("Blue")
     self.shape = Shape(center=(self.x, self.y))
     self.circle = Circle(self.radius * 2)
     # end drawing section
     self.rays = []
     self.vertex_list = None
     r_b = [
         color for color in colour.Color("Red").range_to(
             colour.Color("Green"), 120)
     ]
     b_g = [
         color for color in colour.Color("Green").range_to(
             colour.Color("Blue"), 120)
     ]
     g_r = [
         color for color in colour.Color("Blue").range_to(
             colour.Color("Red"), 120)
     ]
     self.colors = r_b + b_g + g_r
     self.energy = 0
     self.energy_color = None
     self.scanning_max = scanning_max
     self.scanning_min = scanning_min
     if degree > self.scanning_max:
         degree = self.scanning_max
     elif degree < self.scanning_min:
         degree = self.scanning_min
     self.degree = degree
     self.scanning_mode = scanning_mode
     #self.scanning_mode_options = ["CIRCLE", "RANDOM"]
     self.origin = origin
Beispiel #13
0
 def draw(self, shape):
     # Method drawing a shape on the canvas.
     self.__canvas.delete(self.__tmp_rendered)
     rendered_shape = None
     if shape['type'] == 'rectangle' and shape['mode'] == 'normal':
         rendered_shape = Rectangle(shape)
     elif shape['type'] == 'rectangle' and shape['mode'] == 'straight':
         rendered_shape = Square(shape)
     elif shape['type'] == 'oval' and shape['mode'] == 'normal':
         rendered_shape = Oval(shape)
     elif shape['type'] == 'oval' and shape['mode'] == 'straight':
         rendered_shape = Circle(shape)
     elif shape['type'] == 'line' and shape['mode'] == 'normal':
         rendered_shape = Line(shape)
     elif shape['type'] == 'line' and shape['mode'] == 'straight':
         rendered_shape = Diagonal(shape)
     shape_id = rendered_shape.draw_on(self.__canvas)
     return shape_id
Beispiel #14
0
    def addCircle(self,
                  xy=(0, 0),
                  diameter=None,
                  radius=None,
                  label="",
                  fc='none',
                  color='k',
                  lw=2,
                  mplprops={}):
        if diameter != None:
            diameter = self.cust_float(diameter)
        if radius != None:
            radius = self.cust_float(radius)

        circle = Circle.Circle(self.cust_float(xy), diameter, radius, label,
                               fc, color, lw, mplprops, self)
        self.drawOrder.append(circle)
        return circle
Beispiel #15
0
    def revolution_animate(self, ring='n'):
        """Function that makes the animation of moviment"""

        if ring == 'y':
            self.draw_ring()

        if self.__revolution_loop == self.__number_revolution:
            self.__revolution_loop = 0
        x = self.orbit_list[self.__revolution_loop].x
        y = self.orbit_list[self.__revolution_loop].y
        z = self.orbit_list[self.__revolution_loop].z

        if self.__mode == "2D":
            Circle(x, y, self.radius, self.__total).draw()

        else:
            Sphere(x, y, z, self.radius, self.__total, self.color).draw()

        self.__revolution_loop += 1
Beispiel #16
0
def createShapes():
    shapes = []
    for i in range(randint(5, 10)):
        v = randint(1, 4)
        x, y = randint(0, 700), randint(0, 700)
        length = randint(10, 100)
        width = randint(10, 100)
        colorChoice = COLORS[randint(0, len(COLORS) - 1)]

        if v == 1:
            pass
            shapes.append(Triangle((x, y), colorChoice, length))
        if v == 2:
            shapes.append(Rectangle((x, y), colorChoice, length, width))
        if v == 3:
            shapes.append(Square((x, y), colorChoice, length))
        if v == 4:
            shapes.append(Circle((x, y), colorChoice, length))

    return shapes
 def setUp(self):
     # do setup operations here for each test
     print("setUp")
     self.c1 = Circle(3, "red")
     self.c2 = Circle(5, "green")
Beispiel #18
0
 def test_circle_repr(self):
     """C-19. Verify Circle repr result."""
     expected = "Circle(center=Point(2.75, 3), radius=1.5)"
     point1 = Point(2.75, 3)
     circle = Circle(center=point1, radius=1.5)
     self.assertEqual(repr(circle), expected)
Beispiel #19
0
 def test_error_center_from_tuple_no_args(self):
     """C-24. Verify error using center_from_tuple with no arguments."""
     circle = Circle()
     with self.assertRaises(TypeError):
         circle.center_from_tuple()
Beispiel #20
0
 def test_error_change_diameter_lt_zero(self):
     """C-16. Verify error when changing diameter < 0."""
     circle = Circle()
     with self.assertRaises(ValueError):
         circle.diameter = -1
Beispiel #21
0
 def test_circle_str(self):
     """C-18. Verify Circle str result."""
     expected = "Circle with center at (2.75, 3) and radius 1.5"
     point1 = Point(2.75, 3)
     circle = Circle(center=point1, radius=1.5)
     self.assertEqual(str(circle), expected)
Beispiel #22
0
 def test_error_radius_lt_zero(self):
     """C-14. Verify error when creating a Circle with radius < 0."""
     with self.assertRaises(ValueError):
         Circle(center=Point(0, 0), radius=-1)
Beispiel #23
0
 def test_error_change_radius_lt_zero(self):
     """C-15. Verify error when changing radius < 0."""
     circle = Circle()
     with self.assertRaises(ValueError):
         circle.radius = -1
Beispiel #24
0
 def test_diameter_changes(self):
     """C-13. Verify diameter changes works."""
     circle = Circle(center=Point(4, 5), radius=3)
     circle.radius = 5
     expected = 10
     self.assertEqual(circle.diameter, expected)
Beispiel #25
0
 def test_diameter_property(self):
     """C-12. Verify diameter property works."""
     circle = Circle(center=Point(4, 5), radius=3)
     expected = 6
     self.assertEqual(circle.diameter, expected)
Beispiel #26
0
 def test_error_center_change_to_not_point(self):
     """C-11. Verify error if changing center to something not a Point."""
     circle = Circle(center=Point(3, 4), radius=2)
     with self.assertRaises(TypeError):
         circle.center = (3, 4)
Beispiel #27
0
 def test_error_center_not_point_on_creation(self):
     """C-10. Verify error if center is not a Point on creation."""
     with self.assertRaises(TypeError):
         Circle(center=(0, 0), radius=1.5)
Beispiel #28
0
 def test_IsInside(self):
     circle = Circle(0, 0, 1)
     self.assertTrue(circle.IsInside(0, 0))
     self.assertTrue(circle.IsInside(1, 0))
     self.assertTrue(circle.IsInside(0, 1))
     self.assertFalse(circle.IsInside(0, 1.1))
Beispiel #29
0
    def test_GetArea(self):
        circle = Circle(10, 10, 1)
        self.assertEqual(math.pi, circle.GetArea())

        circle = Circle(20, 20, 1)
        self.assertEqual(math.pi, circle.GetArea())
Beispiel #30
0
 def test_center_change(self):
     """C-9. Verify center attribute change works."""
     circle = Circle()
     circle.center = Point(1, 2)
     expected = (1, 2)
     self.assertEqual(point_data(circle.center), expected)