path property

Path? get path

The engine path for this shape, or null if it draws nothing.

Implementation

ui.Path? get path {
  if (_pathResolved) return _path;
  _pathResolved = true;
  switch (type) {
    case SVGAShapeType.shape:
      final outline = this.outline;
      if (outline != null && !outline.isEmpty) _path = outline.path;
    case SVGAShapeType.rect:
      if (width > 0 && height > 0) {
        _path = ui.Path()
          ..addRRect(
            ui.RRect.fromRectAndRadius(
              ui.Rect.fromLTWH(x, y, width, height),
              ui.Radius.circular(cornerRadius),
            ),
          );
      }
    case SVGAShapeType.ellipse:
      if (width > 0 && height > 0) {
        _path = ui.Path()
          ..addOval(
            ui.Rect.fromLTWH(x - width, y - height, width * 2, height * 2),
          );
      }
    case SVGAShapeType.keep:
      break;
  }
  return _path;
}