getMobjectsFrom method
Implementation
List<VMobject> getMobjectsFrom(
Element element, SVGElementStyle initialStyle) {
var result = <VMobject>[];
var tagName = element.localName?.toLowerCase();
var style = initialStyle.update(getElementStyle(element));
if (tagName == 'defs') {
updateRefToElement(element);
} else if (tagName == 'style') {
// don't handle style
} else if (['g', 'svg', 'symbol'].contains(tagName)) {
result.addAll([
for (var child in element.children) ...getMobjectsFrom(child, style)
]);
} else if (tagName == 'path') {
var pathData = element.attributes['d'];
if (pathData != null && pathData.isNotEmpty) {
result.add(pathStringToMobject(pathData, style, element));
}
} else if (tagName == 'use') {
result.addAll(useToMobjects(element, style));
} else if (tagName == 'rect') {
result.add(rectToMobject(element, style));
} else if (tagName == 'ellipse') {
result.add(ellipseToMobject(element, style));
} else if (tagName == 'circle') {
result.add(circleToMobject(element, style));
} else if (tagName == 'polygon' || tagName == 'polyline') {
result.add(polygonToMobject(element, style));
} else {
print('Unknown SVG element $tagName');
}
var vgroup = VGroup(result);
handleTransforms(element, vgroup);
if (result.length > 1 && !unpackGroups) {
result = [vgroup];
}
return result;
}