Closed dmi3kno closed 4 years ago
I see that I can just iterate over children and set attributes of interest to NULL
doc$children[[1]]$children[[1]]$attribs$fill <- NULL
doc$children[[1]]$children[[2]]$attribs$fill <- NULL
Or as a function
unset_children <- function(obj, ...){
obj$update_child_list(
lapply(obj$children, function(x)
lapply(list(...), function(a){x$attribs[[a]] <- NULL; x})
))
}
I am looking at the awesome vignette about editing SVGs (thank you!) and I wonder how I can recolor the rectangles in this example.
I can try and set fill on the group, but of course it does not have any effect, since the values of the elements are still red and yellow.
I wrote a little function that is able to iterate over children and sets the attribute for each kid. I can use it to set every rectangle in the group to "green".
What I would like to do is to iterate over children and "unset" (i.e. remove) certain attribute, with the objective of later setting them on the group level.