'how to use polyline in order to draw a polygon with 2 open coordenates in python?
A. Polyline Department The department must receive a collection of points (at least 2 points are required, but there is no upper limit to the number of points). Also, the last variable is a Boolean variable (Closed) which determines whether the polygon is closed or open (True / False), the default is False (open polygon). The collection of points is given as Tuples in format (x, y), which represent the coordinate of one of the vertices. P = Polyline ((1,2), (5,8), (3,8), True) P2 = Polyline ((4.3), (5.9), (2.4), False) If it is closed, we must check that it is "normal" so that the ribs do not overlap. If there is an intersection of ribs, Exception should be excluded. The following methods will be defined for the department:
- draw - which shows the polygon on the canvas. It is possible to define additional settings, such as the color of the line / thickness, etc. by activating the definition from the draw line
- Area - Returns the area of the polygon, if it is an open polygon, will be returned -1.
- str - Returns a string to display the shape
print (P) Polyline ((1,2), (3,8), (5,8), (1,2) print (P2) Polyline ((2.4), (5.9), (4.3))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
