def _read_ground_line_config(self, ground_line_config): points = [Vector2(x) for x in ground_line_config["points"]] shape = Polyline.from_points(points) color = tuple(ground_line_config["color"]) width = ground_line_config["width"] graphic = PolylineGraphic(shape, color, width) return Ground(shape, graphic)
def test_from_points_fails_when_degenerate_lines(self): with pytest.raises(ValueError) as e: Polyline.from_points([Vector2(0, 0), Vector2(0, 0), Vector2(1, 3)]) assert "The Line must have a positive length" == str(e.value)
def polyline_graphic(self): polyline = Polyline.from_points( [Vector2(0, 0), Vector2(1, 2), Vector2(5, 4)]) return PolylineGraphic(polyline, (1, 2, 3), 2)
def test_from_points_sets_data_members_correctly(self): polyline = Polyline.from_points( [Vector2(0, 0), Vector2(0, 1), Vector2(1, 3)]) assert line_eq(polyline.lines[0], Line(Vector2(0, 0), Vector2(0, 1))) assert line_eq(polyline.lines[1], Line(Vector2(0, 1), Vector2(1, 3)))