| Title: | SVG Document Builder |
|---|---|
| Description: | Build SVG documents with R. |
| Authors: | Mike FC [aut, cre], Dmytro Perepolkin [ctb] |
| Maintainer: | Mike FC <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.12 |
| Built: | 2026-05-24 06:22:53 UTC |
| Source: | https://github.com/coolbutuseless/minisvg |
Add a method to the SVGElement class which creates a new child SVGElement of the specified type
add_method(method_name, element_name, args)add_method(method_name, element_name, args)
method_name |
name of method in SVGElement class |
element_name |
the name of the SVG element to add |
args |
character vector of argument names |
Convert a CSS 'property' object to a string
## S3 method for class 'svg_property' as.character(x, ...)## S3 method for class 'svg_property' as.character(x, ...)
x |
property object |
... |
other arguments |
Character representation of SVGDocument
## S3 method for class 'SVGDocument' as.character(x, include_declaration = TRUE, ...)## S3 method for class 'SVGDocument' as.character(x, include_declaration = TRUE, ...)
x |
SVGDocument |
include_declaration |
Include the SVG declaration at the top? Default: TRUE |
... |
other arguments |
Character representation of SVGElement
## S3 method for class 'SVGElement' as.character(x, ...)## S3 method for class 'SVGElement' as.character(x, ...)
x |
SVGElement |
... |
other arguments |
Character representation of SVGLiteral
## S3 method for class 'SVGLiteral' as.character(x, ...)## S3 method for class 'SVGLiteral' as.character(x, ...)
x |
SVGLiteral |
... |
other arguments |
Character representation of SVGNode
## S3 method for class 'SVGNode' as.character(x, ...)## S3 method for class 'SVGNode' as.character(x, ...)
x |
SVGNode |
... |
other arguments |
knitr/rmarkdown compatibility
knit_print.SVGDocument(x, ...)knit_print.SVGDocument(x, ...)
x |
SVGDocument |
... |
other arguments |
knitr/rmarkdown compatibility
knit_print.SVGFilter(x, ...)knit_print.SVGFilter(x, ...)
x |
SVGFilter |
... |
other arguments |
knitr/rmarkdown compatibility
knit_print.SVGPattern(x, ...)knit_print.SVGPattern(x, ...)
x |
SVGPattern |
... |
other arguments |
This uses 'xml2' package to do the parsing.
parse_inner(xml2_node, as_document = TRUE, as_pattern = FALSE)parse_inner(xml2_node, as_document = TRUE, as_pattern = FALSE)
xml2_node |
root node of a document or an element node |
as_document |
parse the root node as a document node. Default: TRUE |
as_pattern |
parse the root node as a pattern node. Default: FALSE |
Parse SVG text or file into an SVGDocument or SVGElement
parse_svg_doc(x, encoding = "", ..., as_html = FALSE, options = "NOBLANKS") parse_svg_elem( x, encoding = "", ..., as_html = FALSE, options = "NOBLANKS", as_pattern = FALSE )parse_svg_doc(x, encoding = "", ..., as_html = FALSE, options = "NOBLANKS") parse_svg_elem( x, encoding = "", ..., as_html = FALSE, options = "NOBLANKS", as_pattern = FALSE )
x, encoding, ..., as_html, options
|
options passed to |
as_pattern |
parse the root node as a pattern node. Default: FALSE |
XMLDocument or XMLElement
This function creates a named list. It's purpose is mainly as a helper - by having most presentation as named arguments we can use code auto-completion to help remember the 50+ possible attributes.
pres( ..., alignment_baseline, baseline_shift, clip_path, clip_rule, color, color_interpolation, color_interpolation_filters, color_profile, color_rendering, cursor, direction, display, dominant_baseline, enable_background, fill, fill_opacity, fill_rule, filter, flood_color, flood_opacity, font, font_family, font_size, font_size_adjust, font_stretch, font_style, font_variant, font_weight, glyph_orientation_vertical, image_rendering, kerning, letter_spacing, lighting_color, marker, marker_end, marker_mid, marker_start, mask, opacity, overflow, pointer_events, shape_rendering, stop_color, stop_opacity, stroke, stroke_dasharray, stroke_dashoffset, stroke_linecap, stroke_linejoin, stroke_miterlimit, stroke_opacity, stroke_width, text_anchor, text_decoration, text_rendering, unicode_bidi, visibility, word_spacing, writing_mode )pres( ..., alignment_baseline, baseline_shift, clip_path, clip_rule, color, color_interpolation, color_interpolation_filters, color_profile, color_rendering, cursor, direction, display, dominant_baseline, enable_background, fill, fill_opacity, fill_rule, filter, flood_color, flood_opacity, font, font_family, font_size, font_size_adjust, font_stretch, font_style, font_variant, font_weight, glyph_orientation_vertical, image_rendering, kerning, letter_spacing, lighting_color, marker, marker_end, marker_mid, marker_start, mask, opacity, overflow, pointer_events, shape_rendering, stop_color, stop_opacity, stroke, stroke_dasharray, stroke_dashoffset, stroke_linecap, stroke_linejoin, stroke_miterlimit, stroke_opacity, stroke_width, text_anchor, text_decoration, text_rendering, unicode_bidi, visibility, word_spacing, writing_mode )
... |
other named parameters |
alignment_baseline, baseline_shift, clip_path, clip_rule, color, color_interpolation, color_interpolation_filters, color_profile, color_rendering, cursor, direction, display, dominant_baseline, enable_background, fill, fill_opacity, fill_rule, filter, flood_color, flood_opacity, font, font_family, font_size, font_size_adjust, font_stretch, font_style, font_variant, font_weight, glyph_orientation_vertical, image_rendering, kerning, letter_spacing, lighting_color, marker, marker_end, marker_mid, marker_start, mask, opacity, overflow, pointer_events, shape_rendering, stop_color, stop_opacity, stroke, stroke_dasharray, stroke_dashoffset, stroke_linecap, stroke_linejoin, stroke_miterlimit, stroke_opacity, stroke_width, text_anchor, text_decoration, text_rendering, unicode_bidi, visibility, word_spacing, writing_mode
|
named parameters (included to help when using auto-complete) |
For convenience, any underscores in the names will be replaced by dashes. This is because no sane CSS attributes are named with an underscore, but names with dashes are clunky to write in R.
Reference: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Presentation
a list of presentation attributes
Print a CSS 'property' object
## S3 method for class 'svg_property' print(x, ...)## S3 method for class 'svg_property' print(x, ...)
x |
property object |
... |
other arguments |
SVG shower
show_svg(svg, viewer = getOption("viewer", utils::browseURL))show_svg(svg, viewer = getOption("viewer", utils::browseURL))
svg |
SVG text or object |
viewer |
viewer |
SVG builder functions. Similar in purpose to shiny::tags,
but with auto-complete of attribute names as part of the function call.
## Not run: stag$circle(cx = 10, cy = 10, r = 15) # <circle cx="10" cy="10" r="15" /> ## End(Not run)## Not run: stag$circle(cx = 10, cy = 10, r = 15) # <circle cx="10" cy="10" r="15" /> ## End(Not run)
Uses autocomplete to help write some standard propertys
svg_propsvg_prop
An object of class list of length 42.
SVGDocument Class
SVGDocument Class
This is a specialized subclass of SVGElement containing some methods specific
to the top level SVG node.
Has only been tested with MacOS and Rstudio
minisvg::SVGNode -> minisvg::SVGElement -> SVGDocument
width, heightdimensions of document
width, heightdimensions of document
new()
Initialise a new SVG document
SVGDocument$new( ..., width = 400, height = 400, viewBox = NULL, preserveAspectRatio = NULL, xmlns = "http://www.w3.org/2000/svg", xmlns_xlink = "http://www.w3.org/1999/xlink" )
...further arguments. Named arguments treated as attributes, unnamed arguments treated as child nodes
width, heightSVG dimensions. default: 400x400
viewBoxif NULL, then set to "0 0 width height"
preserveAspectRatio, xmlns, xmlns_xlinkstandard SVG attributes
save_html()
Save a complete HTML document containing this SVG document
SVGDocument$save_html(filename)
filenameHTML filename
show()
Render the SVG in the current viewer.
SVGDocument$show(viewer = getOption("viewer", utils::browseURL))viewerwhich viewer to use?
inline_css()
Use the supplied string as the inline CSS for this document
SVGDocument$inline_css(css)
cssstring containing CSS
print()
Print the SVGDocument object
SVGDocument$print(include_declaration = TRUE, ...)
include_declarationInclude the XML declaration? default: TRUE
...other arguments passed to $as_character()
clone()
The objects of this class are cloneable with this method.
SVGDocument$clone(deep = FALSE)
deepWhether to make a deep clone.
A class representing a single SVG element.
A class representing a single SVG element.
minisvg::SVGNode -> SVGElement
nameTag name for this node e.g. "circle"
attribsnamed list of attributes for this node
childrenordered list of direct child nodes (kept in insertion order)
childlists of child nodes indexed by tag name.
a()
SVGElement$a(..., href = NULL)
animate()
SVGElement$animate( ..., attributeName = NULL, attributeType = NULL, from = NULL, to = NULL, dur = NULL, repeatCount = NULL, begin = NULL, end = NULL, calcMode = NULL, values = NULL, keyTimes = NULL, keySplines = NULL, by = NULL )
animateMotion()
SVGElement$animateMotion( ..., calcMode = NULL, path = NULL, keyPoints = NULL, rotate = NULL, origin = NULL )
animateTransform()
SVGElement$animateTransform( ..., attributeName = NULL, attributeType = NULL, by = NULL, from = NULL, to = NULL, type = NULL, dur = NULL, repeatCount = NULL )
circle()
SVGElement$circle(..., cx = NULL, cy = NULL, r = NULL)
clipPath()
SVGElement$clipPath(..., id = NULL)
defs()
SVGElement$defs(...)
desc()
SVGElement$desc(...)
discard()
SVGElement$discard(..., begin = NULL, href = NULL)
ellipse()
SVGElement$ellipse(..., cx = NULL, cy = NULL, rx = NULL, ry = NULL)
feBlend()
SVGElement$feBlend(..., in_ = NULL, in2 = NULL, mode = NULL, result = NULL)
feColorMatrix()
SVGElement$feColorMatrix( ..., in_ = NULL, type = NULL, values = NULL, result = NULL )
feComponentTransfer()
SVGElement$feComponentTransfer(..., in_ = NULL, result = NULL)
feComposite()
SVGElement$feComposite( ..., in_ = NULL, in2 = NULL, operator = NULL, k1 = NULL, k2 = NULL, k3 = NULL, k4 = NULL, result = NULL )
feConvolveMatrix()
SVGElement$feConvolveMatrix( ..., in_ = NULL, order = NULL, kernelMatrix = NULL, divisor = NULL, bias = NULL, targetX = NULL, targetY = NULL, edgeMode = NULL, kernelUnitLength = NULL, preserveAlpha = NULL, result = NULL )
feDiffuseLighting()
SVGElement$feDiffuseLighting( ..., in_ = NULL, surfaceScale = NULL, diffuseConstant = NULL, kernelUnitLength = NULL, result = NULL )
feDisplacementMap()
SVGElement$feDisplacementMap( ..., in_ = NULL, in2 = NULL, scale = NULL, xChannelSelector = NULL, yChannelSelector = NULL, result = NULL )
feFlood()
SVGElement$feFlood( ..., flood_color = NULL, flood_opacity = NULL, result = NULL )
feFuncR()
SVGElement$feFuncR(..., type = NULL, tableValues = NULL)
feFuncG()
SVGElement$feFuncG(..., type = NULL, tableValues = NULL)
feFuncB()
SVGElement$feFuncB(..., type = NULL, tableValues = NULL)
feFuncA()
SVGElement$feFuncA(..., type = NULL, tableValues = NULL)
feGaussianBlur()
SVGElement$feGaussianBlur( ..., in_ = NULL, stdDeviation = NULL, edgeMode = NULL, result = NULL )
feImage()
SVGElement$feImage( ..., preserveAspectRatio = NULL, xlink_href = NULL, result = NULL )
feMerge()
SVGElement$feMerge(..., result = NULL)
feMergeNode()
SVGElement$feMergeNode(..., in_ = NULL)
feMorphology()
SVGElement$feMorphology( ..., in_ = NULL, operator = NULL, radius = NULL, result = NULL )
feOffset()
SVGElement$feOffset(..., in_ = NULL, dx = NULL, dy = NULL, result = NULL)
feSpecularLighting()
SVGElement$feSpecularLighting( ..., in_ = NULL, surfaceScale = NULL, specularConstant = NULL, specularExponent = NULL, kernelUnitLength = NULL, result = NULL )
feTile()
SVGElement$feTile(..., in_ = NULL, result = NULL)
feTurbulence()
SVGElement$feTurbulence( ..., type = NULL, baseFrequency = NULL, numOctaves = NULL, seed = NULL, stitchTiles = NULL, result = NULL )
filter()
SVGElement$filter( ..., id = NULL, x = NULL, y = NULL, width = NULL, height = NULL, filterRes = NULL, filterUnits = NULL, primitiveUnits = NULL, xlink_href = NULL )
foreignObject()
SVGElement$foreignObject(..., x = NULL, y = NULL, width = NULL, height = NULL)
g()
SVGElement$g(..., id = NULL)
image()
SVGElement$image( ..., x = NULL, y = NULL, width = NULL, height = NULL, xlink_href = NULL, preserveAspectRatio = NULL )
line()
SVGElement$line(..., x1 = NULL, y1 = NULL, x2 = NULL, y2 = NULL)
linearGradient()
SVGElement$linearGradient( ..., x1 = NULL, y1 = NULL, x2 = NULL, y2 = NULL, href = NULL, gradientTransform = NULL, gradientUnits = NULL, spreadMethod = NULL )
marker()
SVGElement$marker( ..., refX = NULL, refY = NULL, markerWidth = NULL, markerHeight = NULL, markerUnits = NULL, orient = NULL, preserveAspectRatio = NULL, viewBox = NULL )
mask()
SVGElement$mask( ..., x = NULL, y = NULL, width = NULL, height = NULL, maskUnits = NULL, maskContentUnits = NULL )
mpath()
SVGElement$mpath(..., xlink_href = NULL)
path()
SVGElement$path(..., d = NULL, pathLength = NULL)
pattern()
SVGElement$pattern( ..., id = NULL, x = NULL, y = NULL, width = NULL, height = NULL, href = NULL, patternUnits = NULL, patternTransform = NULL, preserveAspectRatio = NULL )
radialGradient()
SVGElement$radialGradient( ..., id = NULL, cx = NULL, cy = NULL, r = NULL, fx = NULL, fy = NULL, fr = NULL, href = NULL, gradientUnits = NULL, gradientTransform = NULL, spreadMethod = NULL )
rect()
SVGElement$rect( ..., x = NULL, y = NULL, width = NULL, height = NULL, rx = NULL, ry = NULL )
script()
SVGElement$script(..., type = NULL, href = NULL)
set()
SVGElement$set(..., to = NULL)
stop()
SVGElement$stop(..., offset = NULL, stop_color = NULL, stop_opacity = NULL)
style()
SVGElement$style(...)
switch()
SVGElement$switch(...)
symbol()
SVGElement$symbol( ..., id = NULL, x = NULL, y = NULL, width = NULL, height = NULL, refX = NULL, refY = NULL, preserveAspectRatio = NULL )
text()
SVGElement$text( ..., x = NULL, y = NULL, dx = NULL, dy = NULL, rotate = NULL, textWidth = NULL, lengthAdjust = NULL )
textPath()
SVGElement$textPath( ..., href = NULL, path = NULL, method = NULL, side = NULL, spacing = NULL, startOffset = NULL, textLength = NULL, lengthAdjust = NULL )
title()
SVGElement$title(...)
use()
SVGElement$use( ..., x = NULL, y = NULL, width = NULL, height = NULL, href = NULL )
matrix()
SVGElement$matrix(a, b, c, d, e, f)
translate()
SVGElement$translate(x, y = NULL)
scale()
SVGElement$scale(x, y = NULL)
rotate()
SVGElement$rotate(a, x = NULL, y = NULL)
skewX()
SVGElement$skewX(a)
skewY()
SVGElement$skewY(a)
polygon()
SVGElement$polygon(xs = NULL, ys = NULL, points = NULL, ...)
polyline()
SVGElement$polyline(xs = NULL, ys = NULL, points = NULL, ...)
new()
Initialize an SVGElement
SVGElement$new(name, ...)
namenode name e.g. "circle"
...further arguments. Named arguments treated as attributes, unnamed arguments treated as child nodes
update()
Update the SVG Element.
SVGElement$update(...)
...attributes and children to set on this node
Named arguments are considered attributes and will overwrite existing attributes with the same name. Set to NULL to delete the attribute
Unnamed arguments are appended to the list of child nodes. These should be text, other SVGElements or any ojbect that can be represented as a single text string using "as.character()"
To print just the attribute name, but without a value, set to NA
append()
Append child nodes at the specified position.
SVGElement$append(..., position = NULL)
...child nodes
positionby default at the end of the list of children nodes but 'position' argument can be used to set location by index
update_child_list()
Update the list of child nodes by tag name
SVGElement$update_child_list(new_elem)
new_elemthe element being added
rebuild_child_list()
URebuild the list of child nodes by tag name
SVGElement$rebuild_child_list()
add()
Simultaneous create an SVG element and add it as a child node
SVGElement$add(name, ...)
namename of node to create
...attributes and children of this newly created node
In contrast to most other methods, $add() returns
the newly created element, not the document
remove()
Remove child objects at the given indices
SVGElement$remove(indices)
indicesindices of the children to remove
reset_transform()
Remove any transform attributes from this node
SVGElement$reset_transform()
as_character_inner()
Recursively convert this SVGElement and children to text
SVGElement$as_character_inner(..., depth = 0)
...ignored
depthrecursion depth
single character string
as_character()
Recursively convert this SVGElement and children to text
SVGElement$as_character(..., depth = 0, include_declaration = FALSE)
...ignored
depthrecursion depth. default: 0
include_declarationInclude the leading XML declaration? default: FALSE
single character string
save()
Save the text representation of this node and its children
SVGElement$save(filename, include_declaration = FALSE, ...)
filenamefilename
include_declarationInclude the leading XML declaration? default: FALSE
...Extra arguments passed to SVGElement$as_character()
has_attribs()
test if this element has all of the named attributes
SVGElement$has_attribs(attribs)
namedlist of attributes
logical. Note: if length(attribs) == 0, this method returns
TRUE
find()
Find elements which match the given tag names and attributes.
SVGElement$find(tag = c(), attribs = list())
tagcharacter vector of tags to find. default: c()
attribsnamed list of attributes to match. default: list().
Note that attribute matching is matched using in
List of R6 reference objects
\dontrun{
doc$find(tag = c('rect', 'circle'), attribs = list(fill = c('red', 'black')))
}
copy()
Make a deep copy of this node and its children
SVGElement$copy()
clone()
The objects of this class are cloneable with this method.
SVGElement$clone(deep = FALSE)
deepWhether to make a deep clone.
## ------------------------------------------------ ## Method `SVGElement$find` ## ------------------------------------------------ ## Not run: doc$find(tag = c('rect', 'circle'), attribs = list(fill = c('red', 'black'))) ## End(Not run)## ------------------------------------------------ ## Method `SVGElement$find` ## ------------------------------------------------ ## Not run: doc$find(tag = c('rect', 'circle'), attribs = list(fill = c('red', 'black'))) ## End(Not run)
SVGFilter Class
SVGFilter Class
This is a slightly specialized subclass of SVGElement which has methods
to specifically handle SVG <filter> nodes
minisvg::SVGNode -> minisvg::SVGElement -> SVGFilter
new()
Initialise an SVGFilter object
SVGFilter$new(..., name = "filter")
...Further arguments passed to SVGElement$new()
namedefaults to 'filter'
as_full_svg()
Wrap the SVG for this filter in a full SVG document and return the text
SVGFilter$as_full_svg(width = 400, height = width)
height, widthdimensions of SVG wrapper around this filter
save_full_svg()
Save the SVG for this filter in a full SVG document
SVGFilter$save_full_svg(filename, include_declaration = TRUE, ...)
filenamefilename for output
include_declarationInclude leading XML declaration. default: TRUE
...Further arguments passed to SVGFilter$as_full_svg()
show()
Render this filter in the context of a complete SVG document
SVGFilter$show(..., viewer = getOption("viewer", utils::browseURL))...Further arguments passed to SVGFilter$save_full_svg()
viewerviewer.
clone()
The objects of this class are cloneable with this method.
SVGFilter$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run: f <- SVGFilter$new(id = "turbulence-filter", stag$feTurbulence(...)) ## End(Not run)## Not run: f <- SVGFilter$new(id = "turbulence-filter", stag$feTurbulence(...)) ## End(Not run)
A class representing a literal SVG element.
A class representing a literal SVG element.
minisvg::SVGNode -> SVGLiteral
xliteral contents. Must be coercible to string via 'as.character(x)'
namekept only for compatibility with other SVGNode objects. This should be set to 'literal'
new()
Initialize an SVGElement
SVGLiteral$new(x, ...)
xthe literal text to include
...further arguments. Named arguments treated as attributes, unnamed arguments treated as child nodes
update()
Update the SVG Element.
SVGLiteral$update(x, ...)
xthe literal text to include
...attributes and children to set on this node
Named arguments are considered attributes and will overwrite existing attributes with the same name. Set to NULL to delete the attribute
Unnamed arguments are appended to the list of child nodes. These should be text, other SVGElements or any ojbect that can be represented as a single text string using "as.character()"
To print just the attribute name, but without a value, set to NA
as_character_inner()
Convert this SVGLiteral
SVGLiteral$as_character_inner(...)
...ignored
single character string
as_character()
Convert this SVGLiteral
SVGLiteral$as_character(...)
...ignored
single character string
clone()
The objects of this class are cloneable with this method.
SVGLiteral$clone(deep = FALSE)
deepWhether to make a deep clone.
A class representing a single SVG element.
A class representing a single SVG element.
css_declscharacter vector of css declaration text for this node
css_urlscharacter vector of css urls for this node
js_codecharacter vector of javascript code for this node
js_urlscharacter vector of javascript urls for this node
new()
Initialize an SVGNode
SVGNode$new()
update()
Update the SVG Element.
SVGNode$update(...)
...attributes and children to set on this node
Named arguments are considered attributes and will overwrite existing attributes with the same name. Set to NULL to delete the attribute
Unnamed arguments are appended to the list of child nodes. These should be text, other SVGElements or any ojbect that can be represented as a single text string using "as.character()"
To print just the attribute name, but without a value, set to NA
add_css_url()
Add a URL to a CSS style sheet
SVGNode$add_css_url(css_url)
css_urlURL to style sheet. e.g. $add_css_url("css/local.css")
add_css()
Add a CSS declaration for this element.
SVGNode$add_css(css_decl)
css_declCSS string, or object which can be coerced to character.
e.g. $add_dec("#thing {font-size: 27px}")
add_js_code()
Add javascript code for this element
SVGNode$add_js_code(js_code)
js_codecharacter string containing javascript code.
add_js_url()
Add a javaxcript URL to load within the SVG
SVGNode$add_js_url(js_url)
js_urlURL to javascript code. e.g. $add_js_url("example.org/eg.js")
get_css_decls()
Create a CSS declaration string for inclusion in the character output for this element.
SVGNode$get_css_decls()
this includes all css for all child elements
get_css_urls()
Create a vector or urls for CSS inclustion
SVGNode$get_css_urls()
this includes all CSS URLs for all child elements
get_js_code()
Create a character vector of JS code for this node and all child nodes.
SVGNode$get_js_code()
get_js_urls()
Create a vector of external JS urls
SVGNode$get_js_urls()
this includes all CSS URLs for all child elements
get_css_style()
Create a complete CSS <style> tag using the declarations and URLs of the current element, and all child elements.
SVGNode$get_css_style()
character string
get_js_style()
Create a complete CSS style tag using the declarations and URLs of the current element, and all child elements.
SVGNode$get_js_style()
character string
as_character_inner()
Recursively convert this SVGElement and children to text
SVGNode$as_character_inner()
single character string
as_character()
Recursively convert this SVGElement and children to text
SVGNode$as_character()
single character string
print()
Print the SVG string to the terminal
SVGNode$print(include_declaration = FALSE, ...)
include_declarationInclude the leading XML declaration? default: FALSE
...Extra arguments passed to SVGElement$as_character()
save()
Save the text representation of this node and its children
SVGNode$save(filename, include_declaration = FALSE, ...)
filenamefilename
include_declarationInclude the leading XML declaration? default: FALSE
...Extra arguments passed to SVGElement$as_character()
copy()
Make a deep copy of this node and its children
SVGNode$copy()
find()
Find elements which match the given tags
SVGNode$find(tags)
tagscharacter vector of tags to accept
minisvg objects which inherit from SVGNode will return NULL unless this method is overridden.
clone()
The objects of this class are cloneable with this method.
SVGNode$clone(deep = FALSE)
deepWhether to make a deep clone.
SVGPattern Class
SVGPattern Class
This is a slightly specialized subclass of SVGElement which has methods
to specifically handle SVG <pattern> nodes
SVGPattern objects may also have their own 'filter_def' filter definition.
minisvg::SVGNode -> minisvg::SVGElement -> SVGPattern
filter_defA filter definition to accompany this pattern
new()
Initialise an SVGPattern object
SVGPattern$new(..., name = "pattern")
...Further arguments passed to SVGElement$new()
namedefaults to 'pattern', but some gradients may also be used here
as_full_svg()
Wrap the SVG for this pattern in a full SVG document and return the text
SVGPattern$as_full_svg(width = 400, height = width)
height, widthdimensions of SVG wrapper around this pattern
save_full_svg()
Save the SVG for this pattern in a full SVG document
SVGPattern$save_full_svg(filename, include_declaration = TRUE, ...)
filenamefilename for output
include_declarationInclude leading XML declaration. default: TRUE
...Further arguments passed to SVGPattern$as_full_svg()
as_character()
Recursively convert this SVGElement and children to text
SVGPattern$as_character(..., depth = 0, include_declaration = FALSE)
...ignored
depthrecursion depth. default: 0
include_declarationInclude the leading XML declaration? default: FALSE
single character string
show()
Render this pattern in the context of a complete SVG document
SVGPattern$show(..., viewer = getOption("viewer", utils::browseURL))...Further arguments passed to SVGPattern$save_full_svg()
viewerviewer.
clone()
The objects of this class are cloneable with this method.
SVGPattern$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run: a <- SVGPattern$new() f <- stag$filter(id = "turbulence-filter", stag$feTurbulence(...)) a$filter_def <- f ## End(Not run)## Not run: a <- SVGPattern$new() f <- stag$filter(id = "turbulence-filter", stag$feTurbulence(...)) a$filter_def <- f ## End(Not run)
Create a complete SVG object from an svg pattern
SVGPatternList_to_svg(pattern_list, width = 400, height = 400, ncol = 2, ...)SVGPatternList_to_svg(pattern_list, width = 400, height = 400, ncol = 2, ...)
pattern_list |
svg_pattern_list object |
width, height
|
the display width of the surrounding SVG wrapper. defualt: 400x400 |
ncol |
number of columns. if NULL, then will use an auto-layout |
... |
other arguments ignored |