public static Picture readPictureFromTriangles(String path) throws Exception {
        List<Triangle> triangles = new ArrayList<Triangle>();
        File file = new File(path);
        System.out.println(file.getAbsolutePath());
        // File file = new File("/home/arto/Popup-course/triangulation/testi.tr");
        Scanner reader = new Scanner(file);

        String size = reader.nextLine();
        String[] dimension = size.split("\\s+");

        int width = Integer.parseInt(dimension[0]);
        int height = Integer.parseInt(dimension[1]);

        int numOfTriangles = Integer.parseInt(reader.nextLine());

        while (reader.hasNextLine()) {
            String line = reader.nextLine().trim();
            if (line.isEmpty()) {
                continue;
            }

            String[] parts = line.split("\\s+");
            int[] rgba = new int[]{Integer.parseInt(parts[6]), Integer.parseInt(parts[7]), Integer.parseInt(parts[8]), Integer.parseInt(parts[9])};

            Triangle t = new Triangle(rgba,
                    new Point(Integer.parseInt(parts[0]), Integer.parseInt(parts[1])),
                    new Point(Integer.parseInt(parts[2]), Integer.parseInt(parts[3])),
                    new Point(Integer.parseInt(parts[4]), Integer.parseInt(parts[5])));

            triangles.add(t);
        }

        assert triangles.size() == numOfTriangles;
        Picture p = new Picture(width, height);
        for (Triangle t : triangles) {
            p.addTriangle(t);
        }

        return p;
    }