'Find size of polygon area in Tkinter Canvas, Python

I am creating program that analises areas of user-drawn shapes. Here is sample of code that creates polygon from dots. Program gets dots from mouse motion. Firstly it draws lines, than erases them and draws figure.

def finish_custom_selection(self, event):
    # self.custom_lines_id - list of id of created by mouse motion lines [id1, id2 ...]
    # self.canvas_for_selection - tkinter canvas I work with
    # self.custom_dots - list of dots coords pairs [(x1, y1), (x2, y2) ...]
    
    for line in self.custom_lines_id:
        self.canvas_for_selection.delete(line)

    item = self.canvas_for_selection.create_polygon(*self.custom_dots,
                                                    dash=(10, 10), width=2,
                                                    fill='',
                                                    tags="draggable",
                                                    outline="blue")

    self.custom_dots.clear()
    self.custom_lines_id.clear()

So here is my question. How can I calculate size of this polygon area? I know algorithms only for convex polygon, but these area can be completely random. Maybe there are any built-in method I am missing?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source