getPathDs method

List<String> getPathDs(
  1. String pathId
)

Returns a list of path 'd' attributes associated with the given pathId.

This method searches for a <path> or <g> element with the matching 'id' attribute. It automatically handles cases where an ID represents a pair of symmetric muscles by checking for 'left_' and 'right_' prefixes if the original ID is not found.

Implementation

List<String> getPathDs(String pathId) {
  _ensureLoaded();
  final id = pathId.toLowerCase();

  // Check caches first
  if (_pathCache.containsKey(id)) {
    return [_pathCache[id]!];
  }
  if (_groupCache.containsKey(id)) {
    return _groupCache[id]!;
  }
  if (!id.contains('outline') && !id.startsWith('left_') && !id.startsWith('right_')) {
    final paths = getPathDs('right_$id') + getPathDs('left_$id');
    if(paths.isNotEmpty) {
      _groupCache[id] = paths;
      return paths;
    }
  }

  final doc = _document!;

  // Try path
  final path = _findPathById(doc.rootElement, id);
  if (path != null) {
    final d = path.getAttribute('d') ?? '';
    _pathCache[id] = d;
    return [d];
  }

  // Try group
  final group = _findGroupById(doc.rootElement, id);
  if (group != null) {
    final ds = _collectPathsFromGroup(group);
    _groupCache[id] = ds;
    return ds;
  }

  return [];
}