zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils module

SVG circle/ellipse detection and elongation utilities.

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils._load_svg_tree(svg_input)[source]

Load SVG XML tree from either file path or cache hash.

Parameters:

svg_input – Either a file path or cache hash (starting with 'svg_')

Returns:

ElementTree object

Raises:
  • FileNotFoundError – If file doesn’t exist

  • ValueError – If cache hash not found

  • ET.ParseError – If XML parsing fails

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils._create_backup(svg_path)[source]

Create a backup copy of the SVG file.

Returns:

Path to backup file or None on failure

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils._restore_from_backup(svg_path, backup_path)[source]

Restore SVG file from backup.

Returns:

True if successful, False otherwise

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils._cleanup_backup(backup_path)[source]

Remove backup file if it exists.

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils.is_circle_svg(svg_path)[source]

Check if SVG contains a single circle or ellipse element.

Returns:

True if SVG contains exactly one <circle> or <ellipse> element, False otherwise

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils.get_circle_bounds(svg_path)[source]

Get circle/ellipse bounds: (cx, cy, rx, ry).

For circles, rx = ry = r.

Returns:

Tuple of (cx, cy, rx, ry) or None if not a circle/ellipse

zooui.objects.mediaobjects.mediaobjectsutils.svg.utils.svgcircleutils.elongate_circle(svg_path, scale_x, scale_y)[source]

Elongate circle/ellipse by scaling radii from center.

Stores modified SVG in cache and returns cache hash.

Parameters:
  • svg_path – Path to SVG file (will be read but not modified)

  • scale_x – Multiplier for rx (minimum 0.2)

  • scale_y – Multiplier for ry (minimum 0.2)

Returns:

svg_{8_char_hex})

Return type:

Cache hash of modified SVG (format

Raises:
  • ValueError – If scale_x < 0.2 or scale_y < 0.2

  • Exception – If SVG parsing or modification fails

See Also

  • zooui/objects/mediaobjects/svgmediaobject - SVGMediaObject class

  • zooui/objects/mediaobjects/mediaobjectsutils/svg/svgcache/svgcache - SVG caching system