NewPolygon returns a polygon that uses the default line style and no fill color, where xys are the rings of the polygon. Different backends may render overlapping rings and self-intersections differently, but all built-in backends treat inner rings with the opposite winding order from the outer ring
(xys ...XYer)
| 35 | // with the opposite winding order from the outer ring as |
| 36 | // holes. |
| 37 | func NewPolygon(xys ...XYer) (*Polygon, error) { |
| 38 | data := make([]XYs, len(xys)) |
| 39 | for i, d := range xys { |
| 40 | var err error |
| 41 | data[i], err = CopyXYs(d) |
| 42 | if err != nil { |
| 43 | return nil, err |
| 44 | } |
| 45 | } |
| 46 | return &Polygon{ |
| 47 | XYs: data, |
| 48 | LineStyle: DefaultLineStyle, |
| 49 | }, nil |
| 50 | } |
| 51 | |
| 52 | // Plot draws the polygon, implementing the plot.Plotter |
| 53 | // interface. |