The svg_polygon() function adds a polygon to an svg object. In the
context of an SVG shape a polygon is similar to a polyline (defined by a
series of points) except that the path will be automatically closed (i.e.,
last point connects to the first point). Like a polyline, a polygon is drawn
by connecting a series of points with straight lines. The points can be
provided as a vector that's exactly divisible by two, or, as a formatted
string that adheres to the specification of the points attribute of the SVG
<polygon> tag. All point positions are in units of px.
svg_polygon( svg, points, stroke = NULL, stroke_width = NULL, fill = NULL, opacity = NULL, attrs = list(), anims = list(), filters = list(), id = NULL )
| svg | The |
|---|---|
| points | A numeric vector of points (with alternating values for |
| stroke | The color of the stroke applied to the element (i.e., the outline). |
| stroke_width | The width of the stroke in units of pixels. |
| fill | The fill color of the element. |
| opacity | The opacity of the element. Must be a value in the
range of |
| attrs | A presentation attribute list. The helper function
|
| anims | An animation directive list for the element. This should be
structured using the |
| filters | A filter directive list for the element. This is easily
created by using a list of |
| id | An optional ID value to give to the built tag. This is useful for modifying this element in a later function call or for interacting with CSS. |
# Create an SVG with a single # polygon element svg <- SVG(width = 300, height = 300) %>% svg_polygon( points = "100,10 40,198 190,78 10,78 160,198", stroke = "orange", stroke_width = 4, fill = "yellow" )