The svg_image()
function adds an image to an svg
object. The starting
position is defined by x
and y
values. The image width
and height
are
also required. All of these attributes are expressed in units of px
.
svg_image( svg, x, y, image, width = NULL, height = NULL, preserve_aspect_ratio = NULL, opacity = NULL, attrs = list(), anims = list(), filters = list(), id = NULL )
svg | The |
---|---|
x, y | The |
image | The URL for the image file. |
width, height | The width and height of the rectangle in which the image will be placed. If both are not provided, the image's original dimensions will be used. If one of these is provided, then the image will be scaled to the provided value with the aspect ratio intact. Providing both will result in the image placed in center of the rectangle with the aspect ratio preserved. |
preserve_aspect_ratio | Controls how the aspect ratio of the image is
preserved. Use |
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 an SVG image # (the R logo) contained within it svg <- SVG(width = 300, height = 300) %>% svg_image( x = 20, y = 20, width = 100, height = 100, image = "https://www.r-project.org/logo/Rlogo.svg" )