A class representing a single SVG element.

A class representing a single SVG element.

Public fields

css_decls

character vector of css declaration text for this node

css_urls

character vector of css urls for this node

js_code

character vector of javascript code for this node

js_urls

character vector of javascript urls for this node

Methods

Public methods


Method new()

Initialize an SVGNode

Usage

SVGNode$new()


Method update()

Update the SVG Element.

Usage

SVGNode$update(...)

Arguments

...

attributes and children to set on this node

Details

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


Method add_css_url()

Add a URL to a CSS style sheet

Usage

SVGNode$add_css_url(css_url)

Arguments

css_url

URL to style sheet. e.g. $add_css_url("css/local.css")


Method add_css()

Add a CSS declaration for this element.

Usage

SVGNode$add_css(css_decl)

Arguments

css_decl

CSS string, or object which can be coerced to character. e.g. $add_dec("#thing {font-size: 27px}")


Method add_js_code()

Add javascript code for this element

Usage

SVGNode$add_js_code(js_code)

Arguments

js_code

character string containing javascript code.


Method add_js_url()

Add a javaxcript URL to load within the SVG

Usage

SVGNode$add_js_url(js_url)

Arguments

js_url

URL to javascript code. e.g. $add_js_url("example.org/eg.js")


Method get_css_decls()

Create a CSS declaration string for inclusion in the character output for this element.

Usage

SVGNode$get_css_decls()

Details

this includes all css for all child elements


Method get_css_urls()

Create a vector or urls for CSS inclustion

Usage

SVGNode$get_css_urls()

Details

this includes all CSS URLs for all child elements


Method get_js_code()

Create a character vector of JS code for this node and all child nodes.

Usage

SVGNode$get_js_code()


Method get_js_urls()

Create a vector of external JS urls

Usage

SVGNode$get_js_urls()

Details

this includes all CSS URLs for all child elements


Method get_css_style()

Create a complete CSS <style> tag using the declarations and URLs of the current element, and all child elements.

Usage

SVGNode$get_css_style()

Returns

character string


Method get_js_style()

Create a complete CSS style tag using the declarations and URLs of the current element, and all child elements.

Usage

SVGNode$get_js_style()

Returns

character string


Method as_character_inner()

Recursively convert this SVGElement and children to text

Usage

SVGNode$as_character_inner()

Returns

single character string


Method as_character()

Recursively convert this SVGElement and children to text

Usage

SVGNode$as_character()

Returns

single character string


Method print()

Print the SVG string to the terminal

Usage

SVGNode$print(include_declaration = FALSE, ...)

Arguments

include_declaration

Include the leading XML declaration? default: FALSE

...

Extra arguments passed to SVGElement$as_character()


Method save()

Save the text representation of this node and its children

Usage

SVGNode$save(filename, include_declaration = FALSE, ...)

Arguments

filename

filename

include_declaration

Include the leading XML declaration? default: FALSE

...

Extra arguments passed to SVGElement$as_character()


Method copy()

Make a deep copy of this node and its children

Usage

SVGNode$copy()


Method find()

Find elements which match the given tags

Usage

SVGNode$find(tags)

Arguments

tags

character vector of tags to accept

Returns

minisvg objects which inherit from SVGNode will return NULL unless this method is overridden.


Method clone()

The objects of this class are cloneable with this method.

Usage

SVGNode$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.